comparison backend.c @ 1313:b27d7bf1107e

Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
author Michael Pavone <pavone@retrodev.com>
date Mon, 03 Apr 2017 20:48:13 -0700
parents 5c8b1c33ca10
children 92e7dafcc0dc
comparison
equal deleted inserted replaced
1312:9ab3f6781202 1313:b27d7bf1107e
91 } 91 }
92 } 92 }
93 return NULL; 93 return NULL;
94 } 94 }
95 95
96 uint16_t read_word(uint32_t address, void **mem_pointers, cpu_options *opts, void *context)
97 {
98 memmap_chunk const *chunk = find_map_chunk(address, opts, 0, NULL);
99 if (!chunk) {
100 return 0xFFFF;
101 }
102 uint32_t offset = (address - chunk->start) & chunk->mask;
103 if (chunk->flags & MMAP_READ) {
104 uint8_t *base;
105 if (chunk->flags & MMAP_PTR_IDX) {
106 base = mem_pointers[chunk->ptr_index];
107 } else {
108 base = chunk->buffer;
109 }
110 if (base) {
111 uint16_t val;
112 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) {
113 offset /= 2;
114 uint16_t val = base[offset];
115 if (chunk->flags & MMAP_ONLY_ODD) {
116 val |= 0xFF00;
117 } else {
118 val = val << 8 | 0xFF;
119 }
120 } else {
121 val = *(uint16_t *)(base + offset);
122 }
123 return val;
124 }
125 }
126 if ((!(chunk->flags & MMAP_READ) || (chunk->flags & MMAP_FUNC_NULL)) && chunk->read_16) {
127 return chunk->read_16(offset, context);
128 }
129 return 0xFFFF;
130 }
131
96 uint32_t chunk_size(cpu_options *opts, memmap_chunk const *chunk) 132 uint32_t chunk_size(cpu_options *opts, memmap_chunk const *chunk)
97 { 133 {
98 if (chunk->mask == opts->address_mask) { 134 if (chunk->mask == opts->address_mask) {
99 return chunk->end - chunk->start; 135 return chunk->end - chunk->start;
100 } else { 136 } else {