Cleaned up/commented the C code base; version now 0.48

Change-Id: I415c97b579e247f7f3d4fdc476b9e5ed6b1e7e70
This commit is contained in:
David Banks 2015-07-01 12:08:30 +01:00
parent 727a1c0f2a
commit 10be34c618
7 changed files with 831 additions and 627 deletions

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,22 @@
#include "hd44780.h"
#endif
// The Atom CRC Polynomial
#define CRC_POLY 0x002d
#define Delay_us(__us) \
if((unsigned long) (F_CPU/1000000.0 * __us) != F_CPU/1000000.0 * __us)\
__builtin_avr_delay_cycles((unsigned long) ( F_CPU/1000000.0 * __us)+1);\
else __builtin_avr_delay_cycles((unsigned long) ( F_CPU/1000000.0 * __us))
#define Delay_ms(__ms) \
if((unsigned long) (F_CPU/1000.0 * __ms) != F_CPU/1000.0 * __ms)\
__builtin_avr_delay_cycles((unsigned long) ( F_CPU/1000.0 * __ms)+1);\
else __builtin_avr_delay_cycles((unsigned long) ( F_CPU/1000.0 * __ms))
unsigned int hwRead8(unsigned int offset);
unsigned int hwRead16(unsigned int offset);
#ifdef CPUEMBEDDED
unsigned int disMem(unsigned int addr);
void loadData(unsigned int data);
@ -19,4 +35,35 @@ void writeMemByteInc();
unsigned int disMem(unsigned int addr);
#endif
void doCmdBreak(char *params, unsigned int mode);
void doCmdBreakI(char *params);
void doCmdBreakRdIO(char *params);
void doCmdBreakRdMem(char *params);
void doCmdBreakWrIO(char *params);
void doCmdBreakWrMem(char *params);
void doCmdClear(char *params);
void doCmdContinue(char *params);
void doCmdCrc(char *params);
void doCmdDis(char *params);
void doCmdFill(char *params);
void doCmdHelp(char *params);
void doCmdIO(char *params);
void doCmdList(char *params);
void doCmdMem(char *params);
void doCmdReadIO(char *params);
void doCmdReadMem(char *params);
void doCmdRegs(char *params);
void doCmdReset(char *params);
void doCmdStep(char *params);
void doCmdTest(char *params);
void doCmdTrace(char *params);
void doCmdTrigger(char *params);
void doCmdWatchI(char *params);
void doCmdWatchRdIO(char *params);
void doCmdWatchRdMem(char *params);
void doCmdWatchWrIO(char *params);
void doCmdWatchWrMem(char *params);
void doCmdWriteIO(char *params);
void doCmdWriteMem(char *params);
#endif

View File

@ -25,7 +25,7 @@ OBJCOPY=avr-objcopy
CFLAGS=-DCPU=6502 -DCPUEMBEDDED -DF_CPU=${F_CPU}UL -DSERIAL_STATUS -DCOOKED_SERIAL -DNOUSART1 -mmcu=$(MCU) -Wall -Os -mcall-prologues
OBJECTS=AtomBusMon.o dis6502.o status.o
OBJECTS=AtomBusMon.o dis6502.o regs6502.o status.o
build: avr6502cpu.bit

View File

@ -25,7 +25,7 @@ OBJCOPY=avr-objcopy
CFLAGS=-DCPU=Z80 -DCPUEMBEDDED -DF_CPU=${F_CPU}UL -DSERIAL_STATUS -DCOOKED_SERIAL -DNOUSART1 -mmcu=$(MCU) -Wall -Os -mcall-prologues -mno-interrupts
OBJECTS=AtomBusMon.o disz80.o status.o
OBJECTS=AtomBusMon.o disz80.o regsz80.o status.o
build: avrz80cpu.bit

View File

@ -189,10 +189,10 @@ unsigned char dopaddr[256] =
unsigned int disassemble(unsigned int addr)
{
unsigned int temp;
unsigned int op = readByteInc();
unsigned int op = readMemByteInc();
int mode = dopaddr[op];
unsigned int p1 = (mode > MARK2) ? readByteInc() : 0;
unsigned int p2 = (mode > MARK3) ? readByteInc() : 0;
unsigned int p1 = (mode > MARK2) ? readMemByteInc() : 0;
unsigned int p2 = (mode > MARK3) ? readMemByteInc() : 0;
log0("%04X : %s ", addr, opStrings[dopname[op]]);
switch (mode)

29
firmware/regs6502.c Normal file
View File

@ -0,0 +1,29 @@
#include "AtomBusMon.h"
#define OFFSET_REG_A 32
#define OFFSET_REG_X 33
#define OFFSET_REG_Y 34
#define OFFSET_REG_P 35
#define OFFSET_REG_SP 36
#define OFFSET_REG_PC 38
char statusString[8] = "NV-BDIZC";
void doCmdRegs(char *params) {
int i;
unsigned int p = hwRead8(OFFSET_REG_P);
log0("6502 Registers:\n A=%02X X=%02X Y=%02X SP=%04X PC=%04X\n",
hwRead8(OFFSET_REG_A),
hwRead8(OFFSET_REG_X),
hwRead8(OFFSET_REG_Y),
hwRead16(OFFSET_REG_SP),
hwRead16(OFFSET_REG_PC));
char *sp = statusString;
log0(" Status: ");
for (i = 0; i <= 7; i++) {
log0("%c", ((p & 128) ? (*sp) : '-'));
p <<= 1;
sp++;
}
log0("\n");
}

51
firmware/regsz80.c Normal file
View File

@ -0,0 +1,51 @@
#include "AtomBusMon.h"
#define OFFSET_REG_BC 32
#define OFFSET_REG_DE 34
#define OFFSET_REG_HL 36
#define OFFSET_REG_IX 38
#define OFFSET_REG_BCp 40
#define OFFSET_REG_DEp 42
#define OFFSET_REG_HLp 44
#define OFFSET_REG_IY 46
#define OFFSET_REG_AF 48
#define OFFSET_REG_AFp 50
#define OFFSET_REG_SP 52
#define OFFSET_REG_PC 54
#define OFFSET_REG_I 56
#define OFFSET_REG_R 57
#define OFFSET_REG_IFF 58
char statusString[8] = "SZIH-P-C";
void doCmdRegs(char *params) {
int i;
unsigned int p = hwRead16(OFFSET_REG_AF);
log0("Z80 Registers:\n");
log0(" AF=%04X BC=%04X DE=%04X HL=%04X\n",
p,
hwRead16(OFFSET_REG_BC),
hwRead16(OFFSET_REG_DE),
hwRead16(OFFSET_REG_HL));
log0(" 'AF=%04X 'BC=%04X 'DE=%04X 'HL=%04X\n",
hwRead16(OFFSET_REG_AFp),
hwRead16(OFFSET_REG_BCp),
hwRead16(OFFSET_REG_DEp),
hwRead16(OFFSET_REG_HLp));
log0(" IX=%04X IY=%04X PC=%04X SP=%04X I=%02X R=%02X IFF=%02X\n",
hwRead16(OFFSET_REG_IX),
hwRead16(OFFSET_REG_IY),
hwRead16(OFFSET_REG_PC),
hwRead16(OFFSET_REG_SP),
hwRead8(OFFSET_REG_I),
hwRead8(OFFSET_REG_R),
hwRead8(OFFSET_REG_IFF));
char *sp = statusString;
log0(" Status: ");
for (i = 0; i <= 7; i++) {
log0("%c", ((p & 128) ? (*sp) : '-'));
p <<= 1;
sp++;
}
log0("\n");
}