move programs to a separate folder
fix pushg, popg, pushl and popl
This commit is contained in:
11
programs/prog-test-1.asm
Normal file
11
programs/prog-test-1.asm
Normal file
@@ -0,0 +1,11 @@
|
||||
pushc 3
|
||||
pushc 4
|
||||
add
|
||||
pushc 10
|
||||
pushc 6
|
||||
sub
|
||||
mul
|
||||
wrint
|
||||
pushc 10
|
||||
wrchr
|
||||
halt
|
||||
BIN
programs/prog-test-1.bin
Normal file
BIN
programs/prog-test-1.bin
Normal file
Binary file not shown.
9
programs/prog-test-2.asm
Normal file
9
programs/prog-test-2.asm
Normal file
@@ -0,0 +1,9 @@
|
||||
pushc -2
|
||||
rdint
|
||||
mul
|
||||
pushc 3
|
||||
add
|
||||
wrint
|
||||
pushc '\n'
|
||||
wrchr
|
||||
halt
|
||||
BIN
programs/prog-test-2.bin
Normal file
BIN
programs/prog-test-2.bin
Normal file
Binary file not shown.
5
programs/prog-test-3.asm
Normal file
5
programs/prog-test-3.asm
Normal file
@@ -0,0 +1,5 @@
|
||||
rdchr
|
||||
wrint
|
||||
pushc '\n'
|
||||
wrchr
|
||||
halt
|
||||
BIN
programs/prog-test-3.bin
Normal file
BIN
programs/prog-test-3.bin
Normal file
Binary file not shown.
31
programs/prog1.asm
Normal file
31
programs/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
|
||||
BIN
programs/prog1.bin
Normal file
BIN
programs/prog1.bin
Normal file
Binary file not shown.
33
programs/prog2.asm
Normal file
33
programs/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
|
||||
BIN
programs/prog2.bin
Normal file
BIN
programs/prog2.bin
Normal file
Binary file not shown.
Reference in New Issue
Block a user