| ||||||
begin integer a; a := 5.5; end | ERROR: line 3: attempt to assign real expression '5.500000' to integer variable 'a'. | |||||
| ||||||
begin integer i; real i; print 5; end | ERROR: line 3: attempt to declare already used integer 'i' as real | |||||
| ||||||
begin a := 5; end | ERROR: line 2: cannot assign to undeclared variable 'a' | |||||
| ||||||
begin integer a; integer b; a := 5 := b; end | ERROR: line 4: cannot assign to the number '5'. | |||||
| ||||||
begin integer a; a := 5 % 2.5; end | ERROR: line 3: cannot modulus reals | |||||
| ||||||
begin real a; a := 9.0 % 3.0; end | ERROR: line 3: cannot modulus reals | |||||
| ||||||
begin integer a; real b; a := 5 * 4 + 1 - 20 * 3; b := a / 4.0 + 3 * 20.2 + a end | ERROR: line 6: syntax error | |||||
| ||||||
begin integer a; end a := 5; | ERROR: line 4: syntax error | |||||
| ||||||
begin integer a := 5 b := 6; end | ERROR: line 2: syntax error | |||||
| ||||||
begin integer a := 5 + ( ) - 2; print a; end | ERROR: line 2: empty expression | |||||
| ||||||
begin print 5 ** 3.5; end | ERROR: line 2: Exponentiation by a real number is not supported. | |||||
| ||||||
begin real b := 6.0; print 5 ** b; end | ERROR: line 3: Exponentiation by a real number is not supported. | |||||
| ||||||
begin integer i; integer a; integer i; print 4; end | ERROR: line 4: attempt to declare already used integer 'i' as integer | |||||
| ||||||
begin if 5 > 3 begin integer a; print a; end end | ERROR: line 2: syntax error | |||||
| ||||||
begin integer a; integer b; for a := 5 step 1 until 10 begin b := b + a; end end | ERROR: line 6: missing 'do' keyword in 'for..step..until' | |||||
| ||||||
begin integer a; integer b := 0; for a := 1 1 until 5 do begin b := b + a; end print b; end | ERROR: line 5: missing 'step' keyword in 'for..step..until' | |||||
| ||||||
begin integer a; integer b := 0; for a := 1 step 1 5 do begin b := b + a; end print b; end | ERROR: line 5: missing 'until' keyword in 'for..step..until' | |||||
| ||||||
begin integer a; integer b := 0; comment This should use YACC's 'error' to give a decent diagnostic. ; for a := 20 a > 0 do begin b := b + 1; a := a - 1; end print b; end | ERROR: line 17: syntax error | |||||
| ||||||
procedure a() begin integer i := 1; print i; print a; end procedure b() begin real r := 2.0; print r; end begin integer i; real r; a(); b(); print(3); end | ERROR: line 5: attempt to use procedure 'a' as a variable, use 'a()'. | |||||
| ||||||
procedure a() begin integer i := 1; print i; end procedure a() begin real r := 2.0; print r; end begin a(); end | ERROR: line 7: attempt to redefine function 'a'. | |||||
| ||||||
procedure foo() begin print 5; end begin print foo(); end | ERROR: line 7: attempt to use non-typed function 'foo' in expression | |||||
| ||||||
procedure real foo() begin foo := 5.5; end begin integer ret := foo(); end | ERROR: line 7: attempt to assign real value 'foo' to integer variable. | |||||
| ||||||
procedure integer bar(integer a, real b) begin print a; print b; end begin print bar(5); end | ERROR: line 8: too few parameters being passed to 'bar' | |||||
| ||||||
procedure real qux(integer a, real b) begin print a; print b; end begin print qux(5.5, 5); end | ERROR: line 8: param 1 of 'qux' of type 'integer' being passed as 'real' | |||||
| ||||||
procedure zxc(integer a) begin print a; end begin zxc(5, 1, 3); end | ERROR: line 7: too many arguments to function 'zxc' | |||||
| ||||||
begin integer a; a := 5; print a; end | declare a&1,integer
store 0,a&1 store 5,a&1 write a&1 halt | |||||
| ||||||
begin integer a; integer b; a := 5; b := 6; integer c := b := a; print a; print b; print c; end | declare a&1,integer
store 0,a&1 declare b&1,integer store 0,b&1 store 5,a&1 store 6,b&1 store a&1,b&1 declare c&1,integer store b&1,c&1 write a&1 write b&1 write c&1 halt | |||||
| ||||||
begin integer a := 5; integer b := 10; integer c; print a; print b; print c; c := a := 15; print a; print b; print c; end | declare a&1,integer
store 5,a&1 declare b&1,integer store 10,b&1 declare c&1,integer store 0,c&1 write a&1 write b&1 write c&1 store 15,a&1 store a&1,c&1 write a&1 write b&1 write c&1 halt | |||||
| ||||||
begin integer a := 4; integer b := 5; print a; print b; a := b + 5 + b - 4 * 2 + b / 3; print a; print b; end | declare a&1,integer
store 4,a&1 declare b&1,integer store 5,b&1 write a&1 write b&1 declare T&&0,integer iadd b&1,5,T&&0 declare T&&1,integer iadd T&&0,b&1,T&&1 declare T&&2,integer imult 4,2,T&&2 declare T&&3,integer isub T&&1,T&&2,T&&3 declare T&&4,integer idiv b&1,3,T&&4 declare T&&5,integer iadd T&&3,T&&4,T&&5 store T&&5,a&1 write a&1 write b&1 halt | |||||
| ||||||
begin integer a; a := 5 * 1 + 4 / 8 - 4 + 20 % 3; print a; end | declare a&1,integer
store 0,a&1 declare T&&0,integer imult 5,1,T&&0 declare T&&1,integer idiv 4,8,T&&1 declare T&&2,integer iadd T&&0,T&&1,T&&2 declare T&&3,integer isub T&&2,4,T&&3 declare T&&4,integer imod 20,3,T&&4 declare T&&5,integer iadd T&&3,T&&4,T&&5 store T&&5,a&1 write a&1 halt | |||||
| ||||||
begin real a; a := 5.3 * 1.9 + 4.2 / 8.5 - 4.1 + 20.0; print a; end | declare a&1,real
store 0.000000,a&1 declare T&&0,real rmult 5.300000,1.900000,T&&0 declare T&&1,real rdiv 4.200000,8.500000,T&&1 declare T&&2,real radd T&&0,T&&1,T&&2 declare T&&3,real rsub T&&2,4.100000,T&&3 declare T&&4,real radd T&&3,20.000000,T&&4 store T&&4,a&1 write a&1 halt | |||||
| ||||||
begin integer a; real b; a := 5 * 4 + 1 - 20 * 3; print a; b := a / 4.0 + 3 * 20.2 + a; print b; end | declare a&1,integer
store 0,a&1 declare b&1,real store 0.000000,b&1 declare T&&0,integer imult 5,4,T&&0 declare T&&1,integer iadd T&&0,1,T&&1 declare T&&2,integer imult 20,3,T&&2 declare T&&3,integer isub T&&1,T&&2,T&&3 store T&&3,a&1 write a&1 declare T&&4,real itor a&1,T&&4 declare T&&5,real rdiv T&&4,4.000000,T&&5 declare T&&6,real itor 3,T&&6 declare T&&7,real rmult T&&6,20.200001,T&&7 declare T&&8,real radd T&&5,T&&7,T&&8 declare T&&9,real itor a&1,T&&9 declare T&&10,real radd T&&8,T&&9,T&&10 store T&&10,b&1 write b&1 halt | |||||
| ||||||
begin integer a := 20; integer b := 5; print a; print b; b := a + b - 2 * a; a := a + 2 * b - 2; print a; print b; end | declare a&1,integer
store 20,a&1 declare b&1,integer store 5,b&1 write a&1 write b&1 declare T&&0,integer iadd a&1,b&1,T&&0 declare T&&1,integer imult 2,a&1,T&&1 declare T&&2,integer isub T&&0,T&&1,T&&2 store T&&2,b&1 declare T&&3,integer imult 2,b&1,T&&3 declare T&&4,integer iadd a&1,T&&3,T&&4 declare T&&5,integer isub T&&4,2,T&&5 store T&&5,a&1 write a&1 write b&1 halt | |||||
| ||||||
begin integer a, b, c, d, e, f; end | declare f&1,integer
store 0,f&1 declare e&1,integer store 0,e&1 declare d&1,integer store 0,d&1 declare c&1,integer store 0,c&1 declare b&1,integer store 0,b&1 declare a&1,integer store 0,a&1 halt | |||||
| ||||||
begin integer a := 5, b, c := -1, d := 5334, e; print a; print b; print c; print d; print e; end | declare e&1,integer
store 0,e&1 declare d&1,integer store 5334,d&1 declare c&1,integer store -1,c&1 declare b&1,integer store 0,b&1 declare a&1,integer store 5,a&1 write a&1 write b&1 write c&1 write d&1 write e&1 halt | |||||
| ||||||
begin integer a := 5 * (2 + 2) / (10 % 3) * (2 - -3 * -4); print a; end | declare T&&0,integer
iadd 2,2,T&&0 declare T&&1,integer imult 5,T&&0,T&&1 declare T&&2,integer imod 10,3,T&&2 declare T&&3,integer idiv T&&1,T&&2,T&&3 declare T&&4,integer imult -3,-4,T&&4 declare T&&5,integer isub 2,T&&4,T&&5 declare T&&6,integer imult T&&3,T&&5,T&&6 declare a&1,integer store T&&6,a&1 write a&1 halt | |||||
| ||||||
# new program /* declare some variables */ begin real /* embedded comment */ j; // It's j real r; /* another generic real */ r := j := 4.0; # make them both 4 end // end the program | declare j&1,real
store 0.000000,j&1 declare r&1,real store 0.000000,r&1 store 4.000000,j&1 store j&1,r&1 halt | |||||
| ||||||
begin integer a; a := 5 ** 6; print a; a := 2 ** 2; print a; end | declare a&1,integer
store 0,a&1 declare T&&0,integer store 1,T&&0 declare T&&1,integer equ 6,0,T&&1 jt T&&1,:expoutT&&0 store 5,T&&0 declare T&&2,integer equ 6,1,T&&2 jt T&&2,:expoutT&&0 declare T&&3,integer store 6,T&&3 :expT&&0 declare T&&4,integer imult T&&0,5,T&&4 store T&&4,T&&0 declare T&&5,integer isub T&&3,1,T&&5 store T&&5,T&&3 declare T&&6,integer equ T&&3,1,T&&6 jf T&&6,:expT&&0 :expoutT&&0 store T&&0,a&1 write a&1 declare T&&7,integer store 1,T&&7 declare T&&8,integer equ 2,0,T&&8 jt T&&8,:expoutT&&7 store 2,T&&7 declare T&&9,integer equ 2,1,T&&9 jt T&&9,:expoutT&&7 declare T&&10,integer store 2,T&&10 :expT&&7 declare T&&11,integer imult T&&7,2,T&&11 store T&&11,T&&7 declare T&&12,integer isub T&&10,1,T&&12 store T&&12,T&&10 declare T&&13,integer equ T&&10,1,T&&13 jf T&&13,:expT&&7 :expoutT&&7 store T&&7,a&1 write a&1 halt | |||||
| ||||||
begin real b; b := 3.5 ** 5; print b; b := 8.3 ** 6; print b; end | declare b&1,real
store 0.000000,b&1 declare T&&0,real declare T&&1,real itor 1,T&&1 store T&&1,T&&0 declare T&&2,integer equ 5,0,T&&2 jt T&&2,:expoutT&&0 store 3.500000,T&&0 declare T&&3,integer equ 5,1,T&&3 jt T&&3,:expoutT&&0 declare T&&4,integer store 5,T&&4 :expT&&0 declare T&&5,real rmult T&&0,3.500000,T&&5 store T&&5,T&&0 declare T&&6,integer isub T&&4,1,T&&6 store T&&6,T&&4 declare T&&7,integer equ T&&4,1,T&&7 jf T&&7,:expT&&0 :expoutT&&0 store T&&0,b&1 write b&1 declare T&&8,real declare T&&9,real itor 1,T&&9 store T&&9,T&&8 declare T&&10,integer equ 6,0,T&&10 jt T&&10,:expoutT&&8 store 8.300000,T&&8 declare T&&11,integer equ 6,1,T&&11 jt T&&11,:expoutT&&8 declare T&&12,integer store 6,T&&12 :expT&&8 declare T&&13,real rmult T&&8,8.300000,T&&13 store T&&13,T&&8 declare T&&14,integer isub T&&12,1,T&&14 store T&&14,T&&12 declare T&&15,integer equ T&&12,1,T&&15 jf T&&15,:expT&&8 :expoutT&&8 store T&&8,b&1 write b&1 halt | |||||
| ||||||
begin print 5 ** 2 + 6 ** 2 + 7 ** 2; end | declare T&&0,integer
store 1,T&&0 declare T&&1,integer equ 2,0,T&&1 jt T&&1,:expoutT&&0 store 5,T&&0 declare T&&2,integer equ 2,1,T&&2 jt T&&2,:expoutT&&0 declare T&&3,integer store 2,T&&3 :expT&&0 declare T&&4,integer imult T&&0,5,T&&4 store T&&4,T&&0 declare T&&5,integer isub T&&3,1,T&&5 store T&&5,T&&3 declare T&&6,integer equ T&&3,1,T&&6 jf T&&6,:expT&&0 :expoutT&&0 declare T&&7,integer store 1,T&&7 declare T&&8,integer equ 2,0,T&&8 jt T&&8,:expoutT&&7 store 6,T&&7 declare T&&9,integer equ 2,1,T&&9 jt T&&9,:expoutT&&7 declare T&&10,integer store 2,T&&10 :expT&&7 declare T&&11,integer imult T&&7,6,T&&11 store T&&11,T&&7 declare T&&12,integer isub T&&10,1,T&&12 store T&&12,T&&10 declare T&&13,integer equ T&&10,1,T&&13 jf T&&13,:expT&&7 :expoutT&&7 declare T&&14,integer iadd T&&0,T&&7,T&&14 declare T&&15,integer store 1,T&&15 declare T&&16,integer equ 2,0,T&&16 jt T&&16,:expoutT&&15 store 7,T&&15 declare T&&17,integer equ 2,1,T&&17 jt T&&17,:expoutT&&15 declare T&&18,integer store 2,T&&18 :expT&&15 declare T&&19,integer imult T&&15,7,T&&19 store T&&19,T&&15 declare T&&20,integer isub T&&18,1,T&&20 store T&&20,T&&18 declare T&&21,integer equ T&&18,1,T&&21 jf T&&21,:expT&&15 :expoutT&&15 declare T&&22,integer iadd T&&14,T&&15,T&&22 write T&&22 halt | |||||
| ||||||
/* begin integer a := 5, b, c := -1, d := 5334, e; print a; print b; print c; print d; print e; end */ begin print 5; end | write 5
halt | |||||
| ||||||
begin integer i:=5; real r:=i; print r; real d:=5; print d; end | declare i&1,integer
store 5,i&1 declare T&&0,real itor i&1,T&&0 declare r&1,real store T&&0,r&1 write r&1 declare T&&1,real itor 5,T&&1 declare d&1,real store T&&1,d&1 write d&1 halt | |||||
| ||||||
begin integer i; i:= 1 and 2; i:= 2 or 3; i:= not 1; end | declare i&1,integer
store 0,i&1 declare T&&0,integer and 1,2,T&&0 store T&&0,i&1 declare T&&1,integer or 2,3,T&&1 store T&&1,i&1 declare T&&2,integer not 1,T&&2 store T&&2,i&1 halt | |||||
| ||||||
begin print 5 <= 3; print 3 <= 5; print 10 <= 10; print -5 <= 4; print 0 <= -0; print 25 <= 23; end | declare T&&0,integer
low 5,3,T&&0 declare T&&1,integer equ 5,3,T&&1 declare T&&2,integer or T&&0,T&&1,T&&2 write T&&2 declare T&&3,integer low 3,5,T&&3 declare T&&4,integer equ 3,5,T&&4 declare T&&5,integer or T&&3,T&&4,T&&5 write T&&5 declare T&&6,integer low 10,10,T&&6 declare T&&7,integer equ 10,10,T&&7 declare T&&8,integer or T&&6,T&&7,T&&8 write T&&8 declare T&&9,integer low -5,4,T&&9 declare T&&10,integer equ -5,4,T&&10 declare T&&11,integer or T&&9,T&&10,T&&11 write T&&11 declare T&&12,integer low 0,0,T&&12 declare T&&13,integer equ 0,0,T&&13 declare T&&14,integer or T&&12,T&&13,T&&14 write T&&14 declare T&&15,integer low 25,23,T&&15 declare T&&16,integer equ 25,23,T&&16 declare T&&17,integer or T&&15,T&&16,T&&17 write T&&17 halt | |||||
| ||||||
begin print 5 < 3; print 3 < 5; print 10 < 10; print -5 < 4; print 0 < -0; print 25 < 23; end | declare T&&0,integer
low 5,3,T&&0 write T&&0 declare T&&1,integer low 3,5,T&&1 write T&&1 declare T&&2,integer low 10,10,T&&2 write T&&2 declare T&&3,integer low -5,4,T&&3 write T&&3 declare T&&4,integer low 0,0,T&&4 write T&&4 declare T&&5,integer low 25,23,T&&5 write T&&5 halt | |||||
| ||||||
begin print 5 == 3; print 3 == 5; print 10 == 10; print -5 == 4; print 0 == -0; print 25 == 23; end | declare T&&0,integer
equ 5,3,T&&0 write T&&0 declare T&&1,integer equ 3,5,T&&1 write T&&1 declare T&&2,integer equ 10,10,T&&2 write T&&2 declare T&&3,integer equ -5,4,T&&3 write T&&3 declare T&&4,integer equ 0,0,T&&4 write T&&4 declare T&&5,integer equ 25,23,T&&5 write T&&5 halt | |||||
| ||||||
begin print 5 != 3; print 3 != 5; print 10 != 10; print -5 != 4; print 0 != -0; print 25 != 23; end | declare T&&0,integer
equ 5,3,T&&0 declare T&&1,integer not T&&0,T&&1 write T&&1 declare T&&2,integer equ 3,5,T&&2 declare T&&3,integer not T&&2,T&&3 write T&&3 declare T&&4,integer equ 10,10,T&&4 declare T&&5,integer not T&&4,T&&5 write T&&5 declare T&&6,integer equ -5,4,T&&6 declare T&&7,integer not T&&6,T&&7 write T&&7 declare T&&8,integer equ 0,0,T&&8 declare T&&9,integer not T&&8,T&&9 write T&&9 declare T&&10,integer equ 25,23,T&&10 declare T&&11,integer not T&&10,T&&11 write T&&11 halt | |||||
| ||||||
begin print 5 > 3; print 3 > 5; print 10 > 10; print -5 > 4; print 0 > -0; print 25 > 23; end | declare T&&0,integer
high 5,3,T&&0 write T&&0 declare T&&1,integer high 3,5,T&&1 write T&&1 declare T&&2,integer high 10,10,T&&2 write T&&2 declare T&&3,integer high -5,4,T&&3 write T&&3 declare T&&4,integer high 0,0,T&&4 write T&&4 declare T&&5,integer high 25,23,T&&5 write T&&5 halt | |||||
| ||||||
begin print 5 >= 3; print 3 >= 5; print 10 >= 10; print -5 >= 4; print 0 >= -0; print 25 >= 23; end | declare T&&0,integer
high 5,3,T&&0 declare T&&1,integer equ 5,3,T&&1 declare T&&2,integer or T&&0,T&&1,T&&2 write T&&2 declare T&&3,integer high 3,5,T&&3 declare T&&4,integer equ 3,5,T&&4 declare T&&5,integer or T&&3,T&&4,T&&5 write T&&5 declare T&&6,integer high 10,10,T&&6 declare T&&7,integer equ 10,10,T&&7 declare T&&8,integer or T&&6,T&&7,T&&8 write T&&8 declare T&&9,integer high -5,4,T&&9 declare T&&10,integer equ -5,4,T&&10 declare T&&11,integer or T&&9,T&&10,T&&11 write T&&11 declare T&&12,integer high 0,0,T&&12 declare T&&13,integer equ 0,0,T&&13 declare T&&14,integer or T&&12,T&&13,T&&14 write T&&14 declare T&&15,integer high 25,23,T&&15 declare T&&16,integer equ 25,23,T&&16 declare T&&17,integer or T&&15,T&&16,T&&17 write T&&17 halt | |||||
| ||||||
begin integer a; integer b := 0; for a := 1 step 1 until a == 5 do begin b := b + a; end print b; end | declare a&1,integer
store 0,a&1 declare b&1,integer store 0,b&1 store 1,a&1 :label&&0 declare T&&0,integer equ a&1,5,T&&0 jt T&&0,:label&&1 declare T&&1,integer iadd b&1,a&1,T&&1 store T&&1,b&1 declare T&&2,integer iadd 1,a&1,T&&2 store T&&2,a&1 jmp :label&&0 :label&&1 write b&1 halt | |||||
| ||||||
begin integer a; integer b := 0; for a := 20 while a > 0 do begin b := b + 1; a := a - 1; end print b; end | declare a&1,integer
store 0,a&1 declare b&1,integer store 0,b&1 store 20,a&1 :label&&0 declare T&&0,integer high a&1,0,T&&0 jf T&&0,:label&&1 declare T&&1,integer iadd b&1,1,T&&1 store T&&1,b&1 declare T&&2,integer isub a&1,1,T&&2 store T&&2,a&1 jmp :label&&0 :label&&1 write b&1 halt | |||||
| ||||||
begin integer a; for a := 5 do begin print a; end end | declare a&1,integer
store 0,a&1 store 5,a&1 write a&1 halt | |||||
| ||||||
begin integer a; integer b := 0; for a := 5 step -1 until a == 0 do begin b := b + a; end print b; end | declare a&1,integer
store 0,a&1 declare b&1,integer store 0,b&1 store 5,a&1 :label&&0 declare T&&0,integer equ a&1,0,T&&0 jt T&&0,:label&&1 declare T&&1,integer iadd b&1,a&1,T&&1 store T&&1,b&1 declare T&&2,integer iadd -1,a&1,T&&2 store T&&2,a&1 jmp :label&&0 :label&&1 write b&1 halt | |||||
| ||||||
begin integer i:=5; if i<6 then begin print i; end end | declare i&1,integer
store 5,i&1 declare T&&0,integer low i&1,6,T&&0 jf T&&0, :label&&0 write i&1 :label&&0 halt | |||||
| ||||||
// should output 1 and 2 begin // 'if'..'else' using then block if 1 > 0 then begin print 1; end else begin print 2; end // 'if'..'else' using else block if 0 > 1 then begin print 1; end else begin print 2; end end | declare T&&0,integer
high 1,0,T&&0 jf T&&0, :label&&0 write 1 jmp :label&&1 :label&&0 write 2 :label&&1 declare T&&1,integer high 0,1,T&&1 jf T&&1, :label&&2 write 1 jmp :label&&3 :label&&2 write 2 :label&&3 halt | |||||
| ||||||
begin integer i:=3; integer j:=4; if i > 2 then begin if j < 5 then begin print 1; end end end | declare i&1,integer
store 3,i&1 declare j&1,integer store 4,j&1 declare T&&0,integer high i&1,2,T&&0 jf T&&0, :label&&0 declare T&&1,integer low j&1,5,T&&1 jf T&&1, :label&&1 write 1 :label&&1 :label&&0 halt | |||||
| ||||||
begin if 1 > 0 then begin print 1; if 0 < 1 then begin print 2; end end else begin print -1; end if 0 > 1 then begin print -1; end else begin print 1; if 0 < 1 then begin print 2; end end end | declare T&&0,integer
high 1,0,T&&0 jf T&&0, :label&&0 write 1 declare T&&1,integer low 0,1,T&&1 jf T&&1, :label&&1 write 2 :label&&1 jmp :label&&2 :label&&0 write -1 :label&&2 declare T&&2,integer high 0,1,T&&2 jf T&&2, :label&&3 write -1 jmp :label&&4 :label&&3 write 1 declare T&&3,integer low 0,1,T&&3 jf T&&3, :label&&5 write 2 :label&&5 :label&&4 halt | |||||
| ||||||
begin if 1 > 0 then begin print 1; if 0 > 1 then begin print 2; end else begin print 3; end end else begin print -1; end if 0 > 1 then begin print -1; end else begin print 1; if 0 > 1 then begin print 2; end else begin print 3; end end end | declare T&&0,integer
high 1,0,T&&0 jf T&&0, :label&&0 write 1 declare T&&1,integer high 0,1,T&&1 jf T&&1, :label&&1 write 2 jmp :label&&2 :label&&1 write 3 :label&&2 jmp :label&&3 :label&&0 write -1 :label&&3 declare T&&2,integer high 0,1,T&&2 jf T&&2, :label&&4 write -1 jmp :label&&5 :label&&4 write 1 declare T&&3,integer high 0,1,T&&3 jf T&&3, :label&&6 write 2 jmp :label&&7 :label&&6 write 3 :label&&7 :label&&5 halt | |||||
| ||||||
procedure abcd() begin integer a; for a := 5 while a >= 0 do begin a := a - 1; end print a; end begin real a; a := 5.5; print a; abcd(); end | jmp :start&
:abcd&0 declare a&1,integer store 0,a&1 store 5,a&1 :label&&0 declare T&&0,integer high a&1,0,T&&0 declare T&&1,integer equ a&1,0,T&&1 declare T&&2,integer or T&&0,T&&1,T&&2 jf T&&2,:label&&1 declare T&&3,integer isub a&1,1,T&&3 store T&&3,a&1 jmp :label&&0 :label&&1 write a&1 return :start& declare a&3,real store 0.000000,a&3 store 5.500000,a&3 write a&3 call :abcd&0 halt | |||||
| ||||||
procedure p() begin integer i := 10; print i; end begin p(); end | jmp :start&
:p&0 declare i&1,integer store 10,i&1 write i&1 return :start& call :p&0 halt | |||||
| ||||||
/* test multiple procedures, blocks within procedures, and localization of variables */ procedure a() begin integer i := 1; print i; end procedure b() begin real r := 2.0; print r; end procedure c() begin integer i; for i := 3 step 1 until i == 10 do begin integer tmp := i; integer i := 0; print tmp; end end begin integer i; real r; a(); b(); c(); print 10; end | jmp :start&
:a&0 declare i&1,integer store 1,i&1 write i&1 return :b&0 declare r&2,real store 2.000000,r&2 write r&2 return :c&0 declare i&3,integer store 0,i&3 store 3,i&3 :label&&0 declare T&&0,integer equ i&3,10,T&&0 jt T&&0,:label&&1 declare tmp&4,integer store i&3,tmp&4 declare i&4,integer store 0,i&4 write tmp&4 declare T&&1,integer iadd 1,i&3,T&&1 store T&&1,i&3 jmp :label&&0 :label&&1 return :start& declare i&5,integer store 0,i&5 declare r&5,real store 0.000000,r&5 call :a&0 call :b&0 call :c&0 write 10 halt | |||||
| ||||||
/* localization of variables */ procedure a() begin integer i; for i := 0 step 1 until i == 10 do begin integer tmp := i; integer i := 0; print tmp; end end begin integer i; real r; a(); print 10; end | jmp :start&
:a&0 declare i&1,integer store 0,i&1 store 0,i&1 :label&&0 declare T&&0,integer equ i&1,10,T&&0 jt T&&0,:label&&1 declare tmp&2,integer store i&1,tmp&2 declare i&2,integer store 0,i&2 write tmp&2 declare T&&1,integer iadd 1,i&1,T&&1 store T&&1,i&1 jmp :label&&0 :label&&1 return :start& declare i&3,integer store 0,i&3 declare r&3,real store 0.000000,r&3 call :a&0 write 10 halt | |||||
| ||||||
procedure integer a() begin a := 5; end begin print a(); end | jmp :start&
:a&0 store 5,a&0_0 return :start& declare a&0_0,integer call :a&0 write a&0_0 halt | |||||
| ||||||
begin print 2**32; print 2**30; print 2**31; print 2**29; print 1**100000; print 0**50; print 50**2; print 12345**1; print 93839**0; end | declare T&&0,integer
store 1,T&&0 declare T&&1,integer equ 32,0,T&&1 jt T&&1,:expoutT&&0 store 2,T&&0 declare T&&2,integer equ 32,1,T&&2 jt T&&2,:expoutT&&0 declare T&&3,integer store 32,T&&3 :expT&&0 declare T&&4,integer imult T&&0,2,T&&4 store T&&4,T&&0 declare T&&5,integer isub T&&3,1,T&&5 store T&&5,T&&3 declare T&&6,integer equ T&&3,1,T&&6 jf T&&6,:expT&&0 :expoutT&&0 write T&&0 declare T&&7,integer store 1,T&&7 declare T&&8,integer equ 30,0,T&&8 jt T&&8,:expoutT&&7 store 2,T&&7 declare T&&9,integer equ 30,1,T&&9 jt T&&9,:expoutT&&7 declare T&&10,integer store 30,T&&10 :expT&&7 declare T&&11,integer imult T&&7,2,T&&11 store T&&11,T&&7 declare T&&12,integer isub T&&10,1,T&&12 store T&&12,T&&10 declare T&&13,integer equ T&&10,1,T&&13 jf T&&13,:expT&&7 :expoutT&&7 write T&&7 declare T&&14,integer store 1,T&&14 declare T&&15,integer equ 31,0,T&&15 jt T&&15,:expoutT&&14 store 2,T&&14 declare T&&16,integer equ 31,1,T&&16 jt T&&16,:expoutT&&14 declare T&&17,integer store 31,T&&17 :expT&&14 declare T&&18,integer imult T&&14,2,T&&18 store T&&18,T&&14 declare T&&19,integer isub T&&17,1,T&&19 store T&&19,T&&17 declare T&&20,integer equ T&&17,1,T&&20 jf T&&20,:expT&&14 :expoutT&&14 write T&&14 declare T&&21,integer store 1,T&&21 declare T&&22,integer equ 29,0,T&&22 jt T&&22,:expoutT&&21 store 2,T&&21 declare T&&23,integer equ 29,1,T&&23 jt T&&23,:expoutT&&21 declare T&&24,integer store 29,T&&24 :expT&&21 declare T&&25,integer imult T&&21,2,T&&25 store T&&25,T&&21 declare T&&26,integer isub T&&24,1,T&&26 store T&&26,T&&24 declare T&&27,integer equ T&&24,1,T&&27 jf T&&27,:expT&&21 :expoutT&&21 write T&&21 declare T&&28,integer store 1,T&&28 declare T&&29,integer equ 100000,0,T&&29 jt T&&29,:expoutT&&28 store 1,T&&28 declare T&&30,integer equ 100000,1,T&&30 jt T&&30,:expoutT&&28 declare T&&31,integer store 100000,T&&31 :expT&&28 declare T&&32,integer imult T&&28,1,T&&32 store T&&32,T&&28 declare T&&33,integer isub T&&31,1,T&&33 store T&&33,T&&31 declare T&&34,integer equ T&&31,1,T&&34 jf T&&34,:expT&&28 :expoutT&&28 write T&&28 declare T&&35,integer store 1,T&&35 declare T&&36,integer equ 50,0,T&&36 jt T&&36,:expoutT&&35 store 0,T&&35 declare T&&37,integer equ 50,1,T&&37 jt T&&37,:expoutT&&35 declare T&&38,integer store 50,T&&38 :expT&&35 declare T&&39,integer imult T&&35,0,T&&39 store T&&39,T&&35 declare T&&40,integer isub T&&38,1,T&&40 store T&&40,T&&38 declare T&&41,integer equ T&&38,1,T&&41 jf T&&41,:expT&&35 :expoutT&&35 write T&&35 declare T&&42,integer store 1,T&&42 declare T&&43,integer equ 2,0,T&&43 jt T&&43,:expoutT&&42 store 50,T&&42 declare T&&44,integer equ 2,1,T&&44 jt T&&44,:expoutT&&42 declare T&&45,integer store 2,T&&45 :expT&&42 declare T&&46,integer imult T&&42,50,T&&46 store T&&46,T&&42 declare T&&47,integer isub T&&45,1,T&&47 store T&&47,T&&45 declare T&&48,integer equ T&&45,1,T&&48 jf T&&48,:expT&&42 :expoutT&&42 write T&&42 write 12345 write 1 halt | |||||
| ||||||
procedure wr(integer i byref, real r byref, integer noref byval) begin i := i + 1; r := r + 1.0; noref := noref + 1; end begin integer i; real r; integer noref; print i; print r; print noref; wr(i, r, noref); print i; print r; print noref; end | jmp :start&
:wr&0 declare i&0,integer store wr&0_1,i&0 declare r&0,real store wr&0_2,r&0 declare noref&0,integer store wr&0_3,noref&0 declare T&&0,integer iadd i&0,1,T&&0 store T&&0,i&0 declare T&&1,real radd r&0,1.000000,T&&1 store T&&1,r&0 declare T&&2,integer iadd noref&0,1,T&&2 store T&&2,noref&0 store i&0,wr&0_1 store r&0,wr&0_2 return :start& declare wr&0_1,integer declare wr&0_2,real declare wr&0_3,integer declare i&2,integer store 0,i&2 declare r&2,real store 0.000000,r&2 declare noref&2,integer store 0,noref&2 write i&2 write r&2 write noref&2 store i&2,wr&0_1 store r&2,wr&0_2 store noref&2,wr&0_3 call :wr&0 store wr&0_1,i&2 store wr&0_2,r&2 write i&2 write r&2 write noref&2 halt |