Removed LTS/GTS opcodes

This commit is contained in:
neauoire 2021-05-01 09:59:57 -07:00
parent 57d2e11e59
commit 993719818a
14 changed files with 48 additions and 42 deletions

View File

@ -1,10 +1,10 @@
# Uxn
A [stack-based VM](https://wiki.xxiivv.com/site/uxn.html), written in ANSI C.
An [8-bit stack-based computer](https://wiki.xxiivv.com/site/uxn.html), written in ANSI C.
## Build
To build the Uxn emulator, you must have [SDL2](https://wiki.libsdl.org/).
To build the Uxn emulator, you must have [SDL2](https://wiki.libsdl.org/) and [Portmidi](http://portmedia.sourceforge.net/portmidi/).
```sh
./build.sh
@ -34,7 +34,7 @@ Read more in the [Uxambly Guide](https://wiki.xxiivv.com/site/uxambly.html).
|0100 ( -> )
;hello-word ;print JSR2
;hello-word ,print JSR
BRK
@ -54,11 +54,6 @@ RTN
## TODOs
- Shortcut to export/import disk state
- Implement Uxambly REPL
- Load disks at a different place than 0x0000.
- Curl device? 8-bit web browser?
- Replace LTS/GTS? `LTS = #80 ADD SWP #80 ADD SWP LTH`
- `#80 ADD SWP #80 ADD GTH`
## Palettes

View File

@ -34,7 +34,7 @@ else
fi
echo "Assembling.."
./bin/assembler projects/demos/polycat.usm bin/boot.rom
./bin/assembler projects/software/noodle.usm bin/boot.rom
echo "Running.."
if [ "${2}" = '--cli' ];

View File

@ -9,6 +9,8 @@
%++ { #0001 ADD2 }
%TOS { #00 SWP }
%MOD { DUP2 DIV MUL SUB }
%LTS2 { #8000 ADD2 SWP2 #8000 ADD2 GTH2 }
%GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
%PAD-WIDTH { #0030 }
%PAD-HEIGHT { #0020 }

View File

@ -7,6 +7,8 @@
%++ { #0001 ADD2 }
%TOS { #00 SWP }
%MOD { DUP2 DIV MUL SUB }
%LTS2 { #8000 ADD2 SWP2 #8000 ADD2 GTH2 }
%GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
%WAVEFORM { #1000 }

View File

@ -10,7 +10,7 @@
|0100 ( -> )
;hello-word ;print JSR2
;hello-word ,print JSR
BRK

View File

@ -2,7 +2,6 @@
%++ { #0001 ADD2 }
%-- { #0001 SUB2 }
%2/ { #0002 DIV2 }
( devices )
@ -29,8 +28,8 @@
;on-frame .Screen/vector DEO2
( set origin )
.Screen/width DEI2 2/ .Screen/x DEO2
.Screen/height DEI2 2/ .Screen/y DEO2
.Screen/width DEI2 #0002 DIV2 .Screen/x DEO2
.Screen/height DEI2 #0002 DIV2 .Screen/y DEO2
;default_icn .Screen/addr DEO2
#31 .Screen/color DEO

View File

@ -6,6 +6,8 @@
%SCALEX { #0002 DIV2 .Screen/width DEI2 #0002 DIV2 ADD2 #0040 SUB2 }
%SCALEY { #0002 DIV2 .Screen/height DEI2 #0002 DIV2 ADD2 #0040 SUB2 }
%12HOURS { DUP #0c GTH #0c MUL SUB }
%LTS2 { #8000 ADD2 SWP2 #8000 ADD2 GTH2 }
%GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
( devices )

View File

@ -1,7 +1,9 @@
( dev/mouse )
%RTN { JMP2r }
%ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 }.
%ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 }
%LTS2 { #8000 ADD2 SWP2 #8000 ADD2 GTH2 }
%GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
( devices )
@ -97,11 +99,11 @@ RTN
#ffff #00 .line/y PEK2 .line/y0 PEK2 LTS2 #0002 MUL2 ADD2 .line/sy POK2
.line/dx PEK2 .line/dy PEK2 ADD2 .line/e1 POK2
&loop
( draw )
.line/x PEK2 .Screen/x DEO2
.line/y PEK2 .Screen/y DEO2
.color PEK .Screen/color DEO
.line/x PEK2 .line/x0 PEK2 EQU2 .line/y PEK2 .line/y0 PEK2 EQU2 #0101 EQU2 ,&end JNZ
[ .line/x PEK2 .line/x0 PEK2 EQU2 ]
[ .line/y PEK2 .line/y0 PEK2 EQU2 ] #0101 EQU2 ,&end JNZ
.line/e1 PEK2 #0002 MUL2 .line/e2 POK2
.line/e2 PEK2 .line/dy PEK2 LTS2 ,&skipy JNZ
.line/e1 PEK2 .line/dy PEK2 ADD2 .line/e1 POK2
@ -111,7 +113,7 @@ RTN
.line/e1 PEK2 .line/dx PEK2 ADD2 .line/e1 POK2
.line/y PEK2 .line/sy PEK2 ADD2 .line/y POK2
&skipx
,&loop JMP
;&loop JMP2
&end
RTN

View File

@ -5,6 +5,8 @@
%-- { #0001 SUB2 }
%8+ { #0008 ADD2 }
%ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 }
%LTS2 { #8000 ADD2 SWP2 #8000 ADD2 GTH2 }
%GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
%SIZE-TO-RECT {
STH2 STH2 OVR2 STH2r ADD2 OVR2 STH2r ADD2

View File

@ -8,6 +8,8 @@
%++ { #0001 ADD2 }
%TOS { #00 SWP }
%MOD { DUP2 DIV MUL SUB }
%LTS2 { #8000 ADD2 SWP2 #8000 ADD2 GTH2 }
%GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
%VIEW-WIDTH { #0110 }
%VIEW-HEIGHT { #0038 }

View File

@ -23,6 +23,8 @@
%8- { #0008 SUB2 } %8+ { #0008 ADD2 }
%SFL { #40 SFT SFT }
%MOD { DUP2 DIV MUL SUB }
%LTS2 { #8000 ADD2 SWP2 #8000 ADD2 GTH2 }
%GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
%SIZE-TO-RECT {
STH2 STH2 OVR2 STH2r ADD2 OVR2 STH2r ADD2

View File

@ -15,6 +15,8 @@
%RTN { JMP2r }
%ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 }
%LTS2 { #8000 ADD2 SWP2 #8000 ADD2 GTH2 }
%GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
%CLN2r { DUP2 STH2 }
%STEP8 { #0033 SFT2 }
%MOD8 { #0007 AND2 }

View File

@ -41,8 +41,8 @@ Program p;
char ops[][4] = {
"BRK", "LIT", "NOP", "POP", "DUP", "SWP", "OVR", "ROT",
"EQU", "NEQ", "GTH", "LTH", "GTS", "LTS", "DEI", "DEO",
"PEK", "POK", "GET", "PUT", "JMP", "JNZ", "JSR", "STH",
"EQU", "NEQ", "GTH", "LTH", "JMP", "JNZ", "JSR", "STH",
"PEK", "POK", "GET", "PUT", "---", "---", "DEI", "DEO",
"ADD", "SUB", "MUL", "DIV", "AND", "ORA", "EOR", "SFT"
};

View File

@ -44,19 +44,17 @@ void op_equ(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b
void op_neq(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b != a); }
void op_gth(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b > a); }
void op_lth(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b < a); }
void op_gts(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, (Sint8)b > (Sint8)a); }
void op_lts(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, (Sint8)b < (Sint8)a); }
void op_dei(Uxn *u) { Uint8 a = pop8(u->src); push8(u->src, devpeek8(&u->dev[a >> 4], a)); }
void op_deo(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); devpoke8(&u->dev[a >> 4], a, b); }
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_jsr(Uxn *u) { Uint8 a = pop8(u->src); push16(u->dst, u->ram.ptr); u->ram.ptr += (Sint8)a; }
void op_sth(Uxn *u) { Uint8 a = pop8(u->src); push8(u->dst, a); }
/* Memory */
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_get(Uxn *u) { Uint16 a = pop16(u->src); push8(u->src, mempeek8(u->ram.dat, a)); }
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_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_sth(Uxn *u) { Uint8 a = pop8(u->src); push8(u->dst, a); }
void op_dei(Uxn *u) { Uint8 a = pop8(u->src); push8(u->src, devpeek8(&u->dev[a >> 4], a)); }
void op_deo(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); devpoke8(&u->dev[a >> 4], a, b); }
/* Arithmetic */
void op_add(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b + a); }
void op_sub(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b - a); }
@ -78,19 +76,17 @@ void op_equ16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->sr
void op_neq16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->src, b != a); }
void op_gth16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->src, b > a); }
void op_lth16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->src, b < a); }
void op_gts16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->src, (Sint16)b > (Sint16)a); }
void op_lts16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->src, (Sint16)b < (Sint16)a); }
void op_dei16(Uxn *u) { Uint8 a = pop8(u->src); push16(u->src, devpeek16(&u->dev[a >> 4], a)); }
void op_deo16(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); devpoke16(&u->dev[a >> 4], a, b); }
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_jsr16(Uxn *u) { push16(u->dst, u->ram.ptr); u->ram.ptr = pop16(u->src); }
void op_sth16(Uxn *u) { Uint16 a = pop16(u->src); push16(u->dst, a); }
/* Memory(16-bits) */
void op_pek16(Uxn *u) { Uint8 a = pop8(u->src); push16(u->src, mempeek16(u->ram.dat, a)); }
void op_pok16(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); mempoke16(u->ram.dat, a, b); }
void op_get16(Uxn *u) { Uint16 a = pop16(u->src); push16(u->src, mempeek16(u->ram.dat, a)); }
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_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_sth16(Uxn *u) { Uint16 a = pop16(u->src); push16(u->dst, a); }
void op_dei16(Uxn *u) { Uint8 a = pop8(u->src); push16(u->src, devpeek16(&u->dev[a >> 4], a)); }
void op_deo16(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); devpoke16(&u->dev[a >> 4], a, b); }
/* Arithmetic(16-bits) */
void op_add16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b + a); }
void op_sub16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b - a); }
@ -103,13 +99,13 @@ void op_sft16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->s
void (*ops[])(Uxn *u) = {
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_dei, op_deo,
op_pek, op_pok, op_get, op_put, op_jmp, op_jnz, op_jsr, op_sth,
op_equ, op_neq, op_gth, op_lth, op_jmp, op_jnz, op_jsr, op_sth,
op_pek, op_pok, op_get, op_put, op_nop, op_nop, op_dei, op_deo,
op_add, op_sub, op_mul, op_div, op_and, op_ora, op_eor, op_sft,
/* 16-bit */
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_dei16, op_deo16,
op_pek16, op_pok16, op_get16, op_put16, op_jmp16, op_jnz16, op_jsr16, op_sth16,
op_equ16, op_neq16, op_gth16, op_lth16, op_jmp16, op_jnz16, op_jsr16, op_sth16,
op_pek16, op_pok16, op_get16, op_put16, op_nop, op_nop, op_dei16, op_deo16,
op_add16, op_sub16, op_mul16, op_div16, op_and16, op_ora16, op_eor16, op_sft16
};