Progress on status flags
This commit is contained in:
parent
2782586f78
commit
06c57cb936
|
@ -36,8 +36,8 @@ $01 < pointer8 >
|
||||||
|
|
||||||
## Mission
|
## Mission
|
||||||
|
|
||||||
|
- Carry flag?
|
||||||
- Loop
|
- Loop
|
||||||
- Conditional example
|
|
||||||
- Pointers/Literals
|
- Pointers/Literals
|
||||||
- Print word to stdout
|
- Print word to stdout
|
||||||
- Draw pixel to screen
|
- Draw pixel to screen
|
||||||
|
@ -51,7 +51,6 @@ $01 < pointer8 >
|
||||||
- Implement 16 bits operations
|
- Implement 16 bits operations
|
||||||
- Jumps should be relative
|
- Jumps should be relative
|
||||||
- Catch overflow/underflow
|
- Catch overflow/underflow
|
||||||
- Implement literals like `[2]`, and `[ 2 3 ]`.
|
|
||||||
- Audo-detect literals length.
|
- Audo-detect literals length.
|
||||||
- SDL Layer Emulator
|
- SDL Layer Emulator
|
||||||
- Build PPU
|
- Build PPU
|
||||||
|
|
2
build.sh
2
build.sh
|
@ -14,5 +14,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr
|
||||||
cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined uxn.c -o uxn
|
cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined uxn.c -o uxn
|
||||||
|
|
||||||
# run
|
# run
|
||||||
./uxnasm examples/cond.usm boot.rom
|
./uxnasm examples/core.usm boot.rom
|
||||||
./uxn boot.rom
|
./uxn boot.rom
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
< core >
|
< core >
|
||||||
|
|
||||||
+12 -34
|
+12 +34 ADD
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
< subroutines >
|
||||||
|
|
||||||
|
:begin
|
||||||
|
.addall JSR ADD ADD
|
||||||
|
+06 EQU .isequal JSR
|
||||||
|
BRK
|
||||||
|
|
||||||
|
:add1
|
||||||
|
+01 RTS
|
||||||
|
|
||||||
|
:add2
|
||||||
|
+02 RTS
|
||||||
|
|
||||||
|
:add3
|
||||||
|
+03 RTS
|
||||||
|
|
||||||
|
:addall
|
||||||
|
.add1 JSR
|
||||||
|
.add2 JSR
|
||||||
|
.add3 JSR
|
||||||
|
RTS
|
||||||
|
|
||||||
|
:isequal
|
||||||
|
.addall JSR +ff
|
||||||
|
RTS
|
14
uxn.c
14
uxn.c
|
@ -92,7 +92,7 @@ rspop(void)
|
||||||
|
|
||||||
void op_brk() { setflag(FLAG_HALT, 1); }
|
void op_brk() { setflag(FLAG_HALT, 1); }
|
||||||
void op_rts() { cpu.mptr = rspop(); }
|
void op_rts() { cpu.mptr = rspop(); }
|
||||||
void op_lit() { cpu.literal += 1;}
|
void op_lit() { cpu.literal += 1; }
|
||||||
void op_drp() { spop(); }
|
void op_drp() { spop(); }
|
||||||
void op_dup() { spush(cpu.stack[cpu.sptr - 1]); }
|
void op_dup() { spush(cpu.stack[cpu.sptr - 1]); }
|
||||||
void op_swp() { Uint8 b = spop(), a = spop(); spush(b); spush(a); }
|
void op_swp() { Uint8 b = spop(), a = spop(); spush(b); spush(a); }
|
||||||
|
@ -100,8 +100,8 @@ void op_ovr() { spush(cpu.stack[cpu.sptr - 2]); }
|
||||||
void op_rot() { Uint8 c = spop(),b = spop(),a = spop(); spush(b); spush(c); spush(a); }
|
void op_rot() { Uint8 c = spop(),b = spop(),a = spop(); spush(b); spush(c); spush(a); }
|
||||||
void op_jmp() { cpu.mptr = spop(); }
|
void op_jmp() { cpu.mptr = spop(); }
|
||||||
void op_jsr() { rspush(cpu.mptr); cpu.mptr = spop(); }
|
void op_jsr() { rspush(cpu.mptr); cpu.mptr = spop(); }
|
||||||
void op_jmq() { if(getflag(FLAG_ZERO)) op_jmp(); }
|
void op_jmq() { if(getflag(FLAG_ZERO)){ op_jmp(); } setflag(FLAG_ZERO,0); }
|
||||||
void op_jsq() { if(getflag(FLAG_ZERO)) op_jsr(); }
|
void op_jsq() { if(getflag(FLAG_ZERO)){ op_jsr(); } setflag(FLAG_ZERO,0); }
|
||||||
void op_equ() { setflag(FLAG_ZERO, spop() == spop()); }
|
void op_equ() { setflag(FLAG_ZERO, spop() == spop()); }
|
||||||
void op_neq() { setflag(FLAG_ZERO, spop() != spop()); }
|
void op_neq() { setflag(FLAG_ZERO, spop() != spop()); }
|
||||||
void op_lth() { setflag(FLAG_ZERO, spop() < spop()); }
|
void op_lth() { setflag(FLAG_ZERO, spop() < spop()); }
|
||||||
|
@ -159,6 +159,8 @@ eval()
|
||||||
}
|
}
|
||||||
if(instr < 24)
|
if(instr < 24)
|
||||||
(*ops[instr])();
|
(*ops[instr])();
|
||||||
|
if(instr > 0x10)
|
||||||
|
setflag(FLAG_ZERO, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -169,6 +171,12 @@ run(void)
|
||||||
eval(cpu);
|
eval(cpu);
|
||||||
/* debug */
|
/* debug */
|
||||||
printf("ended @ %d | ", cpu.counter);
|
printf("ended @ %d | ", cpu.counter);
|
||||||
|
printf("hf: %x zf: %x cf: %x tf: %x\n",
|
||||||
|
getflag(FLAG_HALT),
|
||||||
|
getflag(FLAG_ZERO),
|
||||||
|
getflag(FLAG_CARRY),
|
||||||
|
getflag(FLAG_TRAPS));
|
||||||
|
printf("\n\n");
|
||||||
for(i = 0; i < 4; i++)
|
for(i = 0; i < 4; i++)
|
||||||
printf("%d-", (cpu.status & (1 << i)) != 0);
|
printf("%d-", (cpu.status & (1 << i)) != 0);
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
|
|
Loading…
Reference in New Issue