add blank todo opcode functions based on opcode json

This commit is contained in:
Vineet K 2024-06-09 13:11:05 +05:30
parent 207c6903f5
commit 76b9059b2e
2 changed files with 438 additions and 20 deletions

31
converter_blank_funs.py Normal file
View File

@ -0,0 +1,31 @@
import json
address_mode_table = {
'Implied': 'AM_ACC',
'Immediate': 'AM_IMM',
'Zero Page': 'AM_ZP',
'Zero Page, X': 'AM_ZP_X',
'Zero Page, Y': 'AM_ZP_Y',
'Absolute': 'AM_ABS',
'Absolute, X': 'AM_ABS_X',
'Absolute, Y': 'AM_ABS_Y',
'Indirect': 'AM_IND',
'(Indirect)': 'AM_IND',
'(Indirect, X)': 'AM_IND_X',
'(Indirect), Y': 'AM_IND_Y',
}
# https://github.com/ericTheEchidna/65C02-JSON/
j = json.load(open('opcodes_65c02.json', 'r'))
#print(j)
for i in j:
#print(i)
instruction = str.lower(i["instruction"])
print('''
static void
''' + instruction + '''(uint8_t arg)
{
/* TODO: complete this */
}''')

427
cpu.c
View File

@ -110,7 +110,7 @@ opcode_arg(enum addressing_mode mode)
return val;
}
void
static void
adc(uint8_t arg)
{
uint16_t sum; // 16-bit sum makes it easier to determine carry flag
@ -125,43 +125,198 @@ adc(uint8_t arg)
STATUS_UPDATE_NEGATIVE(regs.a);
}
void
sbc(uint8_t arg)
static void
and(uint8_t arg)
{
/* SBC is described online as ADC with argument as two's complement */
adc(~arg + 1);
/* TODO: complete this */
}
void
brk(void)
static void
asl(uint8_t arg)
{
/* TODO: complete this */
}
static void
bbr(uint8_t arg)
{
/* TODO: complete this */
}
static void
bbs(uint8_t arg)
{
/* TODO: complete this */
}
static void
bcc(uint8_t arg)
{
/* TODO: complete this */
}
static void
bcs(uint8_t arg)
{
/* TODO: complete this */
}
static void
beq(uint8_t arg)
{
/* TODO: complete this */
}
static void
bit(uint8_t arg)
{
/* TODO: complete this */
}
static void
bmi(uint8_t arg)
{
/* TODO: complete this */
}
static void
bne(uint8_t arg)
{
/* TODO: complete this */
}
static void
bpl(uint8_t arg)
{
/* TODO: complete this */
}
static void
bra(uint8_t arg)
{
/* TODO: complete this */
}
static void
brk()
{
/* $00 */
/* TODO: push regs.pc and regs.status to stack and load IRQ vector */
regs.status.brk = 1;
return;
exit(0);
}
void
tax(void)
static void
bvc(uint8_t arg)
{
/* $AA */
regs.x = regs.a;
STATUS_UPDATE_ZERO(regs.x);
STATUS_UPDATE_NEGATIVE(regs.x);
/* TODO: complete this */
}
void
inx(void)
static void
bvs(uint8_t arg)
{
/* TODO: complete this */
}
static void
clc(uint8_t arg)
{
/* TODO: complete this */
}
static void
cld(uint8_t arg)
{
/* TODO: complete this */
}
static void
cli(uint8_t arg)
{
/* TODO: complete this */
}
static void
clv(uint8_t arg)
{
/* TODO: complete this */
}
static void
cmp(uint8_t arg)
{
/* TODO: complete this */
}
static void
cpx(uint8_t arg)
{
/* TODO: complete this */
}
static void
cpy(uint8_t arg)
{
/* TODO: complete this */
}
static void
dec(uint8_t arg)
{
/* TODO: complete this */
}
static void
dex(uint8_t arg)
{
/* TODO: complete this */
}
static void
dey(uint8_t arg)
{
/* TODO: complete this */
}
static void
eor(uint8_t arg)
{
/* TODO: complete this */
}
static void
inc(uint8_t arg)
{
/* TODO: complete this */
}
static void
inx()
{
/* $E8 */
regs.x++;
STATUS_UPDATE_ZERO(regs.x);
STATUS_UPDATE_NEGATIVE(regs.x);
}
void
static void
iny(uint8_t arg)
{
/* TODO: complete this */
}
static void
jmp(uint8_t arg)
{
/* TODO: complete this */
}
static void
jsr(uint8_t arg)
{
/* TODO: complete this */
}
static void
lda(uint8_t arg)
{
printf("arg1 $%02X\n", arg);
@ -171,6 +326,238 @@ lda(uint8_t arg)
STATUS_UPDATE_NEGATIVE(regs.a);
}
static void
ldx(uint8_t arg)
{
/* TODO: complete this */
}
static void
ldy(uint8_t arg)
{
/* TODO: complete this */
}
static void
lsr(uint8_t arg)
{
/* TODO: complete this */
}
static void
nop(uint8_t arg)
{
/* TODO: complete this */
}
static void
ora(uint8_t arg)
{
/* TODO: complete this */
}
static void
pha(uint8_t arg)
{
/* TODO: complete this */
}
static void
php(uint8_t arg)
{
/* TODO: complete this */
}
static void
phx(uint8_t arg)
{
/* TODO: complete this */
}
static void
phy(uint8_t arg)
{
/* TODO: complete this */
}
static void
pla(uint8_t arg)
{
/* TODO: complete this */
}
static void
plp(uint8_t arg)
{
/* TODO: complete this */
}
static void
plx(uint8_t arg)
{
/* TODO: complete this */
}
static void
ply(uint8_t arg)
{
/* TODO: complete this */
}
static void
rmb(uint8_t arg)
{
/* TODO: complete this */
}
static void
rol(uint8_t arg)
{
/* TODO: complete this */
}
static void
ror(uint8_t arg)
{
/* TODO: complete this */
}
static void
rti(uint8_t arg)
{
/* TODO: complete this */
}
static void
rts(uint8_t arg)
{
/* TODO: complete this */
}
static void
sbc(uint8_t arg)
{
/* SBC is described online as ADC with argument as two's complement */
adc(~arg + 1);
}
static void
sec(uint8_t arg)
{
/* TODO: complete this */
}
static void
sed(uint8_t arg)
{
/* TODO: complete this */
}
static void
sei(uint8_t arg)
{
/* TODO: complete this */
}
static void
smb(uint8_t arg)
{
/* TODO: complete this */
}
static void
sta(uint8_t arg)
{
/* TODO: complete this */
}
static void
stp(uint8_t arg)
{
/* TODO: complete this */
}
static void
stx(uint8_t arg)
{
/* TODO: complete this */
}
static void
sty(uint8_t arg)
{
/* TODO: complete this */
}
static void
stz(uint8_t arg)
{
/* TODO: complete this */
}
static void
tax()
{
regs.x = regs.a;
STATUS_UPDATE_ZERO(regs.x);
STATUS_UPDATE_NEGATIVE(regs.x);
}
static void
tay(uint8_t arg)
{
/* TODO: complete this */
}
static void
trb(uint8_t arg)
{
/* TODO: complete this */
}
static void
tsb(uint8_t arg)
{
/* TODO: complete this */
}
static void
tsx(uint8_t arg)
{
/* TODO: complete this */
}
static void
txa(uint8_t arg)
{
/* TODO: complete this */
}
static void
txs(uint8_t arg)
{
/* TODO: complete this */
}
static void
tya(uint8_t arg)
{
/* TODO: complete this */
}
static void
wai(uint8_t arg)
{
/* TODO: complete this */
}
static void
unp(uint8_t arg)
{
/* TODO: complete this */
}
void
interpret(void)
{