add prog1 and prog2, asm and bin files
This commit is contained in:
parent
88271c91ca
commit
8a89c6bf70
31
prog1.asm
Normal file
31
prog1.asm
Normal 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
|
||||||
33
prog2.asm
Normal file
33
prog2.asm
Normal 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
|
||||||
Loading…
x
Reference in New Issue
Block a user