forked from PUCP-INF/mos6502-emulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.c
38 lines (34 loc) · 759 Bytes
/
debug.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "debug.h"
#include "cpu.h"
#include <stdio.h>
void print_ram()
{
printf("\n");
for (int j = 0; j < 256; ++j) {
printf("%02x ", mem.ram[0][j]);
if ((j+1) % 16 == 0) printf("\n");
}
printf("\n");
}
void print_stack()
{
printf("\nSTACK: ");
for (int i = 255; i != cpu.sp; --i) {
printf("%02x ", mem.ram[1][i]);
}
printf("\n");
}
void print_cpu()
{
// printf("\nOP = %02x\n", mem.ram[cpu.pch][cpu.pcl]);
printf("\nA = %02x\t\tC Z I D B V N\nX = %02x\t\t%d %d %d %d %d %d %d\nY = %02x\n",
cpu.a, cpu.x,
getsr(0), getsr(1), getsr(2), getsr(3), getsr(4), getsr(6), getsr(7),
cpu.y);
}
void info_cpu()
{
print_cpu();
print_stack();
print_ram();
}