Removing signed mode
This commit is contained in:
parent
82d1c276f9
commit
d848cc1f54
|
@ -43,7 +43,7 @@ BRK
|
||||||
$loop NOP
|
$loop NOP
|
||||||
( send ) DUP2 LDR =Console.char
|
( send ) DUP2 LDR =Console.char
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( loop ) DUP2 LDR #00 NEQ ^$loop MUL JMPS
|
( loop ) DUP2 LDR #00 NEQ ^$loop MUL JMP
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
|
@ -47,7 +47,7 @@ Program p;
|
||||||
char ops[][4] = {
|
char ops[][4] = {
|
||||||
"BRK", "NOP", "LIT", "LDR", "STR", "JMP", "JSR", "RTN",
|
"BRK", "NOP", "LIT", "LDR", "STR", "JMP", "JSR", "RTN",
|
||||||
"EQU", "NEQ", "GTH", "LTH", "AND", "XOR", "ROL", "ROR",
|
"EQU", "NEQ", "GTH", "LTH", "AND", "XOR", "ROL", "ROR",
|
||||||
"POP", "DUP", "SWP", "OVR", "ROT", "---", "WSR", "RSW",
|
"POP", "DUP", "SWP", "OVR", "ROT", "CLN", "WSR", "RSW",
|
||||||
"ADD", "SUB", "MUL", "DIV", "---", "---", "---", "---"
|
"ADD", "SUB", "MUL", "DIV", "---", "---", "---", "---"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
2
build.sh
2
build.sh
|
@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr
|
||||||
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
|
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
|
||||||
|
|
||||||
# run
|
# run
|
||||||
./bin/assembler projects/software/left.usm bin/boot.rom
|
./bin/assembler projects/software/nasu.usm bin/boot.rom
|
||||||
./bin/emulator bin/boot.rom
|
./bin/emulator bin/boot.rom
|
||||||
|
|
|
@ -14,7 +14,7 @@ BRK
|
||||||
$loop NOP
|
$loop NOP
|
||||||
( send ) DUP2 LDR =Console.char
|
( send ) DUP2 LDR =Console.char
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( loop ) DUP2 LDR #00 NEQ ^$loop MUL JMPS
|
( loop ) DUP2 LDR #00 NEQ ^$loop MUL JMP
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
$draw-hor NOP
|
$draw-hor NOP
|
||||||
( draw ) #01 =Screen.color
|
( draw ) #01 =Screen.color
|
||||||
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2
|
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2
|
||||||
OVR2 OVR2 LTH2 ^$draw-hor SWP JMPS?
|
OVR2 OVR2 LTH2 ^$draw-hor SWP JMP?
|
||||||
POP2 POP2
|
POP2 POP2
|
||||||
|
|
||||||
( draw ver line )
|
( draw ver line )
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
$draw-ver NOP
|
$draw-ver NOP
|
||||||
( draw ) #02 =Screen.color
|
( draw ) #02 =Screen.color
|
||||||
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2
|
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2
|
||||||
OVR2 OVR2 LTH2 ^$draw-ver SWP JMPS?
|
OVR2 OVR2 LTH2 ^$draw-ver SWP JMP?
|
||||||
POP2 POP2
|
POP2 POP2
|
||||||
|
|
||||||
( draw blending modes )
|
( draw blending modes )
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
( move ) OVR #00 SWP #0008 MUL2 #0020 ADD2 =Sprite.x
|
( move ) OVR #00 SWP #0008 MUL2 #0020 ADD2 =Sprite.x
|
||||||
( draw ) OVR =Sprite.color
|
( draw ) OVR =Sprite.color
|
||||||
( incr ) SWP #01 ADD SWP
|
( incr ) SWP #01 ADD SWP
|
||||||
DUP2 LTH ^$draw-blends SWP JMPS?
|
DUP2 LTH ^$draw-blends SWP JMP?
|
||||||
POP POP
|
POP POP
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
|
@ -104,7 +104,7 @@ RTN
|
||||||
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( incr ) ~Sprite.x #0007 ADD2 =Sprite.x
|
( incr ) ~Sprite.x #0007 ADD2 =Sprite.x
|
||||||
DUP2 LDR #00 NEQ ^$loop MUL JMPS
|
DUP2 LDR #00 NEQ ^$loop MUL JMP
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
@ -117,9 +117,9 @@ RTN
|
||||||
$hor NOP
|
$hor NOP
|
||||||
( draw ) ~color =Screen.color
|
( draw ) ~color =Screen.color
|
||||||
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
||||||
~Screen.x ~rect.x2 LTH2 ^$hor MUL JMPS
|
~Screen.x ~rect.x2 LTH2 ^$hor MUL JMP
|
||||||
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
||||||
~Screen.y ~rect.y2 LTH2 ^$ver MUL JMPS
|
~Screen.y ~rect.y2 LTH2 ^$ver MUL JMP
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
|
@ -130,13 +130,13 @@ RTN
|
||||||
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
||||||
( draw ) ~rect.y1 =Screen.y ~color =Screen.color
|
( draw ) ~rect.y1 =Screen.y ~color =Screen.color
|
||||||
( draw ) ~rect.y2 =Screen.y ~color =Screen.color
|
( draw ) ~rect.y2 =Screen.y ~color =Screen.color
|
||||||
~Screen.x ~rect.x2 LTH2 ^$hor MUL JMPS
|
~Screen.x ~rect.x2 LTH2 ^$hor MUL JMP
|
||||||
~rect.y1 =Screen.y
|
~rect.y1 =Screen.y
|
||||||
$ver NOP
|
$ver NOP
|
||||||
( draw ) ~rect.x1 =Screen.x ~color =Screen.color
|
( draw ) ~rect.x1 =Screen.x ~color =Screen.color
|
||||||
( draw ) ~rect.x2 =Screen.x ~color =Screen.color
|
( draw ) ~rect.x2 =Screen.x ~color =Screen.color
|
||||||
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
||||||
~Screen.y ~rect.y2 #0001 ADD2 LTH2 ^$ver MUL JMPS
|
~Screen.y ~rect.y2 #0001 ADD2 LTH2 ^$ver MUL JMP
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
|
@ -148,9 +148,9 @@ RTN
|
||||||
$hor NOP
|
$hor NOP
|
||||||
( draw ) ~color =Sprite.color
|
( draw ) ~color =Sprite.color
|
||||||
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
~Sprite.x ~rect.x2 LTH2 ^$hor MUL JMPS
|
~Sprite.x ~rect.x2 LTH2 ^$hor MUL JMP
|
||||||
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
|
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
|
||||||
~Sprite.y ~rect.y2 LTH2 ^$ver MUL JMPS
|
~Sprite.y ~rect.y2 LTH2 ^$ver MUL JMP
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
|
|
|
@ -170,11 +170,11 @@ BRK
|
||||||
|
|
||||||
,$no-up ~Mouse.y #0008 GTH2 JMP2?
|
,$no-up ~Mouse.y #0008 GTH2 JMP2?
|
||||||
( decr ) ~scroll.y #00 ~scroll.y #0000 NEQ2 SUB2 =scroll.y
|
( decr ) ~scroll.y #00 ~scroll.y #0000 NEQ2 SUB2 =scroll.y
|
||||||
^$end JMPS
|
^$end JMP
|
||||||
$no-up
|
$no-up
|
||||||
,$no-down ~Mouse.y ~Screen.height #0008 SUB2 LTH2 JMP2?
|
,$no-down ~Mouse.y ~Screen.height #0008 SUB2 LTH2 JMP2?
|
||||||
( incr ) ~scroll.y #0001 ADD2 =scroll.y
|
( incr ) ~scroll.y #0001 ADD2 =scroll.y
|
||||||
^$end JMPS
|
^$end JMP
|
||||||
$no-down
|
$no-down
|
||||||
~Mouse.y #0008 SUB2 =scroll.y
|
~Mouse.y #0008 SUB2 =scroll.y
|
||||||
$end
|
$end
|
||||||
|
@ -200,12 +200,12 @@ RTN
|
||||||
,$no-chord-cut ~Mouse.chord #01 NEQ JMP2?
|
,$no-chord-cut ~Mouse.chord #01 NEQ JMP2?
|
||||||
,cut JSR2
|
,cut JSR2
|
||||||
( release ) #00 DUP =Mouse.state =Mouse.chord
|
( release ) #00 DUP =Mouse.state =Mouse.chord
|
||||||
^$end JMPS
|
^$end JMP
|
||||||
$no-chord-cut
|
$no-chord-cut
|
||||||
,$no-chord-paste ~Mouse.chord #10 NEQ JMP2?
|
,$no-chord-paste ~Mouse.chord #10 NEQ JMP2?
|
||||||
,paste JSR2
|
,paste JSR2
|
||||||
( release ) #00 DUP =Mouse.state =Mouse.chord
|
( release ) #00 DUP =Mouse.state =Mouse.chord
|
||||||
^$end JMPS
|
^$end JMP
|
||||||
$no-chord-paste
|
$no-chord-paste
|
||||||
|
|
||||||
,$end ~Mouse.state #11 EQU JMP2?
|
,$end ~Mouse.state #11 EQU JMP2?
|
||||||
|
@ -214,7 +214,7 @@ RTN
|
||||||
( on drag )
|
( on drag )
|
||||||
,find-selection JSR2 #0001 ADD2 =selection.to
|
,find-selection JSR2 #0001 ADD2 =selection.to
|
||||||
,clamp-selection JSR2
|
,clamp-selection JSR2
|
||||||
^$end JMPS
|
^$end JMP
|
||||||
$no-drag
|
$no-drag
|
||||||
( on click )
|
( on click )
|
||||||
,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to
|
,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to
|
||||||
|
@ -231,7 +231,7 @@ RTN
|
||||||
,document.body =document.eof
|
,document.body =document.eof
|
||||||
$loop NOP
|
$loop NOP
|
||||||
( incr ) ~document.eof #0001 ADD2 =document.eof
|
( incr ) ~document.eof #0001 ADD2 =document.eof
|
||||||
~document.eof LDR #00 NEQ ^$loop MUL JMPS
|
~document.eof LDR #00 NEQ ^$loop MUL JMP
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ RTN
|
||||||
$loop NOP
|
$loop NOP
|
||||||
( move ) ~j ~i ADD2 LDR ~j STR
|
( move ) ~j ~i ADD2 LDR ~j STR
|
||||||
( incr ) ~j #0001 ADD2 =j
|
( incr ) ~j #0001 ADD2 =j
|
||||||
~j ~document.eof LTH2 ^$loop MUL JMPS
|
~j ~document.eof LTH2 ^$loop MUL JMP
|
||||||
~document.eof ~i SUB2 =document.eof
|
~document.eof ~i SUB2 =document.eof
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
@ -270,7 +270,7 @@ RTN
|
||||||
$loop NOP
|
$loop NOP
|
||||||
( move ) ~j ~i SUB2 LDR ~j STR
|
( move ) ~j ~i SUB2 LDR ~j STR
|
||||||
( decr ) ~j #0001 SUB2 =j
|
( decr ) ~j #0001 SUB2 =j
|
||||||
~j ~selection.from GTH2 ^$loop MUL JMPS
|
~j ~selection.from GTH2 ^$loop MUL JMP
|
||||||
~document.eof ~i ADD2 =document.eof
|
~document.eof ~i ADD2 =document.eof
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
@ -299,7 +299,7 @@ RTN
|
||||||
~selection.from #0001 SUB2 LDR #0a EQU RTN?
|
~selection.from #0001 SUB2 LDR #0a EQU RTN?
|
||||||
~selection.from #0001 SUB2 LDR #0d EQU RTN?
|
~selection.from #0001 SUB2 LDR #0d EQU RTN?
|
||||||
( decr ) ~selection.from DUP2 =selection.to #0001 SUB2 =selection.from
|
( decr ) ~selection.from DUP2 =selection.to #0001 SUB2 =selection.from
|
||||||
~selection.from LDR #00 NEQ ^$loop MUL JMPS
|
~selection.from LDR #00 NEQ ^$loop MUL JMP
|
||||||
( clamp at document body )
|
( clamp at document body )
|
||||||
~selection.from ,document.body GTH2 RTN?
|
~selection.from ,document.body GTH2 RTN?
|
||||||
,document.body DUP2 =selection.from #0001 ADD2 =selection.to
|
,document.body DUP2 =selection.from #0001 ADD2 =selection.to
|
||||||
|
@ -312,7 +312,7 @@ RTN
|
||||||
~selection.from LDR #0a EQU RTN?
|
~selection.from LDR #0a EQU RTN?
|
||||||
~selection.from LDR #0d EQU RTN?
|
~selection.from LDR #0d EQU RTN?
|
||||||
( incr ) ~selection.from #0001 ADD2 DUP2 #0001 ADD2 =selection.to =selection.from
|
( incr ) ~selection.from #0001 ADD2 DUP2 #0001 ADD2 =selection.to =selection.from
|
||||||
~selection.from LDR #00 NEQ ^$loop MUL JMPS
|
~selection.from LDR #00 NEQ ^$loop MUL JMP
|
||||||
( clamp at document body )
|
( clamp at document body )
|
||||||
~selection.from ,document.eof LTH2 RTN?
|
~selection.from ,document.eof LTH2 RTN?
|
||||||
,document.eof #0001 SUB2 DUP2 =selection.from #0001 ADD2 =selection.to
|
,document.eof #0001 SUB2 DUP2 =selection.from #0001 ADD2 =selection.to
|
||||||
|
@ -327,7 +327,7 @@ RTN
|
||||||
,$end ~j LDR #20 EQU JMP2?
|
,$end ~j LDR #20 EQU JMP2?
|
||||||
,$end ~j LDR #0a EQU JMP2?
|
,$end ~j LDR #0a EQU JMP2?
|
||||||
,$end ~j LDR #0d EQU JMP2?
|
,$end ~j LDR #0d EQU JMP2?
|
||||||
~j ,document.body GTH2 ^$loop MUL JMPS
|
~j ,document.body GTH2 ^$loop MUL JMP
|
||||||
$end
|
$end
|
||||||
( return ) ~j #0001 SUB2
|
( return ) ~j #0001 SUB2
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ RTN
|
||||||
,$end ~j LDR #20 EQU JMP2?
|
,$end ~j LDR #20 EQU JMP2?
|
||||||
,$end ~j LDR #0a EQU JMP2?
|
,$end ~j LDR #0a EQU JMP2?
|
||||||
,$end ~j LDR #0d EQU JMP2?
|
,$end ~j LDR #0d EQU JMP2?
|
||||||
~j ,document.body GTH2 ^$loop MUL JMPS
|
~j ,document.body GTH2 ^$loop MUL JMP
|
||||||
$end
|
$end
|
||||||
( return ) ~j #0001 ADD2
|
( return ) ~j #0001 ADD2
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ RTN
|
||||||
( incr ) ~j #0001 ADD2 =j
|
( incr ) ~j #0001 ADD2 =j
|
||||||
,$end ~selection.from ~j SUB2 LDR #0a EQU JMP2?
|
,$end ~selection.from ~j SUB2 LDR #0a EQU JMP2?
|
||||||
,$end ~selection.from ~j SUB2 LDR #0d EQU JMP2?
|
,$end ~selection.from ~j SUB2 LDR #0d EQU JMP2?
|
||||||
~selection.from ~j SUB2 ,document.body GTH2 ^$loop MUL JMPS
|
~selection.from ~j SUB2 ,document.body GTH2 ^$loop MUL JMP
|
||||||
$end
|
$end
|
||||||
( return ) ~j
|
( return ) ~j
|
||||||
|
|
||||||
|
@ -369,7 +369,7 @@ RTN
|
||||||
( incr ) ~pt.y #0001 ADD2 =pt.y
|
( incr ) ~pt.y #0001 ADD2 =pt.y
|
||||||
$no-space
|
$no-space
|
||||||
( incr ) ~j #0001 ADD2 =j
|
( incr ) ~j #0001 ADD2 =j
|
||||||
~j LDR #00 NEQ ^$loop MUL JMPS
|
~j LDR #00 NEQ ^$loop MUL JMP
|
||||||
$end
|
$end
|
||||||
( return ) ~j
|
( return ) ~j
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ RTN
|
||||||
,$end ~j ~pt.x ADD2 LDR #0a EQU JMP2?
|
,$end ~j ~pt.x ADD2 LDR #0a EQU JMP2?
|
||||||
,$end ~j ~pt.x ADD2 LDR #0d EQU JMP2?
|
,$end ~j ~pt.x ADD2 LDR #0d EQU JMP2?
|
||||||
( incr ) ~pt.x #0001 ADD2 =pt.x
|
( incr ) ~pt.x #0001 ADD2 =pt.x
|
||||||
~pt.x ~position.x #0001 SUB2 LTH2 ^$loop MUL JMPS
|
~pt.x ~position.x #0001 SUB2 LTH2 ^$loop MUL JMP
|
||||||
$end
|
$end
|
||||||
( return ) ~pt.x ADD2
|
( return ) ~pt.x ADD2
|
||||||
|
|
||||||
|
@ -405,7 +405,7 @@ RTN
|
||||||
$loop NOP
|
$loop NOP
|
||||||
~selection.from ~i ADD2 LDR ,clip.body ~i ADD2 STR
|
~selection.from ~i ADD2 LDR ,clip.body ~i ADD2 STR
|
||||||
( incr ) ~i #0001 ADD2 =i
|
( incr ) ~i #0001 ADD2 =i
|
||||||
~i ~j LTH2 ^$loop MUL JMPS
|
~i ~j LTH2 ^$loop MUL JMP
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ RTN
|
||||||
$loop NOP
|
$loop NOP
|
||||||
,clip.body ~i ADD2 LDR ~selection.from ~i ADD2 STR
|
,clip.body ~i ADD2 LDR ~selection.from ~i ADD2 STR
|
||||||
( incr ) ~i #0001 ADD2 =i
|
( incr ) ~i #0001 ADD2 =i
|
||||||
~i ~j LTH2 ^$loop MUL JMPS
|
~i ~j LTH2 ^$loop MUL JMP
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ RTN
|
||||||
( incr ) ~j #0001 ADD2 =j
|
( incr ) ~j #0001 ADD2 =j
|
||||||
$no-break
|
$no-break
|
||||||
( incr ) ~textarea.addr #0001 ADD2 =textarea.addr
|
( incr ) ~textarea.addr #0001 ADD2 =textarea.addr
|
||||||
~textarea.addr LDR #00 NEQ ^$find-offset MUL JMPS
|
~textarea.addr LDR #00 NEQ ^$find-offset MUL JMP
|
||||||
$find-offset-end
|
$find-offset-end
|
||||||
|
|
||||||
#0018 =Sprite.x #0000 =Sprite.y
|
#0018 =Sprite.x #0000 =Sprite.y
|
||||||
|
@ -577,7 +577,7 @@ RTN
|
||||||
$loop NOP
|
$loop NOP
|
||||||
( draw ) #08 =Sprite.color
|
( draw ) #08 =Sprite.color
|
||||||
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
|
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
|
||||||
~Sprite.y ~Screen.height LTH2 ^$loop MUL JMPS
|
~Sprite.y ~Screen.height LTH2 ^$loop MUL JMP
|
||||||
|
|
||||||
#0000 =Sprite.y
|
#0000 =Sprite.y
|
||||||
,arrowup_icn =Sprite.addr
|
,arrowup_icn =Sprite.addr
|
||||||
|
@ -603,7 +603,7 @@ RTN
|
||||||
( draw ) DUP2 LDR #00 SWP #20 SUB #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
( draw ) DUP2 LDR #00 SWP #20 SUB #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
DUP2 LDR #00 NEQ ^$loop MUL JMPS
|
DUP2 LDR #00 NEQ ^$loop MUL JMP
|
||||||
POP2
|
POP2
|
||||||
( selection )
|
( selection )
|
||||||
~selection.from ,document.body SUB2 ,draw-short JSR2
|
~selection.from ,document.body SUB2 ,draw-short JSR2
|
||||||
|
|
|
@ -109,7 +109,7 @@ BRK
|
||||||
~MOUS.y ~bankview.y SUB2 #0008 DIV2 #0008 MUL2 #0010 MUL2 ADD2
|
~MOUS.y ~bankview.y SUB2 #0008 DIV2 #0008 MUL2 #0010 MUL2 ADD2
|
||||||
~bankview.addr ADD2 #00 ~i ADD2 STR
|
~bankview.addr ADD2 #00 ~i ADD2 STR
|
||||||
( incr ) ~i #01 ADD =i
|
( incr ) ~i #01 ADD =i
|
||||||
~i #08 LTH ^copy-loop MUL JMPS
|
~i #08 LTH ^copy-loop MUL JMP
|
||||||
,redraw JSR2 ,click-end JMP2
|
,redraw JSR2 ,click-end JMP2
|
||||||
@not-copy-mode
|
@not-copy-mode
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ BRK
|
||||||
~MOUS.y ~bankview.y SUB2 #0008 DIV2 #0008 MUL2 #0010 MUL2 ADD2
|
~MOUS.y ~bankview.y SUB2 #0008 DIV2 #0008 MUL2 #0010 MUL2 ADD2
|
||||||
~bankview.addr ADD2 #00 ~i ADD2 STR
|
~bankview.addr ADD2 #00 ~i ADD2 STR
|
||||||
( incr ) ~i #01 ADD =i
|
( incr ) ~i #01 ADD =i
|
||||||
~i #08 LTH ^erase-loop MUL JMPS
|
~i #08 LTH ^erase-loop MUL JMP
|
||||||
,redraw JSR2 ,click-end JMP2
|
,redraw JSR2 ,click-end JMP2
|
||||||
@not-erase-mode
|
@not-erase-mode
|
||||||
|
|
||||||
|
@ -460,13 +460,13 @@ RTN
|
||||||
( incr ) ~SCRN.x #0001 ADD2 =SCRN.x
|
( incr ) ~SCRN.x #0001 ADD2 =SCRN.x
|
||||||
( draw ) ~rect.y1 =SCRN.y ~color =SCRN.color
|
( draw ) ~rect.y1 =SCRN.y ~color =SCRN.color
|
||||||
( draw ) ~rect.y2 =SCRN.y ~color =SCRN.color
|
( draw ) ~rect.y2 =SCRN.y ~color =SCRN.color
|
||||||
~SCRN.x ~rect.x2 LTH2 ^$hor MUL JMPS
|
~SCRN.x ~rect.x2 LTH2 ^$hor MUL JMP
|
||||||
~rect.y1 =SCRN.y
|
~rect.y1 =SCRN.y
|
||||||
$ver NOP
|
$ver NOP
|
||||||
( draw ) ~rect.x1 =SCRN.x ~color =SCRN.color
|
( draw ) ~rect.x1 =SCRN.x ~color =SCRN.color
|
||||||
( draw ) ~rect.x2 =SCRN.x ~color =SCRN.color
|
( draw ) ~rect.x2 =SCRN.x ~color =SCRN.color
|
||||||
( incr ) ~SCRN.y #0001 ADD2 =SCRN.y
|
( incr ) ~SCRN.y #0001 ADD2 =SCRN.y
|
||||||
~SCRN.y ~rect.y2 #0001 ADD2 LTH2 ^$ver MUL JMPS
|
~SCRN.y ~rect.y2 #0001 ADD2 LTH2 ^$ver MUL JMP
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,29 @@
|
||||||
( tests/cond )
|
( tests/cond )
|
||||||
|
|
||||||
|
%RTN { RSW2 JMP2 }
|
||||||
|
%RTN? { CLN2 JMP2? }
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
#00 #d0
|
#00 #d0
|
||||||
|
|
||||||
$loop NOP
|
$loop NOP
|
||||||
( incr ) SWP #01 ADD SWP
|
( incr ) SWP #01 ADD SWP
|
||||||
DUP2 LTH ^$loop SWP JMPS?
|
DUP2 LTH ^$loop SWP JMP?
|
||||||
POP =Console.byte
|
POP =Console.byte
|
||||||
|
|
||||||
|
,routine JSR2
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@routine
|
@routine
|
||||||
|
|
||||||
|
|
||||||
|
CLN2 JMP2
|
||||||
|
|
||||||
|
#aa
|
||||||
|
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
|c000 @FRAME
|
|c000 @FRAME
|
||||||
|
|
|
@ -12,12 +12,12 @@ BRK
|
||||||
( should print 11, 22, 33, 44 )
|
( should print 11, 22, 33, 44 )
|
||||||
|
|
||||||
#11 =Console.byte
|
#11 =Console.byte
|
||||||
#03 JMPS BRK BRK BRK
|
#03 JMP BRK BRK BRK
|
||||||
|
|
||||||
( skip foward with id )
|
( skip foward with id )
|
||||||
|
|
||||||
#22 =Console.byte
|
#22 =Console.byte
|
||||||
^jump JMPS BRK BRK BRK @jump
|
^jump JMP BRK BRK BRK @jump
|
||||||
|
|
||||||
( skip patterns )
|
( skip patterns )
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ BRK
|
||||||
#ff =Console.byte
|
#ff =Console.byte
|
||||||
@skip1
|
@skip1
|
||||||
|
|
||||||
#12 #34 LTH ^skip2 #04 SUB MUL JMPS
|
#12 #34 LTH ^skip2 #04 SUB MUL JMP
|
||||||
#ff =Console.byte
|
#ff =Console.byte
|
||||||
@skip2
|
@skip2
|
||||||
|
|
||||||
|
@ -41,9 +41,9 @@ RTN
|
||||||
|
|
||||||
( should print aa, bb, cc, dd )
|
( should print aa, bb, cc, dd )
|
||||||
|
|
||||||
@label1 #aa =Console.byte ^label3 JMPS
|
@label1 #aa =Console.byte ^label3 JMP
|
||||||
@label2 #cc =Console.byte ^label4 JMPS
|
@label2 #cc =Console.byte ^label4 JMP
|
||||||
@label3 #bb =Console.byte ^label2 JMPS
|
@label3 #bb =Console.byte ^label2 JMP
|
||||||
@label4 #dd =Console.byte BRK
|
@label4 #dd =Console.byte BRK
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -16,7 +16,7 @@ BRK
|
||||||
|
|
||||||
$loop NOP
|
$loop NOP
|
||||||
~a #01 ADD =a
|
~a #01 ADD =a
|
||||||
~a #d0 LTH ^$loop MUL JMPS
|
~a #d0 LTH ^$loop MUL JMP
|
||||||
~a =Console.byte
|
~a =Console.byte
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
@ -34,7 +34,7 @@ RTN
|
||||||
|
|
||||||
$loop NOP
|
$loop NOP
|
||||||
~c #01 ADD =c
|
~c #01 ADD =c
|
||||||
~c #d0 LTH ^$loop SWP JMPS?
|
~c #d0 LTH ^$loop SWP JMP?
|
||||||
~c =Console.byte
|
~c =Console.byte
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
@ -44,7 +44,7 @@ RTN
|
||||||
#00 #d0
|
#00 #d0
|
||||||
$loop NOP
|
$loop NOP
|
||||||
( incr ) SWP #01 ADD SWP
|
( incr ) SWP #01 ADD SWP
|
||||||
DUP2 LTH ^$loop SWP JMPS?
|
DUP2 LTH ^$loop SWP JMP?
|
||||||
POP =Console.byte
|
POP =Console.byte
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
@ -54,7 +54,7 @@ RTN
|
||||||
#0000 #0d00
|
#0000 #0d00
|
||||||
$loop NOP
|
$loop NOP
|
||||||
( incr ) SWP2 #0001 ADD2 SWP2
|
( incr ) SWP2 #0001 ADD2 SWP2
|
||||||
OVR2 OVR2 LTH2 ^$loop SWP JMPS?
|
OVR2 OVR2 LTH2 ^$loop SWP JMP?
|
||||||
POP2 =Console.short
|
POP2 =Console.short
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
13
uxn.c
13
uxn.c
|
@ -33,9 +33,8 @@ Uint16 peek16(Stack *s, Uint8 a) { return peek8(s, a * 2) + (peek8(s, a * 2 + 1)
|
||||||
void op_brk(Uxn *u) { setflag(&u->status, FLAG_HALT, 1); }
|
void op_brk(Uxn *u) { setflag(&u->status, FLAG_HALT, 1); }
|
||||||
void op_lit(Uxn *u) { u->literal += 1; }
|
void op_lit(Uxn *u) { u->literal += 1; }
|
||||||
void op_nop(Uxn *u) { (void)u; }
|
void op_nop(Uxn *u) { (void)u; }
|
||||||
void op_jmp(Uxn *u) { Uint8 a = pop8(&u->wst); u->ram.ptr += getflag(&u->status, FLAG_SIGN) ? (Sint8)a : a; }
|
void op_jmp(Uxn *u) { Uint8 a = pop8(&u->wst); u->ram.ptr += (Sint8)a; }
|
||||||
|
void op_jsr(Uxn *u) { Uint8 a = pop8(&u->wst); push16(&u->rst, u->ram.ptr); u->ram.ptr += (Sint8)a; }
|
||||||
void op_jsr(Uxn *u) { Uint8 a = pop8(&u->wst); push16(&u->rst, u->ram.ptr); u->ram.ptr += getflag(&u->status, FLAG_SIGN) ? (Sint8)a : a; }
|
|
||||||
void op_rtn(Uxn *u) { u->ram.ptr = pop16(&u->rst); }
|
void op_rtn(Uxn *u) { u->ram.ptr = pop16(&u->rst); }
|
||||||
void op_ldr(Uxn *u) { Uint16 a = pop16(&u->wst); push8(&u->wst, mempeek8(u, a)); }
|
void op_ldr(Uxn *u) { Uint16 a = pop16(&u->wst); push8(&u->wst, mempeek8(u, a)); }
|
||||||
void op_str(Uxn *u) { Uint16 a = pop16(&u->wst); Uint8 b = pop8(&u->wst); mempoke8(u, a, b); }
|
void op_str(Uxn *u) { Uint16 a = pop16(&u->wst); Uint8 b = pop8(&u->wst); mempoke8(u, a, b); }
|
||||||
|
@ -50,6 +49,7 @@ void op_dup(Uxn *u) { push8(&u->wst, peek8(&u->wst, 0)); }
|
||||||
void op_swp(Uxn *u) { Uint8 b = pop8(&u->wst), a = pop8(&u->wst); push8(&u->wst, b); push8(&u->wst, a); }
|
void op_swp(Uxn *u) { Uint8 b = pop8(&u->wst), a = pop8(&u->wst); push8(&u->wst, b); push8(&u->wst, a); }
|
||||||
void op_ovr(Uxn *u) { push8(&u->wst, peek8(&u->wst, 1)); }
|
void op_ovr(Uxn *u) { push8(&u->wst, peek8(&u->wst, 1)); }
|
||||||
void op_rot(Uxn *u) { Uint8 c = pop8(&u->wst), b = pop8(&u->wst), a = pop8(&u->wst); push8(&u->wst, b); push8(&u->wst, c); push8(&u->wst, a); }
|
void op_rot(Uxn *u) { Uint8 c = pop8(&u->wst), b = pop8(&u->wst), a = pop8(&u->wst); push8(&u->wst, b); push8(&u->wst, c); push8(&u->wst, a); }
|
||||||
|
void op_cln(Uxn *u) { push8(&u->wst, peek8(&u->rst, 0)); }
|
||||||
void op_wsr(Uxn *u) { Uint8 a = pop8(&u->wst); push8(&u->rst, a); }
|
void op_wsr(Uxn *u) { Uint8 a = pop8(&u->wst); push8(&u->rst, a); }
|
||||||
void op_rsw(Uxn *u) { Uint8 a = pop8(&u->rst); push8(&u->wst, a); }
|
void op_rsw(Uxn *u) { Uint8 a = pop8(&u->rst); push8(&u->wst, a); }
|
||||||
/* Arithmetic */
|
/* Arithmetic */
|
||||||
|
@ -78,6 +78,7 @@ void op_dup16(Uxn *u) { push16(&u->wst, peek16(&u->wst, 0)); }
|
||||||
void op_swp16(Uxn *u) { Uint16 b = pop16(&u->wst), a = pop16(&u->wst); push16(&u->wst, b); push16(&u->wst, a); }
|
void op_swp16(Uxn *u) { Uint16 b = pop16(&u->wst), a = pop16(&u->wst); push16(&u->wst, b); push16(&u->wst, a); }
|
||||||
void op_ovr16(Uxn *u) { push16(&u->wst, peek16(&u->wst, 1)); }
|
void op_ovr16(Uxn *u) { push16(&u->wst, peek16(&u->wst, 1)); }
|
||||||
void op_rot16(Uxn *u) { Uint16 c = pop16(&u->wst), b = pop16(&u->wst), a = pop16(&u->wst); push16(&u->wst, b); push16(&u->wst, c); push16(&u->wst, a); }
|
void op_rot16(Uxn *u) { Uint16 c = pop16(&u->wst), b = pop16(&u->wst), a = pop16(&u->wst); push16(&u->wst, b); push16(&u->wst, c); push16(&u->wst, a); }
|
||||||
|
void op_cln16(Uxn *u) { push16(&u->wst, peek16(&u->rst, 0)); }
|
||||||
void op_wsr16(Uxn *u) { Uint16 a = pop16(&u->wst); push16(&u->rst, a); }
|
void op_wsr16(Uxn *u) { Uint16 a = pop16(&u->wst); push16(&u->rst, a); }
|
||||||
void op_rsw16(Uxn *u) { Uint16 a = pop16(&u->rst); push16(&u->wst, a); }
|
void op_rsw16(Uxn *u) { Uint16 a = pop16(&u->rst); push16(&u->wst, a); }
|
||||||
/* Arithmetic(16-bits) */
|
/* Arithmetic(16-bits) */
|
||||||
|
@ -93,12 +94,12 @@ void op_lth16(Uxn *u) { Uint16 a = pop16(&u->wst), b = pop16(&u->wst); push8(&u-
|
||||||
void (*ops[])(Uxn *u) = {
|
void (*ops[])(Uxn *u) = {
|
||||||
op_brk, op_nop, op_lit, op_ldr, op_str, op_jmp, op_jsr, op_rtn,
|
op_brk, op_nop, op_lit, op_ldr, op_str, op_jmp, op_jsr, op_rtn,
|
||||||
op_equ, op_neq, op_gth, op_lth, op_and, op_xor, op_rol, op_ror,
|
op_equ, op_neq, op_gth, op_lth, op_and, op_xor, op_rol, op_ror,
|
||||||
op_pop, op_dup, op_swp, op_ovr, op_rot, op_nop, op_wsr, op_rsw,
|
op_pop, op_dup, op_swp, op_ovr, op_rot, op_cln, op_wsr, op_rsw,
|
||||||
op_add, op_sub, op_mul, op_div, op_nop, op_nop, op_nop, op_nop,
|
op_add, op_sub, op_mul, op_div, op_nop, op_nop, op_nop, op_nop,
|
||||||
/* 16-bit */
|
/* 16-bit */
|
||||||
op_brk, op_nop16, op_lit16, op_ldr16, op_str16, op_jmp16, op_jsr16, op_rtn,
|
op_brk, op_nop16, op_lit16, op_ldr16, op_str16, op_jmp16, op_jsr16, op_rtn,
|
||||||
op_equ16, op_neq16, op_gth16, op_lth16, op_and16, op_xor16, op_rol16, op_ror16,
|
op_equ16, op_neq16, op_gth16, op_lth16, op_and16, op_xor16, op_rol16, op_ror16,
|
||||||
op_pop16, op_dup16, op_swp16, op_ovr16, op_rot16, op_nop, op_wsr16, op_rsw16,
|
op_pop16, op_dup16, op_swp16, op_ovr16, op_rot16, op_cln16, op_wsr16, op_rsw16,
|
||||||
op_add16, op_sub16, op_mul16, op_div16, op_nop, op_nop, op_nop, op_nop
|
op_add16, op_sub16, op_mul16, op_div16, op_nop, op_nop, op_nop, op_nop
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -155,7 +156,7 @@ opcuxn(Uxn *u, Uint8 instr)
|
||||||
return haltuxn(u, "Return-stack overflow", instr);
|
return haltuxn(u, "Return-stack overflow", instr);
|
||||||
if(!fcond || (fcond && pop8(&u->wst)))
|
if(!fcond || (fcond && pop8(&u->wst)))
|
||||||
(*ops[op])(u);
|
(*ops[op])(u);
|
||||||
else if(opr[op][0] >= opr[op][1])
|
else
|
||||||
u->wst.ptr -= opr[op][0] - opr[op][1];
|
u->wst.ptr -= opr[op][0] - opr[op][1];
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue