Implemented PEK/POK/GET/PUT
This commit is contained in:
parent
b01b74bad4
commit
276e5086db
|
@ -41,9 +41,9 @@ BRK
|
||||||
@print ( addr -- )
|
@print ( addr -- )
|
||||||
|
|
||||||
&loop
|
&loop
|
||||||
( send ) DUP2 PEK2 .Console/char IOW
|
( send ) DUP2 GET .Console/char IOW
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( loop ) DUP2 PEK2 #00 NEQ ,&loop JNZ
|
( loop ) DUP2 GET #00 NEQ ,&loop JNZ
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
2
build.sh
2
build.sh
|
@ -32,7 +32,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Assembling.."
|
echo "Assembling.."
|
||||||
./bin/assembler projects/examples/dev.mouse.usm bin/boot.rom
|
./bin/assembler projects/examples/dev.console.usm bin/boot.rom
|
||||||
|
|
||||||
echo "Running.."
|
echo "Running.."
|
||||||
if [ "${2}" = '--cli' ];
|
if [ "${2}" = '--cli' ];
|
||||||
|
|
|
@ -17,9 +17,9 @@ BRK
|
||||||
@print ( addr -- )
|
@print ( addr -- )
|
||||||
|
|
||||||
&loop
|
&loop
|
||||||
( send ) DUP2 PEK2 .Console/char IOW
|
( send ) DUP2 GET .Console/char IOW
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( loop ) DUP2 PEK2 #00 NEQ ,&loop JNZ
|
( loop ) DUP2 GET #00 NEQ ,&loop JNZ
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
|
@ -40,18 +40,18 @@ BRK
|
||||||
|
|
||||||
( clear last cursor )
|
( clear last cursor )
|
||||||
;clear .Screen/addr IOW2
|
;clear .Screen/addr IOW2
|
||||||
.pointer/x LDR .Screen/x IOW2
|
.pointer/x PEK2 .Screen/x IOW2
|
||||||
.pointer/y LDR .Screen/y IOW2
|
.pointer/y PEK2 .Screen/y IOW2
|
||||||
#30 .Screen/color IOW
|
#30 .Screen/color IOW
|
||||||
|
|
||||||
( record pointer positions )
|
( record pointer positions )
|
||||||
.Mouse/x IOR2 .pointer/x STR
|
.Mouse/x IOR2 .pointer/x POK2
|
||||||
.Mouse/y IOR2 .pointer/y STR
|
.Mouse/y IOR2 .pointer/y POK2
|
||||||
|
|
||||||
( draw new cursor )
|
( draw new cursor )
|
||||||
;cursor .Screen/addr IOW2
|
;cursor .Screen/addr IOW2
|
||||||
.pointer/x LDR .Screen/x IOW2
|
.pointer/x PEK2 .Screen/x IOW2
|
||||||
.pointer/y LDR .Screen/y IOW2
|
.pointer/y PEK2 .Screen/y IOW2
|
||||||
|
|
||||||
( colorize on state )
|
( colorize on state )
|
||||||
.Mouse/state IOR #00 NEQ
|
.Mouse/state IOR #00 NEQ
|
||||||
|
|
|
@ -42,7 +42,7 @@ Program p;
|
||||||
char ops[][4] = {
|
char ops[][4] = {
|
||||||
"BRK", "LIT", "NOP", "POP", "DUP", "SWP", "OVR", "ROT",
|
"BRK", "LIT", "NOP", "POP", "DUP", "SWP", "OVR", "ROT",
|
||||||
"EQU", "NEQ", "GTH", "LTH", "GTS", "LTS", "IOR", "IOW",
|
"EQU", "NEQ", "GTH", "LTH", "GTS", "LTS", "IOR", "IOW",
|
||||||
"PEK", "POK", "LDR", "STR", "JMP", "JNZ", "JSR", "STH",
|
"PEK", "POK", "GET", "PUT", "JMP", "JNZ", "JSR", "STH",
|
||||||
"ADD", "SUB", "MUL", "DIV", "AND", "ORA", "EOR", "SFT"
|
"ADD", "SUB", "MUL", "DIV", "AND", "ORA", "EOR", "SFT"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
16
src/uxn.c
16
src/uxn.c
|
@ -51,8 +51,8 @@ void op_iow(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); devpoke8(&u->dev
|
||||||
/* Memory */
|
/* Memory */
|
||||||
void op_pek(Uxn *u) { Uint8 a = pop8(u->src); push8(u->src, mempeek8(u->ram.dat, a)); }
|
void op_pek(Uxn *u) { Uint8 a = pop8(u->src); push8(u->src, mempeek8(u->ram.dat, a)); }
|
||||||
void op_pok(Uxn *u) { Uint8 a = pop8(u->src); Uint8 b = pop8(u->src); mempoke8(u->ram.dat, a, b); }
|
void op_pok(Uxn *u) { Uint8 a = pop8(u->src); Uint8 b = pop8(u->src); mempoke8(u->ram.dat, a, b); }
|
||||||
void op_ldr(Uxn *u) { Uint8 a = pop8(u->src); push16(u->src, mempeek16(u->ram.dat, a)); }
|
void op_get(Uxn *u) { Uint16 a = pop16(u->src); push8(u->src, mempeek8(u->ram.dat, a)); }
|
||||||
void op_str(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); mempoke16(u->ram.dat, a, b); }
|
void op_put(Uxn *u) { Uint16 a = pop16(u->src); Uint8 b = pop8(u->src); mempoke8(u->ram.dat, a, b); }
|
||||||
void op_jmp(Uxn *u) { Uint8 a = pop8(u->src); u->ram.ptr += (Sint8)a; }
|
void op_jmp(Uxn *u) { Uint8 a = pop8(u->src); u->ram.ptr += (Sint8)a; }
|
||||||
void op_jnz(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); if (b) u->ram.ptr += (Sint8)a; }
|
void op_jnz(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); if (b) u->ram.ptr += (Sint8)a; }
|
||||||
void op_jsr(Uxn *u) { Uint8 a = pop8(u->src); push16(u->dst, u->ram.ptr); u->ram.ptr += (Sint8)a; }
|
void op_jsr(Uxn *u) { Uint8 a = pop8(u->src); push16(u->dst, u->ram.ptr); u->ram.ptr += (Sint8)a; }
|
||||||
|
@ -83,10 +83,10 @@ void op_lts16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->sr
|
||||||
void op_ior16(Uxn *u) { Uint8 a = pop8(u->src); push16(u->src, devpeek16(&u->dev[a >> 4], a)); }
|
void op_ior16(Uxn *u) { Uint8 a = pop8(u->src); push16(u->src, devpeek16(&u->dev[a >> 4], a)); }
|
||||||
void op_iow16(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); devpoke16(&u->dev[a >> 4], a, b); }
|
void op_iow16(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); devpoke16(&u->dev[a >> 4], a, b); }
|
||||||
/* Memory(16-bits) */
|
/* Memory(16-bits) */
|
||||||
void op_pek16(Uxn *u) { Uint16 a = pop16(u->src); push8(u->src, mempeek8(u->ram.dat, a)); }
|
void op_pek16(Uxn *u) { Uint8 a = pop8(u->src); push16(u->src, mempeek16(u->ram.dat, a)); }
|
||||||
void op_pok16(Uxn *u) { Uint16 a = pop16(u->src); Uint8 b = pop8(u->src); mempoke8(u->ram.dat, a, b); }
|
void op_pok16(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); mempoke16(u->ram.dat, a, b); }
|
||||||
void op_ldr16(Uxn *u) { Uint16 a = pop16(u->src); push16(u->src, mempeek16(u->ram.dat, a)); }
|
void op_get16(Uxn *u) { Uint16 a = pop16(u->src); push16(u->src, mempeek16(u->ram.dat, a)); }
|
||||||
void op_str16(Uxn *u) { Uint16 a = pop16(u->src); Uint16 b = pop16(u->src); mempoke16(u->ram.dat, a, b); }
|
void op_put16(Uxn *u) { Uint16 a = pop16(u->src); Uint16 b = pop16(u->src); mempoke16(u->ram.dat, a, b); }
|
||||||
void op_jmp16(Uxn *u) { u->ram.ptr = pop16(u->src); }
|
void op_jmp16(Uxn *u) { u->ram.ptr = pop16(u->src); }
|
||||||
void op_jnz16(Uxn *u) { Uint16 a = pop16(u->src); Uint8 b = pop8(u->src); if (b) u->ram.ptr = a; }
|
void op_jnz16(Uxn *u) { Uint16 a = pop16(u->src); Uint8 b = pop8(u->src); if (b) u->ram.ptr = a; }
|
||||||
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); }
|
||||||
|
@ -104,12 +104,12 @@ void op_sft16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->s
|
||||||
void (*ops[])(Uxn *u) = {
|
void (*ops[])(Uxn *u) = {
|
||||||
op_brk, op_lit, op_nop, op_pop, op_dup, op_swp, op_ovr, op_rot,
|
op_brk, op_lit, op_nop, op_pop, op_dup, op_swp, op_ovr, op_rot,
|
||||||
op_equ, op_neq, op_gth, op_lth, op_gts, op_lts, op_ior, op_iow,
|
op_equ, op_neq, op_gth, op_lth, op_gts, op_lts, op_ior, op_iow,
|
||||||
op_pek, op_pok, op_ldr, op_str, op_jmp, op_jnz, op_jsr, op_sth,
|
op_pek, op_pok, op_get, op_put, op_jmp, op_jnz, op_jsr, op_sth,
|
||||||
op_add, op_sub, op_mul, op_div, op_and, op_ora, op_eor, op_sft,
|
op_add, op_sub, op_mul, op_div, op_and, op_ora, op_eor, op_sft,
|
||||||
/* 16-bit */
|
/* 16-bit */
|
||||||
op_brk, op_lit16, op_nop, op_pop16, op_dup16, op_swp16, op_ovr16, op_rot16,
|
op_brk, op_lit16, op_nop, op_pop16, op_dup16, op_swp16, op_ovr16, op_rot16,
|
||||||
op_equ16, op_neq16, op_gth16, op_lth16, op_gts16, op_lts16, op_ior16, op_iow16,
|
op_equ16, op_neq16, op_gth16, op_lth16, op_gts16, op_lts16, op_ior16, op_iow16,
|
||||||
op_pek16, op_pok16, op_ldr16, op_str16, op_jmp16, op_jnz16, op_jsr16, op_sth16,
|
op_pek16, op_pok16, op_get16, op_put16, op_jmp16, op_jnz16, op_jsr16, op_sth16,
|
||||||
op_add16, op_sub16, op_mul16, op_div16, op_and16, op_ora16, op_eor16, op_sft16
|
op_add16, op_sub16, op_mul16, op_div16, op_and16, op_ora16, op_eor16, op_sft16
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue