diff --git a/firmware/AtomBusMon.c b/firmware/AtomBusMon.c index 70f76ae..49c57a3 100644 --- a/firmware/AtomBusMon.c +++ b/firmware/AtomBusMon.c @@ -113,10 +113,10 @@ char *triggerStrings[NUM_TRIGGERS] = { }; -#define VERSION "0.28" +#define VERSION "0.29" #ifdef EMBEDDED_6502 -#define NUM_CMDS 24 +#define NUM_CMDS 25 #else #define NUM_CMDS 19 #endif @@ -175,6 +175,7 @@ char *cmdStrings[NUM_CMDS] = { "dis", "read", "write", + "fill", #endif "reset", "step", @@ -373,30 +374,43 @@ int lookupBreakpoint(char *params) { #ifdef EMBEDDED_6502 -unsigned int readMem(unsigned int addr) { - int i; - for (i = 0; i <= 15; i++) { - hwCmd(CMD_LOAD_MEM, addr & 1); - addr >>= 1; - } - hwCmd(CMD_RD_MEM, 0); - Delay_us(10); - return hwRead8(OFFSET_DATA); -} - -void writeMem(unsigned int addr, unsigned int data) { +void loadData(unsigned int data) { int i; for (i = 0; i <= 7; i++) { hwCmd(CMD_LOAD_MEM, data & 1); data >>= 1; } +} + +void loadAddr(unsigned int addr) { + int i; for (i = 0; i <= 15; i++) { hwCmd(CMD_LOAD_MEM, addr & 1); addr >>= 1; } +} + +unsigned int readByte() { + hwCmd(CMD_RD_MEM, 0); + Delay_us(10); + return hwRead8(OFFSET_DATA); +} + +void writeByte() { hwCmd(CMD_WR_MEM, 0); } +unsigned int readMem(unsigned int addr) { + loadAddr(addr); + return readByte(); +} + +void writeMem(unsigned int addr, unsigned int data) { + loadData(data); + loadAddr(addr); + writeByte(); +} + unsigned int disMem(unsigned int addr) { return disassemble(addr, readMem(addr), readMem(addr + 1), readMem(addr + 2)); } @@ -492,10 +506,11 @@ void doCmdRegs(char *params) { void doCmdMem(char *params) { int i, j; unsigned int row[16]; - sscanf(params, "%x", &memAddr); + sscanf(params, "%x", &memAddr); + loadAddr(memAddr); for (i = 0; i < 0x100; i+= 16) { for (j = 0; j < 16; j++) { - row[j] = readMem(memAddr + i + j); + row[j] = readByte(); } log0("%04X ", memAddr + i); for (j = 0; j < 16; j++) { @@ -539,6 +554,20 @@ void doCmdRead(char *params) { writeMem(addr, data); } +void doCmdFill(char *params) { + unsigned int i; + unsigned int start; + unsigned int end; + unsigned int data; + sscanf(params, "%x %x %x", &start, &end, &data); + log0("Wr: %04X to %04X = %X\n", start, end, data); + loadData(data); + loadAddr(start); + for (i = start; i < end; i++) { + hwCmd(CMD_WR_MEM, 0); + } +} + #endif void doCmdTrace(char *params) { @@ -809,6 +838,7 @@ void (*cmdFuncs[NUM_CMDS])(char *params) = { doCmdDis, doCmdRead, doCmdWrite, + doCmdFill, #endif doCmdReset, doCmdStep, diff --git a/firmware/disassembler.c b/firmware/disassembler.c index 3de7009..50efb01 100644 --- a/firmware/disassembler.c +++ b/firmware/disassembler.c @@ -25,7 +25,7 @@ char dopname[256][6] = /*F0*/ "BEQ", "SBC", "SBC", "---", "---", "SBC", "INC", "---", "SED", "SBC", "PLX", "---", "---", "SBC", "INC", "---", }; -int dopaddr[256] = +unsigned char dopaddr[256] = { /*00*/ IMP, INDX, IMP, IMP, ZP, ZP, ZP, IMP, IMP, IMM, IMPA, IMP, ABS, ABS, ABS, IMP, /*10*/ BRA, INDY, IND, IMP, ZP, ZPX, ZPX, IMP, IMP, ABSY, IMPA, IMP, ABS, ABSX, ABSX, IMP, diff --git a/src/BusMonCore.vhd b/src/BusMonCore.vhd index c356c22..2897a43 100644 --- a/src/BusMonCore.vhd +++ b/src/BusMonCore.vhd @@ -397,6 +397,11 @@ begin end if; end if; + + -- Auto increment the memory address reg the cycle after a rd/wr + if (memory_rd = '1' or memory_wr = '1') then + addr_dout_reg(23 downto 8) <= addr_dout_reg(23 downto 8) + 1; + end if; -- Single Stepping if ((single = '0') or (cmd_edge2 = '0' and cmd_edge1 = '1' and cmd = "1000")) then