Make dumpregs and dump_ram accessible from debug HWI. Add emulator ID to debug irqh
This commit is contained in:
parent
56eae1aca1
commit
9ceac9ae5a
64
dsim.c
64
dsim.c
|
@ -8,6 +8,9 @@
|
|||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define EMU_ID 0xed6f
|
||||
#define EMU_VER 0x0000
|
||||
|
||||
uint16_t ram[0x10000];
|
||||
uint16_t ra, rb, rc, rx, ry, rz, ri, rj;
|
||||
uint16_t rpc, rsp, rex, ria;
|
||||
|
@ -20,6 +23,27 @@ uint16_t intq[MAX_INTQ_SIZE];
|
|||
unsigned int intq_size;
|
||||
uint8_t intq_head;
|
||||
|
||||
void dumpregs()
|
||||
{
|
||||
printf("%4s %4s %4s %4s %4s %4s %4s %4s %4s %4s %4s %4s\n",
|
||||
"PC","SP","A","B","C","X","Y","Z","I","J","EX","IA");
|
||||
printf("%04hx %04hx %04hx %04hx %04hx %04hx %04hx %04hx %04hx %04hx %04hx %04hx\n",
|
||||
rpc, rsp, ra, rb, rc, rx, ry, rz, ri, rj, rex, ria);
|
||||
}
|
||||
|
||||
void dump_ram(uint16_t addr, uint16_t count)
|
||||
{
|
||||
uint16_t i, a;
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
a = (addr + i) % sizeof(ram);
|
||||
if ((i % 8) == 0)
|
||||
printf("\n%04x: ", a);
|
||||
printf("%04x ", ram[a]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void intq_push(uint16_t v)
|
||||
{
|
||||
if (intq_size < MAX_INTQ_SIZE) {
|
||||
|
@ -64,7 +88,21 @@ struct dev_entry {
|
|||
|
||||
void debug_irqh()
|
||||
{
|
||||
running = false;
|
||||
switch (ra) {
|
||||
case 0x0000:
|
||||
running = false;
|
||||
break;
|
||||
case 0x0001:
|
||||
dumpregs();
|
||||
break;
|
||||
case 0x0002:
|
||||
dump_ram(ry, rx);
|
||||
break;
|
||||
case 0xffff:
|
||||
rx = EMU_ID;
|
||||
ry = EMU_VER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
struct dev_entry iodevs[] = {
|
||||
|
@ -442,14 +480,6 @@ const op_t sops[] = {
|
|||
oNOP, oNOP, oNOP, oNOP, oNOP, oNOP, oNOP, oNOP /* 18-1f */
|
||||
};
|
||||
|
||||
void dumpregs()
|
||||
{
|
||||
printf("%4s %4s %4s %4s %4s %4s %4s %4s %4s %4s %4s %4s\n",
|
||||
"PC","SP","A","B","C","X","Y","Z","I","J","EX","IA");
|
||||
printf("%04hx %04hx %04hx %04hx %04hx %04hx %04hx %04hx %04hx %04hx %04hx %04hx\n",
|
||||
rpc, rsp, ra, rb, rc, rx, ry, rz, ri, rj, rex, ria);
|
||||
}
|
||||
|
||||
void next()
|
||||
{
|
||||
uint16_t ir;
|
||||
|
@ -469,8 +499,6 @@ void next()
|
|||
}
|
||||
}
|
||||
|
||||
dumpregs();
|
||||
|
||||
ir = ram[rpc++];
|
||||
|
||||
opcode = ir & 0x001f;
|
||||
|
@ -518,24 +546,10 @@ int load_image(char *filename)
|
|||
}
|
||||
}
|
||||
|
||||
void dump_ram(uint16_t addr, uint16_t count)
|
||||
{
|
||||
uint16_t i, a;
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
a = (addr + i) % sizeof(ram);
|
||||
if ((i % 8) == 0)
|
||||
printf("\n%04x: ", a);
|
||||
printf("%04x ", ram[a]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc > 1) {
|
||||
load_image(argv[1]);
|
||||
dump_ram(0, 32);
|
||||
reset();
|
||||
while (running) next();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue