2018-02-25 15:43:00 +00:00
|
|
|
; source code for a tinyvm program
|
|
|
|
%block b1
|
|
|
|
%vardefs
|
2018-02-27 21:16:45 +00:00
|
|
|
var byte teller 1
|
2018-03-02 01:49:43 +00:00
|
|
|
var byte numbertoprint 0
|
2018-02-27 21:16:45 +00:00
|
|
|
const byte one 1
|
2018-02-28 01:40:16 +00:00
|
|
|
const byte thousand 100000
|
|
|
|
var array_byte newlinestr 2 [32 32]
|
2018-02-25 15:43:00 +00:00
|
|
|
%end_vardefs
|
|
|
|
|
|
|
|
%instructions
|
2018-02-27 21:16:45 +00:00
|
|
|
push teller
|
|
|
|
syscall decimalstr_signed
|
|
|
|
syscall printstr
|
|
|
|
push newlinestr
|
|
|
|
syscall printstr
|
|
|
|
back:
|
|
|
|
push teller
|
|
|
|
push one
|
|
|
|
add
|
2018-03-02 01:49:43 +00:00
|
|
|
dup
|
|
|
|
dup
|
|
|
|
pop teller
|
|
|
|
call 1 printnumber
|
|
|
|
push thousand
|
|
|
|
cmp_lt
|
|
|
|
jump_if_true back
|
|
|
|
return 0
|
|
|
|
printnumber:
|
2018-02-27 21:16:45 +00:00
|
|
|
syscall decimalstr_signed
|
|
|
|
syscall printstr
|
|
|
|
push newlinestr
|
|
|
|
syscall printstr
|
2018-03-02 01:49:43 +00:00
|
|
|
return 0
|
2018-02-25 15:43:00 +00:00
|
|
|
%end_instructions
|
|
|
|
|
|
|
|
%subblocks
|
|
|
|
%end_subblocks
|
|
|
|
%end_block ;b1
|