AnnexF/weigh_il.txt
author mjsousa
Sun, 14 Dec 2014 18:40:20 +0000
changeset 963 e3d4dca7520b
parent 0 fb772792efd1
permissions -rwxr-xr-x
Do constant folding of variable's initial value (allows correct C code generation with variables in the subrange of an array declaration: ARRAY [1..max] of INT).
FUNCTION WEIGH : WORD     (* BCD encoded *)
  VAR_INPUT  (* "EN" input is used to indicate "scale ready" *)
    weigh_command : BOOL;
    gross_weight : WORD ; (* BCD encoded *)
    tare_weight : INT ;
  END_VAR
(* Function Body *)
	LD	weigh_command	
	JMPC	WEIGH_NOW	
	ST	ENO	(* No weighing, 0 to "ENO" *)
	RET		
WEIGH_NOW:	LD	gross_weight	
	BCD_TO_INT		
	SUB	tare_weight	
	INT_TO_BCD		(* Return evaluated weight *)
	ST	WEIGH	

END_FUNCTION                     (* Implicit "ENO" *)