Renamed ROL for SHL

This commit is contained in:
neauoire 2021-03-16 09:33:44 -07:00
parent 06be09eee4
commit 71c0b357ce
7 changed files with 30 additions and 30 deletions

View File

@ -46,7 +46,7 @@ Program p;
char ops[][4] = {
"BRK", "NOP", "LIT", "LDR", "STR", "---", "JMP", "JSR",
"EQU", "NEQ", "GTH", "LTH", "AND", "XOR", "ROL", "ROR",
"EQU", "NEQ", "GTH", "LTH", "AND", "XOR", "SHL", "SHR",
"POP", "DUP", "SWP", "OVR", "ROT", "---", "CLN", "WSR",
"ADD", "SUB", "MUL", "DIV", "---", "---", "---", "---"
};

View File

@ -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
# run
./bin/assembler projects/software/left.usm bin/boot.rom
./bin/assembler projects/software/nasu.usm bin/boot.rom
./bin/emulator bin/boot.rom

View File

@ -35,13 +35,13 @@ BRK
( detect movement )
~Controller.buttons #f0 AND
DUP #04 ROR #01 AND #01 NEQ ,$no-up JMC2
DUP #04 SHR #01 AND #01 NEQ ,$no-up JMC2
( move ) ~Sprite.y DECR2 =Sprite.y ,up_icn =Sprite.addr $no-up
DUP #05 ROR #01 AND #01 NEQ ,$no-down JMC2
DUP #05 SHR #01 AND #01 NEQ ,$no-down JMC2
( move ) ~Sprite.y INCR2 =Sprite.y ,down_icn =Sprite.addr $no-down
DUP #06 ROR #01 AND #01 NEQ ,$no-left JMC2
DUP #06 SHR #01 AND #01 NEQ ,$no-left JMC2
( move ) ~Sprite.x DECR2 =Sprite.x ,left_icn =Sprite.addr $no-left
DUP #07 ROR #01 AND #01 NEQ ,$no-right JMC2
DUP #07 SHR #01 AND #01 NEQ ,$no-right JMC2
( move ) ~Sprite.x INCR2 =Sprite.x ,right_icn =Sprite.addr $no-right
POP

View File

@ -46,7 +46,7 @@ BRK
,no-click ~Mouse.state #00 EQU JMP2?
( load ) ~editor.addr ~Mouse.y ~editor.y1 SUB2 #0008 DIV2 ADD2 LDR
( mask ) #01 #07 ~Mouse.x ~editor.x1 SUB2 #0008 DIV2 SWP POP SUB ROL
( mask ) #01 #07 ~Mouse.x ~editor.x1 SUB2 #0008 DIV2 SWP POP SUB SHL
XOR
( save ) ~editor.addr ~Mouse.y ~editor.y1 SUB2 #0008 DIV2 ADD2 STR
@ -81,7 +81,7 @@ RTN
$hor
( get bit )
,cell0_icn #00
~editor.addr #00 ~pixel.y ADD2 LDR #07 ~pixel.x SUB ROR #01 AND ( get bit )
~editor.addr #00 ~pixel.y ADD2 LDR #07 ~pixel.x SUB SHR #01 AND ( get bit )
#0008 MUL2 ADD2 =Sprite.addr ( add *8 )
( draw ) #08 =Sprite.color
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x

View File

@ -74,37 +74,37 @@ BRK
@no-ctrl-right
( alt )
,no-alt ~Controller #0f AND #02 NEQ JMP2?
,no-aup ~Controller #04 ROR #01 NEQ JMP2?
,no-aup ~Controller #04 SHR #01 NEQ JMP2?
,find-wordstart JSR2 =selection.to
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-aup
,no-adown ~Controller #04 ROR #02 NEQ JMP2?
,no-adown ~Controller #04 SHR #02 NEQ JMP2?
,find-wordend JSR2 =selection.to
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-adown
,no-aleft ~Controller #04 ROR #04 NEQ JMP2?
,no-aleft ~Controller #04 SHR #04 NEQ JMP2?
~selection.to #0001 SUB2 =selection.to
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-aleft
,no-aright ~Controller #04 ROR #08 NEQ JMP2?
,no-aright ~Controller #04 SHR #08 NEQ JMP2?
~selection.to #0001 ADD2 =selection.to
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-aright
@no-alt
( ctrl )
,no-ctrl ~Controller #0f AND #01 NEQ JMP2?
,no-cup ~Controller #04 ROR #01 NEQ JMP2?
,no-cup ~Controller #04 SHR #01 NEQ JMP2?
#0004 ,scroll-up JSR2
,redraw JSR2 ,ctrl-end JMP2
@no-cup
,no-cdown ~Controller #04 ROR #02 NEQ JMP2?
,no-cdown ~Controller #04 SHR #02 NEQ JMP2?
#0004 ,scroll-down JSR2
,redraw JSR2 ,ctrl-end JMP2
@no-cdown
,no-cleft ~Controller #04 ROR #04 NEQ JMP2?
,no-cleft ~Controller #04 SHR #04 NEQ JMP2?
,goto-linestart JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-cleft
,no-cright ~Controller #04 ROR #08 NEQ JMP2?
,no-cright ~Controller #04 SHR #08 NEQ JMP2?
,goto-lineend JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-cright
@no-ctrl
@ -464,13 +464,13 @@ RTN
@draw-short ( short )
=addr
,font_hex #00 ,addr LDR #f0 AND #04 ROR #08 MUL ADD2 =Sprite.addr
,font_hex #00 ,addr LDR #f0 AND #04 SHR #08 MUL ADD2 =Sprite.addr
( draw ) #0e =Sprite.color
~Sprite.x #0008 ADD2 =Sprite.x
,font_hex #00 ,addr LDR #0f AND #08 MUL ADD2 =Sprite.addr
( draw ) #0e =Sprite.color
~Sprite.x #0008 ADD2 =Sprite.x
,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =Sprite.addr
,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 SHR #08 MUL ADD2 =Sprite.addr
( draw ) #0e =Sprite.color
~Sprite.x #0008 ADD2 =Sprite.x
,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =Sprite.addr
@ -552,7 +552,7 @@ RTN
#0000 =Sprite.x
~scroll.y ~Sprite.y #0008 DIV2 ADD2 DUP2 SWP POP =k
~position.y EQU2 #0c MUL =l
,font_hex #00 ~k #f0 AND #04 ROR #08 MUL ADD2 =Sprite.addr
,font_hex #00 ~k #f0 AND #04 SHR #08 MUL ADD2 =Sprite.addr
#02 ~l ADD =Sprite.color
#0008 =Sprite.x
,font_hex #00 ~k #0f AND #08 MUL ADD2 =Sprite.addr

View File

@ -157,7 +157,7 @@ BRK
,redraw JSR2 ,click-end JMP2
@no-erase-mode
( load ) ~addr ~pos.y #0008 DIV2 ADD2 LDR
( mask ) #01 #07 ~pos.x #0008 DIV2 SWP POP SUB ROL
( mask ) #01 #07 ~pos.x #0008 DIV2 SWP POP SUB SHL
XOR
( save ) ~addr ~pos.y #0008 DIV2 ADD2 STR
,redraw JSR2 ,click-end JMP2
@ -354,7 +354,7 @@ RTN
#00 =i
$bytes
~tileview.x #0088 ADD2 =SPRT.x
,font_hex #00 ~tileview.addr #00 ~i ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr
,font_hex #00 ~tileview.addr #00 ~i ADD2 LDR #f0 AND #04 SHR #08 MUL ADD2 =SPRT.addr
( draw ) #02 =SPRT.color
~SPRT.x #0008 ADD2 =SPRT.x
,font_hex #00 ~tileview.addr #00 ~i ADD2 LDR #0f AND #08 MUL ADD2 =SPRT.addr
@ -399,7 +399,7 @@ RTN
$hor
( get bit )
,blank_icn #00
~tileview.addr #00 ~pt.y ADD2 LDR #07 ~pt.x SUB ROR #01 AND ( get bit )
~tileview.addr #00 ~pt.y ADD2 LDR #07 ~pt.x SUB SHR #01 AND ( get bit )
#0008 MUL2 ADD2 =SPRT.addr ( add *8 )
( draw ) #01 =SPRT.color
( incr ) ~SPRT.x #0008 ADD2 =SPRT.x
@ -440,13 +440,13 @@ RTN
@draw-short ( short )
=addr
,font_hex #00 ,addr LDR #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr
,font_hex #00 ,addr LDR #f0 AND #04 SHR #08 MUL ADD2 =SPRT.addr
( draw ) #02 =SPRT.color
~SPRT.x #0008 ADD2 =SPRT.x
,font_hex #00 ,addr LDR #0f AND #08 MUL ADD2 =SPRT.addr
( draw ) #02 =SPRT.color
~SPRT.x #0008 ADD2 =SPRT.x
,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr
,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 SHR #08 MUL ADD2 =SPRT.addr
( draw ) #02 =SPRT.color
~SPRT.x #0008 ADD2 =SPRT.x
,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =SPRT.addr

12
uxn.c
View File

@ -40,8 +40,8 @@ void op_str(Uxn *u) { Uint16 a = pop16(u->src); Uint8 b = pop8(u->src); mempoke8
/* Logic */
void op_and(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b & a); }
void op_xor(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b | a); }
void op_rol(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b << (a % 8)); }
void op_ror(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b >> (a % 8)); }
void op_shl(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b << (a % 8)); }
void op_shr(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b >> (a % 8)); }
/* Stack */
void op_pop(Uxn *u) { pop8(u->src); }
void op_dup(Uxn *u) { push8(u->src, peek8(u->src, 0)); }
@ -68,8 +68,8 @@ void op_ldr16(Uxn *u) { Uint16 a = pop16(u->src); push16(u->src, mempeek16(u, a)
void op_str16(Uxn *u) { Uint16 a = pop16(u->src); Uint16 b = pop16(u->src); mempoke16(u, a, b); }
void op_and16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b & a); }
void op_xor16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b ^ a); }
void op_rol16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b << (a % 16)); }
void op_ror16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b >> (a % 16)); }
void op_shl16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b << (a % 16)); }
void op_shr16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b >> (a % 16)); }
/* Stack(16-bits) */
void op_pop16(Uxn *u) { pop16(u->src); }
void op_dup16(Uxn *u) { push16(u->src, peek16(u->src, 0)); }
@ -90,12 +90,12 @@ void op_lth16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->sr
void (*ops[])(Uxn *u) = {
op_brk, op_nop, op_lit, op_ldr, op_str, op_nop, op_jmp, op_jsr,
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_shl, op_shr,
op_pop, op_dup, op_swp, op_ovr, op_rot, op_nop, op_cln, op_sth,
op_add, op_sub, op_mul, op_div, op_nop, op_nop, op_nop, op_nop,
/* 16-bit */
op_brk, op_nop16, op_lit16, op_ldr16, op_str16, op_nop, op_jmp16, op_jsr16,
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_shl16, op_shr16,
op_pop16, op_dup16, op_swp16, op_ovr16, op_rot16, op_nop, op_cln16, op_sth16,
op_add16, op_sub16, op_mul16, op_div16, op_nop, op_nop, op_nop, op_nop
};