diff --git a/assembler.c b/assembler.c index c5656d8..ef9edff 100644 --- a/assembler.c +++ b/assembler.c @@ -46,9 +46,9 @@ Program p; char ops[][4] = { "BRK", "NOP", "LIT", "LDR", "STR", "---", "JMP", "JSR", - "EQU", "NEQ", "GTH", "LTH", "AND", "ORA", "SHL", "SFT", + "EQU", "NEQ", "GTH", "LTH", "AND", "ORA", "EOR", "SFT", "POP", "DUP", "SWP", "OVR", "ROT", "---", "CLN", "STH", - "ADD", "SUB", "MUL", "DIV", "---", "---", "---", "XOR" + "ADD", "SUB", "MUL", "DIV", "---", "---", "---", "---" }; int scin(char *s, char c) { int i = 0; while(s[i]) if(s[i++] == c) return i - 1; return -1; } /* string char index */ diff --git a/projects/software/left.usm b/projects/software/left.usm index 8e64694..14c5d22 100644 --- a/projects/software/left.usm +++ b/projects/software/left.usm @@ -19,7 +19,7 @@ %RTN? { JMP2r? } %++ { #0001 ADD2 } %-- { #0001 SUB2 } -%8/ { #0003 SFT2 } %8* { #0003 SHL2 } +%8/ { #0003 SFT2 } %8* { #0030 SFT2 } %8- { #0008 SUB2 } %8+ { #0008 ADD2 } ;lock { byte 1 } diff --git a/projects/software/nasu.usm b/projects/software/nasu.usm index ac479e4..922359d 100644 --- a/projects/software/nasu.usm +++ b/projects/software/nasu.usm @@ -8,11 +8,11 @@ %RTN { JMP2r } %RTN? { JMP2r? } -%STEP8 { #0003 SFT2 #0003 SHL2 } +%STEP8 { #0003 SFT2 #0030 SFT2 } %++ { #0001 ADD2 } -%2/ { #0001 SFT2 } %2* { #0001 SHL2 } -%8/ { #0003 SFT2 } %8* { #0003 SHL2 } +%2/ { #0001 SFT2 } %2* { #0010 SFT2 } +%8/ { #0003 SFT2 } %8* { #0030 SFT2 } %8- { #0008 SUB2 } %8+ { #0008 ADD2 } %SFL { #40 SFT SFT } @@ -158,7 +158,7 @@ BRK ,no-erase-mode ~bankview.mode #02 NEQ JMP2? ( load ) ~addr ~pos.y 8/ ADD2 LDR ( mask ) #01 #07 ~pos.x 8/ SWP POP SUB SFL - #ff XOR AND + #ff EOR AND ( save ) ~addr ~pos.y 8/ ADD2 STR ,redraw JSR2 ,click-end JMP2 @no-erase-mode diff --git a/projects/software/noodle.usm b/projects/software/noodle.usm index 99d6969..dcd9d59 100644 --- a/projects/software/noodle.usm +++ b/projects/software/noodle.usm @@ -22,7 +22,7 @@ %RTN? { JMP2r? } %++ { #0001 ADD2 } %-- { #0001 SUB2 } %2/ { #0001 SFT2 } -%8/ { #0003 SFT2 } %8* { #0003 SHL2 } +%8/ { #0003 SFT2 } %8* { #0030 SFT2 } %8+ { #0008 ADD2 } %MOD8 { #0007 AND2 } %SFL { #40 SFT SFT } @@ -356,7 +356,7 @@ RTN =pt1.y =pt1.x ( get tile addr ) ,data ~pt1.x 8/ ~pt1.y 8/ ~canvas.w MUL2 ADD2 8* ~pt1.y MOD8 ADD2 ADD2 ( load ) DUP2 LDR - ( mask ) #01 #07 ~pt1.x MOD8 SWP POP SUB SFL #ff XOR AND + ( mask ) #01 #07 ~pt1.x MOD8 SWP POP SUB SFL #ff EOR AND ( save ) ROT ROT STR RTN diff --git a/uxn.c b/uxn.c index a2e7b6d..ca5db69 100644 --- a/uxn.c +++ b/uxn.c @@ -40,13 +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_ora(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_shl(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b << (a % 8)); } -void op_sft(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); - Uint8 left = (a & 0xf0) >> 4; - Uint8 right = (a & 0x0f); - push8(u->src, b << (left % 8) >> (right % 8)); -} +void op_eor(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b ^ a); } +void op_sft(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); Uint8 left = (a & 0xf0) >> 4; Uint8 right = (a & 0x0f); push8(u->src, b << (left % 8) >> (right % 8)); } /* Stack */ void op_pop(Uxn *u) { pop8(u->src); } void op_dup(Uxn *u) { push8(u->src, peek8(u->src, 0)); } @@ -71,11 +66,11 @@ void op_jmp16(Uxn *u) { u->ram.ptr = pop16(u->src); } void op_jsr16(Uxn *u) { push16(u->dst, u->ram.ptr); u->ram.ptr = pop16(u->src); } 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); } +/* Logic */ void op_and16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b & a); } void op_ora16(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_shl16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b << (a % 16)); } -void op_sft16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b >> (a % 16)); } +void op_eor16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b ^ a); } +void op_sft16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); Uint8 left = (a & 0x00f0) >> 4; Uint8 right = (a & 0x000f); push16(u->src, b << (left % 8) >> (right % 8)); } /* Stack(16-bits) */ void op_pop16(Uxn *u) { pop16(u->src); } void op_dup16(Uxn *u) { push16(u->src, peek16(u->src, 0)); } @@ -96,14 +91,14 @@ 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_ora, op_shl, op_sft, + op_equ, op_neq, op_gth, op_lth, op_and, op_ora, op_eor, op_sft, 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_xor, + op_add, op_sub, op_mul, op_div, op_nop, op_nop, op_nop, op_eor, /* 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_ora16, op_shl16, op_sft16, + op_equ16, op_neq16, op_gth16, op_lth16, op_and16, op_ora16, op_eor16, op_sft16, 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_xor16 + op_add16, op_sub16, op_mul16, op_div16, op_nop, op_nop, op_nop, op_nop }; Uint8 opr[][4] = { /* wstack-/+ rstack-/+ */