2018-02-25 15:43:00 +00:00
|
|
|
; source code for a tinyvm program
|
|
|
|
%block b1
|
|
|
|
%vardefs
|
2018-03-04 14:11:45 +00:00
|
|
|
var word teller 0
|
|
|
|
var word numbertoprint 0
|
2018-02-27 21:16:45 +00:00
|
|
|
const byte one 1
|
2018-03-04 14:11:45 +00:00
|
|
|
const word thousand 1000
|
2018-03-03 11:13:25 +00:00
|
|
|
const byte space_chr 10
|
|
|
|
const word screenstart 1024
|
2018-02-25 15:43:00 +00:00
|
|
|
%end_vardefs
|
|
|
|
|
|
|
|
%instructions
|
2018-02-27 21:16:45 +00:00
|
|
|
back:
|
|
|
|
push teller
|
|
|
|
push one
|
|
|
|
add
|
2018-03-02 01:49:43 +00:00
|
|
|
dup
|
|
|
|
dup
|
2018-03-03 11:13:25 +00:00
|
|
|
dup
|
|
|
|
push screenstart
|
|
|
|
swap
|
|
|
|
syscall memwrite_word
|
2018-03-02 01:49:43 +00:00
|
|
|
pop teller
|
|
|
|
call 1 printnumber
|
|
|
|
push thousand
|
|
|
|
cmp_lt
|
|
|
|
jump_if_true back
|
|
|
|
return 0
|
|
|
|
printnumber:
|
2018-03-04 14:11:45 +00:00
|
|
|
syscall decimalstr_unsigned
|
2018-02-27 21:16:45 +00:00
|
|
|
syscall printstr
|
2018-03-02 23:07:44 +00:00
|
|
|
push space_chr
|
|
|
|
syscall printchr
|
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
|