final construction parts & primitive output
This commit is contained in:
parent
6fcc8cd379
commit
d827ee0f97
12 changed files with 36 additions and 15 deletions
BIN
6.out
BIN
6.out
Binary file not shown.
BIN
a.out
BIN
a.out
Binary file not shown.
BIN
cpu.6
BIN
cpu.6
Binary file not shown.
6
cpu.c
6
cpu.c
|
@ -7,6 +7,7 @@ u8int rA, rS, rX, rY, rP;
|
|||
u16int pc;
|
||||
|
||||
int irq, nmi;
|
||||
int trace;
|
||||
|
||||
void
|
||||
nz(u8int v)
|
||||
|
@ -217,8 +218,9 @@ step(void)
|
|||
}
|
||||
cpc = pc;
|
||||
op = fetch8();
|
||||
print("%02x %08b %08b %08b %08b %04x %02x\n",
|
||||
op, rA, rX, rY, rP, cpc, rS);
|
||||
if(trace)
|
||||
print("%02x %08b %08b %08b %08b %04x %02x\n",
|
||||
op, rA, rX, rY, rP, cpc, rS);
|
||||
switch(op){
|
||||
case 0x00:
|
||||
pc++;
|
||||
|
|
1
dat.h
1
dat.h
|
@ -12,3 +12,4 @@ extern u8int *mem;
|
|||
extern u8int *romptr;
|
||||
extern u8int rA, rS, rX, rY, rP;
|
||||
extern u16int pc;
|
||||
extern int trace;
|
||||
|
|
7
fns.h
7
fns.h
|
@ -2,4 +2,11 @@ extern int step(void);
|
|||
extern u8int memread(u16int);
|
||||
extern void memwrite(u16int, u8int);
|
||||
|
||||
extern void push8(u8int);
|
||||
extern void push16(u16int);
|
||||
extern u8int pop8(void);
|
||||
extern u16int pop16(void);
|
||||
extern u8int fetch8(void);
|
||||
extern u16int fetch16(void);
|
||||
|
||||
extern void out(void);
|
||||
|
|
BIN
main.6
BIN
main.6
Binary file not shown.
7
main.c
7
main.c
|
@ -6,7 +6,7 @@
|
|||
void
|
||||
usage(void)
|
||||
{
|
||||
fprint(2, "usage: %s [ -s target cycle length ] prog\n", argv0);
|
||||
fprint(2, "usage: %s [ -t ] [ -s target cycle length ] prog\n", argv0);
|
||||
exits("usage");
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ main(int argc, char **argv)
|
|||
vlong t, t2, t3;
|
||||
vlong target;
|
||||
|
||||
trace = 0;
|
||||
target = 1000;
|
||||
mem = malloc(0x10000);
|
||||
if(mem == nil)
|
||||
|
@ -49,6 +50,9 @@ main(int argc, char **argv)
|
|||
case 's':
|
||||
target = atoll(EARGF(usage()));
|
||||
break;
|
||||
case 't':
|
||||
trace = 1;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
|
@ -71,6 +75,7 @@ main(int argc, char **argv)
|
|||
t3 = t2-t;
|
||||
}
|
||||
}
|
||||
out();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
BIN
mem.6
BIN
mem.6
Binary file not shown.
2
mkfile
2
mkfile
|
@ -3,7 +3,7 @@
|
|||
BIN=/$objtype/bin
|
||||
|
||||
TARG=scemu
|
||||
OFILES=main.$O cpu.$O mem.$O
|
||||
OFILES=main.$O cpu.$O mem.$O out.$O
|
||||
UPDATE=mkfile prog.s ${OFILES:%.$O=%.c}
|
||||
|
||||
default:V: $O.out
|
||||
|
|
17
out.c
Normal file
17
out.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include <u.h>
|
||||
#include <libc.h>
|
||||
#include "dat.h"
|
||||
#include "fns.h"
|
||||
|
||||
void
|
||||
out(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
if(memread(0x7002) == 1){
|
||||
c = memread(0x7000);
|
||||
memwrite(0x7001, 0);
|
||||
print("%c", c);
|
||||
memwrite(0x7001, 1);
|
||||
}
|
||||
}
|
11
test.s
11
test.s
|
@ -1,11 +0,0 @@
|
|||
.org $ff00
|
||||
reset:
|
||||
lda #'\'
|
||||
sta $7000
|
||||
loop:
|
||||
ror
|
||||
jmp loop
|
||||
.org $fffa
|
||||
.word reset
|
||||
.word reset
|
||||
.word reset
|
Loading…
Add table
Reference in a new issue