Chanded versin

This commit is contained in:
nils polek 2024-01-18 19:56:11 +00:00
parent 1f02f49cdf
commit f60e82b46b
6 changed files with 178 additions and 1 deletions

View File

@ -1,6 +1,6 @@
#ifndef CONSTS #ifndef CONSTS
#define CONSTS #define CONSTS
#define VERSION 6 #define VERSION 8
#endif /* ifndef CONSTS #endif /* ifndef CONSTS
#define CONSTS #define CONSTS

177
fib.asm Normal file
View File

@ -0,0 +1,177 @@
//
// version
//
.vers 6
//
// 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 main()
//
_main:
asf 2
call _readInteger
pushr
popl 0
pushl 0
call _fib
drop 1
pushr
popl 1
pushl 0
call _writeInteger
drop 1
pushc 10
call _writeCharacter
drop 1
pushc 102
call _writeCharacter
drop 1
pushc 105
call _writeCharacter
drop 1
pushc 98
call _writeCharacter
drop 1
pushc 58
call _writeCharacter
drop 1
pushc 32
call _writeCharacter
drop 1
pushl 1
call _writeInteger
drop 1
pushc 10
call _writeCharacter
drop 1
__0:
rsf
ret
//
// Integer fib(Integer)
//
_fib:
asf 4
pushc 0
popl 0
pushc 1
popl 1
pushc 0
popl 2
pushc 1
popl 3
pushl -3
pushc 2
lt
brf __2
pushc 1
popr
jmp __1
jmp __3
__2:
jmp __5
__4:
pushl 0
pushl 1
add
popl 2
pushl 1
popl 0
pushl 2
popl 1
pushl 3
pushc 1
add
popl 3
__5:
pushl 3
pushl -3
lt
brt __4
__6:
pushl 2
popr
jmp __1
__3:
__1:
rsf
ret

BIN
fib.bin?inline=false Normal file

Binary file not shown.

BIN
njvm.o

Binary file not shown.

BIN
prog.bin

Binary file not shown.

BIN
support.o

Binary file not shown.