the consequences of OOP have been a disaster for the human race, and some failures of my own along the way

This commit is contained in:
Yuvia 2025-09-09 20:29:16 +00:00
parent d827ee0f97
commit eea8ef5513
15 changed files with 161 additions and 15 deletions

BIN
6.out Executable file

Binary file not shown.

BIN
a.out Normal file

Binary file not shown.

BIN
cpu.6 Normal file

Binary file not shown.

5
cpu.c
View file

@ -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);
}
}

3
fns.h
View file

@ -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*);

BIN
in.6 Normal file

Binary file not shown.

22
in.c Normal file
View file

@ -0,0 +1,22 @@
#include <u.h>
#include <libc.h>
#include <ctype.h>
#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);
}
}
}

BIN
main.6 Normal file

Binary file not shown.

7
main.c
View file

@ -1,5 +1,6 @@
#include <u.h>
#include <libc.h>
#include <thread.h>
#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();
}
}

BIN
mem.6 Normal file

Binary file not shown.

2
mkfile
View file

@ -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

BIN
out.6 Normal file

Binary file not shown.

16
out.c
View file

@ -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);
}
}

24
test.s Normal file
View file

@ -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

97
wozmon.s Normal file
View file

@ -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