~swisschili/toolchain-6502

b04a40263ced274594076186d9dc2783da6bd2e8 — swissChili 3 months ago e7ee6da
Change SP to
3 files changed, 4 insertions(+), 5 deletions(-)

M README.md
M cpu.c
M gui.c
M README.md => README.md +0 -2
@@ 1,8 1,6 @@
# 6502 Toolchain

<center>
[![Screenshot](screenshot.png)](colors.webm)
</center>

This project aims to create a portable toolchain for developing,
testing and debugging programs for the 6502 processor. An assembler

M cpu.c => cpu.c +3 -2
@@ 22,7 22,7 @@ sdl_screen_t *g_scr = NULL;

void reset(cpu_t *cpu)
{
	cpu->regs[SP] = 0xFD; // stack at is 0x100 + SP
	cpu->regs[SP] = 0xFF; // stack at is 0x100 + SP
	cpu->pc = 0x600; // arbitrary program counter start
	cpu->running = true;
	memset(cpu->mem + 0x100, 0, 0xFE);


@@ 31,7 31,7 @@ void reset(cpu_t *cpu)
cpu_t new_cpu()
{
	cpu_t cpu = { 0 };
	cpu.regs[SP] = 0xFD; // stack at is 0x100 + SP
	cpu.regs[SP] = 0xFF; // stack at is 0x100 + SP
	cpu.pc = 0x600; // arbitrary program counter start
	cpu.running = true;
	cpu.mem = malloc(0xFFFF);


@@ 396,6 396,7 @@ void execute(cpu_t *cpu, const char *mnemonic, uint8_t op, arg_t a, uint8_t am)

		case JSR:
			stack_pushle(cpu, cpu->pc);
			cpu->pc = a.ptr;
			break;

		case RTS:

M gui.c => gui.c +1 -1
@@ 163,7 163,7 @@ void gui(cpu_t *cpu)
			NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE))
		{
			nk_layout_row_static(ctx, 24, 48, 2);
			for (int i = 0xFD; i >= 0; i--)
			for (int i = 0xFF; i >= 0; i--)
			{
				char line[6];
				sprintf(line, "$%x", 0x100 + i);