diff --git a/6.out b/6.out new file mode 100755 index 0000000..d104972 Binary files /dev/null and b/6.out differ diff --git a/a.out b/a.out new file mode 100644 index 0000000..64791c5 Binary files /dev/null and b/a.out differ diff --git a/cpu.6 b/cpu.6 new file mode 100644 index 0000000..361a8cb Binary files /dev/null and b/cpu.6 differ diff --git a/cpu.c b/cpu.c index 9e5c139..b0b6bd9 100644 --- a/cpu.c +++ b/cpu.c @@ -219,7 +219,7 @@ step(void) cpc = pc; op = fetch8(); if(trace) - print("%02x %08b %08b %08b %08b %04x %02x\n", + print("%02x %02x %02x %02x %08b %04x %02x\n", op, rA, rX, rY, rP, cpc, rS); switch(op){ case 0x00: @@ -713,8 +713,5 @@ step(void) default: print("unimplemented %#02x\n", op); exits(nil); - case 0xFF: - print("%s\n", (s8int*)mem+0x500); - exits(nil); } } diff --git a/fns.h b/fns.h index 1fec11e..72fa083 100644 --- a/fns.h +++ b/fns.h @@ -9,4 +9,5 @@ extern u16int pop16(void); extern u8int fetch8(void); extern u16int fetch16(void); -extern void out(void); +extern void in(void*); +extern void out(void*); diff --git a/in.6 b/in.6 new file mode 100644 index 0000000..630b7d5 Binary files /dev/null and b/in.6 differ diff --git a/in.c b/in.c new file mode 100644 index 0000000..e6d6a34 --- /dev/null +++ b/in.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include "dat.h" +#include "fns.h" + +void +in(void*) +{ + int c; + + for(;;){ + if(memread(0x7005) == 1){ + memwrite(0x7004, 1); + read(0, &c, 1); + c = toupper(c); + memwrite(0x7003, c); + memwrite(0x7004, 0); + memwrite(0x7005, 0); + } + } +} diff --git a/main.6 b/main.6 new file mode 100644 index 0000000..9df8dad Binary files /dev/null and b/main.6 differ diff --git a/main.c b/main.c index d0d4365..9244fa4 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,6 @@ #include #include +#include #include "dat.h" #include "fns.h" @@ -35,7 +36,7 @@ openprog(char *f) } void -main(int argc, char **argv) +threadmain(int argc, char **argv) { int c; vlong t, t2, t3; @@ -60,9 +61,12 @@ main(int argc, char **argv) if(!argc) usage(); openprog(*argv); + rS = 0xFF; rP = 0x34; pc = 0xFFFC; pc = fetch16(); + threadcreate(in, nil, mainstacksize); + threadcreate(out, nil, mainstacksize); for(;;){ c = step(); while(c >= 0){ @@ -75,7 +79,6 @@ main(int argc, char **argv) t3 = t2-t; } } - out(); } } diff --git a/mem.6 b/mem.6 new file mode 100644 index 0000000..9015a8e Binary files /dev/null and b/mem.6 differ diff --git a/mkfile b/mkfile index 6b7c155..24a7edd 100755 --- a/mkfile +++ b/mkfile @@ -3,7 +3,7 @@ BIN=/$objtype/bin TARG=scemu -OFILES=main.$O cpu.$O mem.$O out.$O +OFILES=main.$O cpu.$O mem.$O in.$O out.$O UPDATE=mkfile prog.s ${OFILES:%.$O=%.c} default:V: $O.out diff --git a/out.6 b/out.6 new file mode 100644 index 0000000..de3077d Binary files /dev/null and b/out.6 differ diff --git a/out.c b/out.c index 2c5570d..8f9489c 100644 --- a/out.c +++ b/out.c @@ -4,14 +4,16 @@ #include "fns.h" void -out(void) +out(void*) { int c; - if(memread(0x7002) == 1){ - c = memread(0x7000); - memwrite(0x7001, 0); - print("%c", c); - memwrite(0x7001, 1); - } + for(;;) + if(memread(0x7002) == 1){ /* ready to be fiddled */ + memwrite(0x7001, 1); /* we are busy */ + c = memread(0x7000); + print("%c", c); + memwrite(0x7002, 0); + memwrite(0x7001, 0); + } } diff --git a/test.s b/test.s new file mode 100644 index 0000000..caeddbe --- /dev/null +++ b/test.s @@ -0,0 +1,24 @@ + .org $8000 +reset: + lda #$01 + sta $7005 +loop: + lda $7004 + bne loop + lda $7003 + sta $7000 + lda #$01 + sta $7002 +waiting: + nop + nop + nop + nop + lda $7001 + bne waiting + .byte $ff + + .org $fffa + .word $8000 + .word $8000 + .word $8000 diff --git a/wozmon.s b/wozmon.s new file mode 100644 index 0000000..789e0ed --- /dev/null +++ b/wozmon.s @@ -0,0 +1,97 @@ +xaml = $24 +xamh = $25 +l = $28 +h = $29 +ysav = $2a +mode = $2b +asav = $2c +curchar = $2d + + .org $fe00 +reset: + cld + cli + lda #$03 +notcr: + cmp #$03 ; is etx, subst. for esc + beq escape + iny + bpl nextchar +escape: + lda #$5c + jsr echo +getline: + lda #$0a + jsr echo +setstor: + asl +setmode: + sta mode +blskip: +nextchar: + ldy #1 + sty $7005 +nextcharl: + lda $7004 ; have next char? + beq nextcharl + lda $7003 + sta curchar + cmp #$2e ; . + bcc blskip + beq setmode + cmp #$3a ; : + beq setstor + cmp #$52 ; R + beq run + stx l + stx h + sty ysav +nexthex: + lda curchar + eor #$b0 + cmp #$0a + bcc dig + adc #$b9 + cmp #$fa + bcc nothex +dig: + asl + asl + asl + asl + ldx #$04 +hexshift: + asl + rol l + rol h + dex + bne hexshift + bne nexthex +nothex: + cpy ysav + beq escape + bit mode + jmp nextchar +run: + jmp (xaml) +echo: + sta asav + txa + pha + lda asav + tax +echol: + lda $7001 + cmp #$01 + beq echol + stx $7000 + lda #$01 + sta $7002 + pla + tax + rts + + .org $fffa + .word $f000 + .word reset + .word $0000