Print memory size left

This commit is contained in:
Devine Lu Linvega 2023-07-13 10:49:49 -07:00
parent 78eb70d88f
commit c53ca56775
2 changed files with 32 additions and 32 deletions

View File

@ -13,7 +13,7 @@
@on-reset ( -> ) @on-reset ( -> )
.Console/type DEI ?&>has-arg .Console/type DEI ?&>has-arg
;Dict/usage <perr> ;dict/usage &err <print-str>
#010f DEO #010f DEO
BRK &>has-arg BRK &>has-arg
;on-waitsrc .Console/vector DEO2 ;on-waitsrc .Console/vector DEO2
@ -24,7 +24,8 @@
BRK BRK
@on-ready ( -> ) @on-ready ( -> )
;src load-rom reset run #800f DEO <reset>
;src load-rom run #800f DEO
BRK BRK
( (
@ -32,21 +33,17 @@
@load-rom ( filename* -- ) @load-rom ( filename* -- )
.File/name DEO2 .File/name DEO2
#fff0 ;rom/reset SUB2 .File/length DEO2 #fff0 ;rom/reset SUB2 DUP2 .File/length DEO2
;rom/reset .File/read DEO2 ;rom/reset .File/read DEO2
.File/success DEI2 #fff0 ;rom/reset SUB2 EQU2 ?&err-overflow .File/success DEI2 SUB2 <print-dec>
.File/success DEI2 #0000 EQU2 ?&err-empty ;dict/bytes-free !<print-str>
JMP2r
&err-empty ( -- )
( TODO ) JMP2r
&err-overflow ( -- )
( TODO ) JMP2r
@run ( -- ) @run ( -- )
[ LIT2 00 -emu/sleep ] STZ [ LIT2 00 -emu/sleep ] STZ
#0000 #0000
&w ( -- ) &w ( -- )
step .uxn/err LDZ ?&err <step> POP
.uxn/err LDZ ?&err
.emu/sleep LDZ ?&end .emu/sleep LDZ ?&end
INC2 ORAk ?&w INC2 ORAk ?&w
&end POP2 &end POP2
@ -56,6 +53,10 @@
#00 ;rst/ptr STA #00 ;rst/ptr STA
JMP2r JMP2r
@halt ( opcode -- opcode )
#01 .emu/sleep STZ
JMP2r
@send ( v* p* -- ) @send ( v* p* -- )
NIP NIP
( | handlers ) ( | handlers )
@ -77,10 +78,6 @@
#0a18 DEO #0a18 DEO
JMP2r JMP2r
@halt ( opcode -- )
#01 .emu/sleep STZ
JMP2r
( (
@|stdlib ) @|stdlib )
@ -91,14 +88,13 @@
POP2 #01 JMP2r POP2 #01 JMP2r
@scap ( str* -- end* ) @scap ( str* -- end* )
!&a !&
&w ( -- ) &w ( -- )
INC2 &a LDAk ?&w INC2 & LDAk ?&w
JMP2r JMP2r
@sput ( chr str* -- ) @sput ( chr str* -- )
scap INC2k #00 ROT ROT STA scap/ ROT #00 SWP2 STA2
STA
JMP2r JMP2r
@<phex> ( short* -- ) @<phex> ( short* -- )
@ -109,22 +105,26 @@
#0f AND DUP #09 GTH #27 MUL ADD LIT "0 ADD #18 DEO #0f AND DUP #09 GTH #27 MUL ADD LIT "0 ADD #18 DEO
JMP2r JMP2r
@<perr> ( err* -- )
!&a
&w ( -- )
LDAk #19 DEO
INC2 &a LDAk ?&w
POP2 JMP2r
@<print-str> ( str* -- ) @<print-str> ( str* -- )
&w ( -- ) &w ( -- )
LDAk #18 DEO LDAk #19 DEO
INC2 LDAk ?&w INC2 LDAk ?&w
POP2 JMP2r POP2 JMP2r
@<print-dec> ( short* -- )
#2710 [ LIT2r 00fb ]
&w ( -- )
DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?&>skip
DUP LIT "0 ADD #19 DEO
INCr &>skip
POP2 #000a DIV2 SWPr INCr STHkr ?&w
POP2r POP2 POP2 JMP2r
( (
@|res ) @|res )
@Dict &usage "usage: 20 "uxnvm.rom 20 "game.rom 0a $1 @dict &usage "usage: 20 "uxnvm.rom 20 "game.rom 0a $1
&bytes-free 20 "bytes 20 "free. 0a $1
~vm.tal ~vm.tal

View File

@ -1,14 +1,14 @@
( emulator ) ( emulator )
@reset ( -- ) @<reset> ( -- )
#00 .uxn/err STZ #00 .uxn/err STZ
#0100 .uxn/pc STZ2 #0100 .uxn/pc STZ2
#0000 ;wst/ptr STA2 #0000 ;wst/ptr STA2
#0000 ;rst/ptr STA2 #0000 ;rst/ptr STA2
#0000 ;step/cycles STA2 #0000 ;<step>/cycles STA2
JMP2r JMP2r
@step ( -- ) @<step> ( -- ok )
( get opcode ) .uxn/pc LDZ2 ;rom ADD2 LDA ( get opcode ) .uxn/pc LDZ2 ;rom ADD2 LDA
( exit on BRK ) DUP #00 EQU ?halt ( exit on BRK ) DUP #00 EQU ?halt
( move PC ) .uxn/pc LDZ2k INC2 ROT STZ2 ( move PC ) .uxn/pc LDZ2k INC2 ROT STZ2
@ -20,7 +20,7 @@
( get routine ) #00 OVR #1f AND DUP2 ADD2 ;optbl ADD2 LDA2 JSR2 ( get routine ) #00 OVR #1f AND DUP2 ADD2 ;optbl ADD2 LDA2 JSR2
( incr time ) [ LIT2 &cycles $2 ] INC2 ,&cycles STR2 ( incr time ) [ LIT2 &cycles $2 ] INC2 ,&cycles STR2
( check err ) .uxn/err LDZ ?halt ( check err ) .uxn/err LDZ ?halt
POP JMP2r JMP2r
( (
@|primitives ) @|primitives )