add prog1 and prog2, asm and bin files

This commit is contained in:
Elias Bennour 2023-12-04 01:21:36 +01:00
parent 88271c91ca
commit 8a89c6bf70
4 changed files with 64 additions and 0 deletions

31
prog1.asm Normal file
View File

@ -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

BIN
prog1.bin Normal file

Binary file not shown.

33
prog2.asm Normal file
View File

@ -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

BIN
prog2.bin Normal file

Binary file not shown.