diff --git a/prog1.asm b/prog1.asm new file mode 100644 index 0000000..470fd7a --- /dev/null +++ b/prog1.asm @@ -0,0 +1,31 @@ +// +// prog1.asm -- an assembler example with global variables +// + +// global Integer x; +// global Integer y; +// x = 2; +// y = x + 3; +// x = 7 * y + x; +// writeInteger(x + -33); +// writeCharacter('\n'); + + pushc 2 + popg 0 + pushg 0 + pushc 3 + add + popg 1 + pushc 7 + pushg 1 + mul + pushg 0 + add + popg 0 + pushg 0 + pushc -33 + add + wrint + pushc '\n' + wrchr + halt diff --git a/prog1.bin b/prog1.bin new file mode 100644 index 0000000..9aa0fba Binary files /dev/null and b/prog1.bin differ diff --git a/prog2.asm b/prog2.asm new file mode 100644 index 0000000..5e4b4d5 --- /dev/null +++ b/prog2.asm @@ -0,0 +1,33 @@ +// +// prog2.asm -- an assembler example with local variables +// + +// local Integer x; +// local Integer y; +// x = 2; +// y = x + 3; +// x = 7 * y + x; +// writeInteger(x + -33); +// writeCharacter('\n'); + + asf 2 + pushc 2 + popl 0 + pushl 0 + pushc 3 + add + popl 1 + pushc 7 + pushl 1 + mul + pushl 0 + add + popl 0 + pushl 0 + pushc -33 + add + wrint + pushc '\n' + wrchr + rsf + halt diff --git a/prog2.bin b/prog2.bin new file mode 100644 index 0000000..a6de7a6 Binary files /dev/null and b/prog2.bin differ