entry main.enter; import "../IMPORT/register.h"; import "../IMPORT/callsys.h"; import "../IMPORT/proc.h"; import "../IMPORT/invoc.h"; import "../IMPORT/callsys.lib.s"; import "../IMPORT/memory.lib.s"; public block lowData { data { public address: } } import "../IMPORT/string.lib.s"; import "../IMPORT/number.lib.s"; import "../IMPORT/bool.lib.s"; import "../IMPORT/io.lib.s"; import "../IMPORT/dString.lib.s"; import "../IMPORT/array.lib.s"; import "../IMPORT/INST.s"; public block main uses register { public block subClass { } public block static { public block field { data { public i_0: quad; } } public block method { } } public block static { public block init extends proc.sav0 uses proc { local { public max: } code { public enter: lda $sp, -max($sp); stq $ra, savRA($sp); clr $ip; clr $nip; mov $sp, $fp; { ldiq $at, main.static.field.i_0; stq $zero, 0($at); } { { const { align; string: asciiz "while"; align; } ldiq $a0, string; bsr Array.fromString.enter; mov $v0, $t0; } mov $t0, $a0; bsr Array.toString.enter; mov $v0, $a0; bsr IO.println.enter; } { ldiq $t0, 0; ldiq $t1, main.static.field.i_0; stq $t0, 0($t1); } { while: ldiq $t0, main.static.field.i_0; ldq $t0, 0($t0); ldiq $t1, 6; cmplt $t0, $t1, $t0; beq $t0, end; do: { ldiq $t0, main.static.field.i_0; ldq $t0, 0($t0); mov $t0, $a0; mov 10, $a1; bsr Number.toSigned.enter; mov $v0, $a0; bsr Array.fromString.enter; mov $v0, $t0; mov $t0, $a0; bsr Array.toString.enter; mov $v0, $a0; bsr IO.println.enter; } { ldiq $t0, main.static.field.i_0; ldq $t0, 0($t0); ldiq $t1, 1; addq $t0, $t1, $t0; ldiq $t1, main.static.field.i_0; stq $t0, 0($t1); } continue: br while; break: end: } { ldiq $t0, 0; ldiq $t1, main.static.field.i_0; stq $t0, 0($t1); } { { const { align; string: asciiz "do"; align; } ldiq $a0, string; bsr Array.fromString.enter; mov $v0, $t0; } mov $t0, $a0; bsr Array.toString.enter; mov $v0, $a0; bsr IO.println.enter; } { do: { ldiq $t0, main.static.field.i_0; ldq $t0, 0($t0); mov $t0, $a0; mov 10, $a1; bsr Number.toSigned.enter; mov $v0, $a0; bsr Array.fromString.enter; mov $v0, $t0; mov $t0, $a0; bsr Array.toString.enter; mov $v0, $a0; bsr IO.println.enter; } { ldiq $t0, main.static.field.i_0; ldq $t0, 0($t0); ldiq $t1, 1; addq $t0, $t1, $t0; ldiq $t1, main.static.field.i_0; stq $t0, 0($t1); } continue: ldiq $t0, main.static.field.i_0; ldq $t0, 0($t0); ldiq $t1, 6; cmplt $t0, $t1, $t0; bne $t0, do; break: end: } { { const { align; string: asciiz "for"; align; } ldiq $a0, string; bsr Array.fromString.enter; mov $v0, $t0; } mov $t0, $a0; bsr Array.toString.enter; mov $v0, $a0; bsr IO.println.enter; } { for: ldiq $t0, 0; ldiq $t1, main.static.field.i_0; stq $t0, 0($t1); while: ldiq $t0, main.static.field.i_0; ldq $t0, 0($t0); ldiq $t1, 6; cmplt $t0, $t1, $t0; beq $t0, end; do: { ldiq $t0, main.static.field.i_0; ldq $t0, 0($t0); mov $t0, $a0; mov 10, $a1; bsr Number.toSigned.enter; mov $v0, $a0; bsr Array.fromString.enter; mov $v0, $t0; mov $t0, $a0; bsr Array.toString.enter; mov $v0, $a0; bsr IO.println.enter; } continue: ldiq $t1, main.static.field.i_0; ldq $t0, 0($t1); addq $t0, 1, $t2; stq $t2, 0($t1); br while; break: end: } ldq $ra, savRA($sp); lda $sp, +max($sp); ret; } } } code { public enter: clr $ip; clr $nip; ldiq $a0, lowData.address; ldiq $a1, highData.address; mov $sp, $a2; bsr Memory.initialise.enter; bsr static.init.enter; mov 0, $a0; bsr Sys.exit.enter; } } public block highData { data { public address: } }