Removed SHL for SFT

This commit is contained in:
neauoire 2021-03-19 21:13:09 -07:00
parent d4a5d9e9cb
commit 0c18938e9f
5 changed files with 18 additions and 23 deletions

View File

@ -46,9 +46,9 @@ Program p;
char ops[][4] = { char ops[][4] = {
"BRK", "NOP", "LIT", "LDR", "STR", "---", "JMP", "JSR", "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", "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 */ int scin(char *s, char c) { int i = 0; while(s[i]) if(s[i++] == c) return i - 1; return -1; } /* string char index */

View File

@ -19,7 +19,7 @@
%RTN? { JMP2r? } %RTN? { JMP2r? }
%++ { #0001 ADD2 } %-- { #0001 SUB2 } %++ { #0001 ADD2 } %-- { #0001 SUB2 }
%8/ { #0003 SFT2 } %8* { #0003 SHL2 } %8/ { #0003 SFT2 } %8* { #0030 SFT2 }
%8- { #0008 SUB2 } %8+ { #0008 ADD2 } %8- { #0008 SUB2 } %8+ { #0008 ADD2 }
;lock { byte 1 } ;lock { byte 1 }

View File

@ -8,11 +8,11 @@
%RTN { JMP2r } %RTN { JMP2r }
%RTN? { JMP2r? } %RTN? { JMP2r? }
%STEP8 { #0003 SFT2 #0003 SHL2 } %STEP8 { #0003 SFT2 #0030 SFT2 }
%++ { #0001 ADD2 } %++ { #0001 ADD2 }
%2/ { #0001 SFT2 } %2* { #0001 SHL2 } %2/ { #0001 SFT2 } %2* { #0010 SFT2 }
%8/ { #0003 SFT2 } %8* { #0003 SHL2 } %8/ { #0003 SFT2 } %8* { #0030 SFT2 }
%8- { #0008 SUB2 } %8+ { #0008 ADD2 } %8- { #0008 SUB2 } %8+ { #0008 ADD2 }
%SFL { #40 SFT SFT } %SFL { #40 SFT SFT }
@ -158,7 +158,7 @@ BRK
,no-erase-mode ~bankview.mode #02 NEQ JMP2? ,no-erase-mode ~bankview.mode #02 NEQ JMP2?
( load ) ~addr ~pos.y 8/ ADD2 LDR ( load ) ~addr ~pos.y 8/ ADD2 LDR
( mask ) #01 #07 ~pos.x 8/ SWP POP SUB SFL ( mask ) #01 #07 ~pos.x 8/ SWP POP SUB SFL
#ff XOR AND #ff EOR AND
( save ) ~addr ~pos.y 8/ ADD2 STR ( save ) ~addr ~pos.y 8/ ADD2 STR
,redraw JSR2 ,click-end JMP2 ,redraw JSR2 ,click-end JMP2
@no-erase-mode @no-erase-mode

View File

@ -22,7 +22,7 @@
%RTN? { JMP2r? } %RTN? { JMP2r? }
%++ { #0001 ADD2 } %-- { #0001 SUB2 } %++ { #0001 ADD2 } %-- { #0001 SUB2 }
%2/ { #0001 SFT2 } %2/ { #0001 SFT2 }
%8/ { #0003 SFT2 } %8* { #0003 SHL2 } %8/ { #0003 SFT2 } %8* { #0030 SFT2 }
%8+ { #0008 ADD2 } %8+ { #0008 ADD2 }
%MOD8 { #0007 AND2 } %MOD8 { #0007 AND2 }
%SFL { #40 SFT SFT } %SFL { #40 SFT SFT }
@ -356,7 +356,7 @@ RTN
=pt1.y =pt1.x =pt1.y =pt1.x
( get tile addr ) ,data ~pt1.x 8/ ~pt1.y 8/ ~canvas.w MUL2 ADD2 8* ~pt1.y MOD8 ADD2 ADD2 ( get tile addr ) ,data ~pt1.x 8/ ~pt1.y 8/ ~canvas.w MUL2 ADD2 8* ~pt1.y MOD8 ADD2 ADD2
( load ) DUP2 LDR ( 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 ( save ) ROT ROT STR
RTN RTN

23
uxn.c
View File

@ -40,13 +40,8 @@ void op_str(Uxn *u) { Uint16 a = pop16(u->src); Uint8 b = pop8(u->src); mempoke8
/* Logic */ /* Logic */
void op_and(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b & a); } 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_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_eor(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_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 */ /* Stack */
void op_pop(Uxn *u) { pop8(u->src); } void op_pop(Uxn *u) { pop8(u->src); }
void op_dup(Uxn *u) { push8(u->src, peek8(u->src, 0)); } 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_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_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_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_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_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_eor16(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); Uint8 left = (a & 0x00f0) >> 4; Uint8 right = (a & 0x000f); push16(u->src, b << (left % 8) >> (right % 8)); }
void op_sft16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b >> (a % 16)); }
/* Stack(16-bits) */ /* Stack(16-bits) */
void op_pop16(Uxn *u) { pop16(u->src); } void op_pop16(Uxn *u) { pop16(u->src); }
void op_dup16(Uxn *u) { push16(u->src, peek16(u->src, 0)); } 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) = { void (*ops[])(Uxn *u) = {
op_brk, op_nop, op_lit, op_ldr, op_str, op_nop, op_jmp, op_jsr, 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_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 */ /* 16-bit */
op_brk, op_nop16, op_lit16, op_ldr16, op_str16, op_nop, op_jmp16, op_jsr16, 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_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-/+ */ Uint8 opr[][4] = { /* wstack-/+ rstack-/+ */