// cpu header file, contains variable declarations, short definition macros, and bitmasks that // are declared for clarity and ease of use; macros that do real work can be found in actions.h /* UART Transmit variables and definitions */ #pragma regalloc- // don't want to store declared variables in registers unsigned char txc_buffer1[80]; // write from here to transmit buffer, alternate 1 and 2 for simultaneous read and write unsigned char txc_buffer2[80]; // write from here to transmit buffer, alternate 1 and 2 for simultaneous read and write unsigned char buf_index; // tracks which byte in the txc_buffer we are writing from unsigned char trans_done; // indicates whether the transmitter is idle unsigned char* txc_write_buffer; // pointer to the buffer to transmit from (to send to outside world) unsigned char* txc_read_buffer; // pointer to the buffer transmit data can be written to if transmitter is busy (from code, waiting to be sent) unsigned char* buffer_switch; // temp pointer used to switch txc_write_buffer and txc_read_buffer unsigned char write_ready; // indicates another set of data is ready to be sent unsigned char temp_buffer[80]; // temporary uses such as storing the string to print out to serial /* UART receive variables */ char rxc_done; // indicates whether we are done receiving (whether user has hit enter) char r_index; // index of rxc_buffer unsigned char r_char; // current received character // Define 6502 registers, working variables, sreg flag masks for assembly use #asm ; define 6502 registers for ASM .def REG_SR=r19 .def REG_A=r8 .def REG_X=r2 .def REG_Y=r3 .def REG_IR=r4 .def REG_SP=r5 .def REG_PCL=r12 .def REG_PCH=r13 ; define working variables for ASM .def REG_OP=r9 .def REG_OPADDRL=r10 .def REG_OPADDRH=r11 .def REG_TMP=r16 ;note: can only perform immediate operations on r16-31 .def REG_TMP2=r17 .def REG_TMP3=r18 .def REG_TMP4=r20 ; define 6502 status register flags (bit masks) .equ ASR_N=0x80 .equ ASR_V=0x40 .equ ASR_B=0x10 .equ ASR_D=0x08 .equ ASR_I=0x04 .equ ASR_Z=0x02 .equ ASR_C=0x01 ; bit order of the status flags in the 6502 sreg .equ ASR_NB=7 .equ ASR_VB=6 .equ ASR_BB=4 .equ ASR_DB=3 .equ ASR_IB=2 .equ ASR_ZB=1 .equ ASR_CB=0 ; inverted bit mask .equ ASR_NI=0x7f .equ ASR_VI=0xbf .equ ASR_BI=0xef .equ ASR_DI=0xf7 .equ ASR_II=0xfb .equ ASR_ZI=0xfd .equ ASR_CI=0xfe #endasm #pragma regalloc- // define 6502 registers for C use (allocate the registers such that they // "overlap" and thus are the same as the ones declared for ASM use). // note: only able to allocate a variable to a register to when // the register number is <= 15. register unsigned char rA @ 0x08; register unsigned char rX @ 0x02; register unsigned char rY @ 0x03; register unsigned char rIR @ 0x04; register unsigned char rSP @ 0x05; register unsigned int rPC @ 0x0C; register unsigned char rPCL @ 0x0C; register unsigned char rPCH @ 0x0D; // define general working register definitions for use in C; again we overlap // with the same register numbers as declared for ASM use // note: can't allocate any variables to reg16-31 register unsigned char operand @ 0x09; register unsigned int op_addr @ 0x0A; // define 6502 status register flags for C #define SR_N (rSR.7) #define SR_V (rSR.6) #define SR_B (rSR.4) #define SR_D (rSR.3) #define SR_I (rSR.2) #define SR_Z (rSR.1) #define SR_C (rSR.0)