added tests

This commit is contained in:
nilspolek 2024-01-27 21:18:34 +01:00
parent 49e4911238
commit 4cc117fdd4
35 changed files with 393 additions and 1 deletions

1
.gitignore vendored
View File

@ -4,4 +4,3 @@ njvm
njvm.dSYM njvm.dSYM
njvm.exe njvm.exe
njvm2 njvm2
test

BIN
test/.DS_Store vendored Normal file

Binary file not shown.

BIN
test/tests/1.bin Normal file

Binary file not shown.

BIN
test/tests/10.bin Normal file

Binary file not shown.

BIN
test/tests/11.bin Normal file

Binary file not shown.

BIN
test/tests/12.bin Normal file

Binary file not shown.

BIN
test/tests/13.bin Normal file

Binary file not shown.

BIN
test/tests/2.bin Normal file

Binary file not shown.

BIN
test/tests/3.bin Normal file

Binary file not shown.

BIN
test/tests/4.bin Normal file

Binary file not shown.

BIN
test/tests/5.bin Normal file

Binary file not shown.

BIN
test/tests/6.bin Normal file

Binary file not shown.

BIN
test/tests/7.bin Normal file

Binary file not shown.

BIN
test/tests/8.bin Normal file

Binary file not shown.

BIN
test/tests/9.bin Normal file

Binary file not shown.

View File

@ -0,0 +1,13 @@
asf 5
pushc 11
call x
wrint
rsf
halt
x:
asf 3
pushc 22
wrint
rsf

View File

@ -0,0 +1,125 @@
//
// version
//
.vers 7
//
// execution framework
//
__start:
call _main
call _exit
__stop:
jmp __stop
//
// Integer readInteger()
//
_readInteger:
asf 0
rdint
popr
rsf
ret
//
// void writeInteger(Integer)
//
_writeInteger:
asf 0
pushl -3
wrint
rsf
ret
//
// Character readCharacter()
//
_readCharacter:
asf 0
rdchr
popr
rsf
ret
//
// void writeCharacter(Character)
//
_writeCharacter:
asf 0
pushl -3
wrchr
rsf
ret
//
// Integer char2int(Character)
//
_char2int:
asf 0
pushl -3
popr
rsf
ret
//
// Character int2char(Integer)
//
_int2char:
asf 0
pushl -3
popr
rsf
ret
//
// void exit()
//
_exit:
asf 0
halt
rsf
ret
//
// void writeString(String)
//
_writeString:
asf 1
pushc 0
popl 0
jmp _writeString_L2
_writeString_L1:
pushl -3
pushl 0
getfa
call _writeCharacter
drop 1
pushl 0
pushc 1
add
popl 0
_writeString_L2:
pushl 0
pushl -3
getsz
lt
brt _writeString_L1
rsf
ret
//
// void main()
//
_main:
asf 0
pushc 4421
pushc 5743
mul
pushc 7699
mul
call _writeInteger
drop 1
__0:
rsf
ret

View File

@ -0,0 +1,5 @@
pushc 5
pushc 4
add
wrint
halt

View File

@ -0,0 +1,5 @@
pushc 5
pushc 4
div
wrint
halt

View File

@ -0,0 +1,5 @@
pushc 5
pushc 4
mod
wrint
halt

View File

@ -0,0 +1,5 @@
pushc 5
pushc 4
mul
wrint
halt

View File

@ -0,0 +1,5 @@
pushc 5
pushc 4
sub
wrint
halt

16
test/tests/brfTest1.asm Normal file
View File

@ -0,0 +1,16 @@
pushc 3
pushc 4
eq
brf L1
pushc 4
L1:
pushc 7
wrint
pushc 10
wrchr
halt

17
test/tests/brfTest2.asm Normal file
View File

@ -0,0 +1,17 @@
pushc 4
pushc 4
eq
brf L1
pushc 6
wrint
pushc 10
wrchr
halt
L1:
pushc 7
wrint
pushc 10
wrchr
halt

19
test/tests/brtTest1.asm Normal file
View File

@ -0,0 +1,19 @@
pushc 3
pushc 4
eq
brt L1
pushc 5
wrint
pushc 10
wrchr
halt
L1:
pushc 7
wrint
pushc 10
wrchr
halt

17
test/tests/brtTest2.asm Normal file
View File

@ -0,0 +1,17 @@
pushc 4
pushc 4
eq
brt L1
pushc 6
wrint
pushc 10
wrchr
halt
L1:
pushc 7
wrint
pushc 10
wrchr
halt

15
test/tests/equalsTest.asm Normal file
View File

@ -0,0 +1,15 @@
pushc 3
pushc 4
eq
wrint
pushc 10
wrchr
pushc 6
pushc 6
eq
wrint
pushc 10
wrchr
halt

View File

@ -0,0 +1,24 @@
pushc 3
pushc 4
ge
wrint
pushc 10
wrchr
pushc 8
pushc 4
ge
wrint
pushc 10
wrchr
pushc 6
pushc 6
ge
wrint
pushc 10
wrchr
halt

View File

@ -0,0 +1,24 @@
pushc 3
pushc 4
gt
wrint
pushc 10
wrchr
pushc 8
pushc 4
gt
wrint
pushc 10
wrchr
pushc 6
pushc 6
gt
wrint
pushc 10
wrchr
halt

19
test/tests/jumpTest.asm Normal file
View File

@ -0,0 +1,19 @@
pushc 3
pushc 4
wrint
pushc 10
wrchr
pushc 3
jmp L1
pushc 4
L1:
wrint
pushc 10
wrchr
halt

View File

@ -0,0 +1,24 @@
pushc 3
pushc 4
le
wrint
pushc 10
wrchr
pushc 8
pushc 4
le
wrint
pushc 10
wrchr
pushc 6
pushc 6
le
wrint
pushc 10
wrchr
halt

View File

@ -0,0 +1,24 @@
pushc 3
pushc 4
lt
wrint
pushc 10
wrchr
pushc 8
pushc 4
lt
wrint
pushc 10
wrchr
pushc 6
pushc 6
lt
wrint
pushc 10
wrchr
halt

BIN
test/tests/nja Executable file

Binary file not shown.

View File

@ -0,0 +1,15 @@
pushc 3
pushc 4
ne
wrint
pushc 10
wrchr
pushc 6
pushc 6
ne
wrint
pushc 10
wrchr
halt

16
test/tests/prog1.asm Normal file
View File

@ -0,0 +1,16 @@
pushc 3
pushc 4
eq
brf L1
pushc 4
L1:
pushc 7
wrint
pushc 10
wrchr
halt