add memory writing functions
This commit is contained in:
parent
4db0a8163e
commit
c417bf2276
22
cpu.c
22
cpu.c
@ -51,20 +51,34 @@ uint8_t program[] = { 0xa9, 0xc0, 0xaa, 0xe8, 0x00 };
|
|||||||
|
|
||||||
uint32_t cycles = 0;
|
uint32_t cycles = 0;
|
||||||
|
|
||||||
uint8_t
|
static uint8_t
|
||||||
peek(uint16_t addr)
|
peek(uint16_t addr)
|
||||||
{
|
{
|
||||||
return memory[addr];
|
return memory[addr];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t
|
static uint16_t
|
||||||
peek16(uint16_t addr)
|
peek16(uint16_t addr)
|
||||||
{
|
{
|
||||||
/* bytes are stored in little-endian (low then high) */
|
/* bytes are stored in little-endian (low then high) */
|
||||||
return (uint16_t)memory[addr] | ((uint16_t)memory[addr + 1] << 8);
|
return (uint16_t)memory[addr] | ((uint16_t)memory[addr + 1] << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t
|
static void
|
||||||
|
memwrite(uint16_t addr, uint8_t byte)
|
||||||
|
{
|
||||||
|
memory[addr] = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
memwrite16(uint16_t addr, uint16_t word)
|
||||||
|
{
|
||||||
|
/* bytes are stored in little-endian (low then high) */
|
||||||
|
memory[addr] = word & 0xFF;
|
||||||
|
memory[addr + 1] = (word & 0xFF00) >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t
|
||||||
opcode_arg(enum addressing_mode mode)
|
opcode_arg(enum addressing_mode mode)
|
||||||
{
|
{
|
||||||
uint8_t arg, val;
|
uint8_t arg, val;
|
||||||
@ -597,7 +611,7 @@ unp(uint8_t arg)
|
|||||||
/* TODO: complete this */
|
/* TODO: complete this */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
interpret(void)
|
interpret(void)
|
||||||
{
|
{
|
||||||
uint8_t opcode;
|
uint8_t opcode;
|
||||||
|
Loading…
Reference in New Issue
Block a user