4 Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
6 This file is part of simavr.
8 simavr is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 simavr is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with simavr. If not, see <http://www.gnu.org/licenses/>.
26 * Instruction decoder, run ONE instruction
28 uint16_t avr_run_one(avr_t * avr);
31 * These are for internal access to the stack (for interupts)
33 uint16_t _avr_sp_get(avr_t * avr);
34 void _avr_sp_set(avr_t * avr, uint16_t sp);
35 void _avr_push16(avr_t * avr, uint16_t v);
38 * Get a "pretty" register name
40 const char * avr_regname(uint8_t reg);
45 * These will diseapear when gdb arrives
47 void avr_dump_state(avr_t * avr);
49 #define DUMP_REG() { \
50 for (int i = 0; i < 32; i++) printf("%s=%02x%c", avr_regname(i), avr->data[i],i==15?'\n':' ');\
52 uint16_t y = avr->data[R_YL] | (avr->data[R_YH]<<8);\
53 for (int i = 0; i < 20; i++) printf("Y+%02d=%02x ", i, avr->data[y+i]);\
59 #define DUMP_STACK() \
60 for (int i = avr->stack_frame_index; i; i--) {\
62 printf("\e[31m*** %04x: %-25s sp %04x\e[0m\n",\
63 avr->stack_frame[pci].pc, avr->codeline[avr->stack_frame[pci].pc>>1]->symbol, avr->stack_frame[pci].sp);\
71 printf("*** CYCLE %lld PC %04x\n", avr->cycle, avr->pc);\
72 for (int i = OLD_PC_SIZE-1; i > 0; i--) {\
73 int pci = (avr->old_pci + i) & 0xf;\
74 printf("\e[31m*** %04x: %-25s RESET -%d; sp %04x\e[0m\n",\
75 avr->old[pci].pc, avr->codeline[avr->old[pci].pc>>1]->symbol, OLD_PC_SIZE-i, avr->old[pci].sp);\
77 printf("Stack Ptr %04x/%04x = %d \n", _avr_sp_get(avr), avr->ramend, avr->ramend - _avr_sp_get(avr));\
82 #endif /* SIM_CORE_H_ */