Print cycles count

This commit is contained in:
Devine Lu Linvega 2023-07-13 11:09:55 -07:00
parent 11249a9e52
commit 40adea4936
2 changed files with 16 additions and 19 deletions

View File

@ -7,7 +7,6 @@
@src $40 @src $40
@uxn &pc $2 &src $2 &dst $2 &err $1 &2 $1 @uxn &pc $2 &src $2 &dst $2 &err $1 &2 $1
@emu &sleep $1
|0100 |0100
@ -39,29 +38,26 @@
;dict/bytes-free !<print-str> ;dict/bytes-free !<print-str>
@run ( -- ) @run ( -- )
[ LIT2 00 -emu/sleep ] STZ
#0000
&w ( -- )
<step> <step>
.uxn/err LDZ ?&err .uxn/err LDZ ?&err
#00 EQU ?&end ?run
INC2 ORAk ?&w
&end ( -- ) &end ( -- )
POP2 JMP2r ;<step>/count LDA2 <print-dec>
;dict/cycles <print-str>
JMP2r
&err ( opcode -- ) &err ( opcode -- )
POP !<reset> POP !<reset>
@halt ( opcode -- opcode ) @halt ( opcode -- opcode )
#01 .emu/sleep STZ
JMP2r JMP2r
@send ( v* p* -- ) @send ( v* p* -- )
NIP NIP
( | handlers ) ( | handlers )
DUP #0e NEQ ?&>no-debug DUP #0e NEQ ?&>no-debug
&>no-debug ( TODO ) &>no-debug
DUP #0f NEQ ?&>no-halt DUP #0f NEQ ?&>no-halt
&>no-halt ( TODO ) &>no-halt
DUP #18 NEQ ?&>no-out DUP #18 NEQ ?&>no-out
POP NIP #18 DEO POP NIP #18 DEO
JMP2r &>no-out JMP2r &>no-out
@ -70,7 +66,7 @@
JMP2r &>no-err JMP2r &>no-err
( | error ) ( | error )
;dict/err-device <print-str> ;dict/err-device <print-str>
<phex>/b <print-hex>/b
#0a18 DEO #0a18 DEO
POP2 JMP2r POP2 JMP2r
@ -93,10 +89,10 @@
scap/ ROT #00 SWP2 STA2 scap/ ROT #00 SWP2 STA2
JMP2r JMP2r
@<phex> ( short* -- ) @<print-hex> ( short* -- )
SWP <phex>/b SWP <print-hex>/b
&b ( -- ) &b ( -- )
DUP #04 SFT <phex>/c DUP #04 SFT <print-hex>/c
&c ( -- ) &c ( -- )
#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
@ -122,6 +118,7 @@
@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 &bytes-free 20 "bytes 20 "free. 0a $1
&err-device "Unsupported 20 "device: 20 $1 &err-device "Unsupported 20 "device: 20 $1
&cycles 20 "cycles. 0a $1
~vm.tal ~vm.tal

View File

@ -1,11 +1,11 @@
( emulator ) ( emulator )
@<reset> ( -- ) @<reset> ( -- )
#00 .uxn/err STZ [ LIT2 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>/count STA2
JMP2r JMP2r
@<step> ( -- ok ) @<step> ( -- ok )
@ -18,7 +18,7 @@
( keep mode ) DUP #80 AND #00 NEQ ;pop/keep STA ( keep mode ) DUP #80 AND #00 NEQ ;pop/keep STA
( copy pop pointer ) .uxn/src LDZ2 #00fe ADD2 LDAk DUP SWP2 STA2 ( copy pop pointer ) .uxn/src LDZ2 #00fe ADD2 LDAk DUP SWP2 STA2
( 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 &count $2 ] INC2 ,&count STR2
( check err ) .uxn/err LDZ ?halt ( check err ) .uxn/err LDZ ?halt
JMP2r JMP2r