summaryrefslogtreecommitdiff
path: root/sux.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-10-04 18:22:00 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2020-10-04 18:22:00 -0400
commitca8e2f93acc794b00464c5513956bd84de258913 (patch)
tree83153822fdea777bd11a8254c0e4bd87fe1d8350 /sux.c
parent784ff59108b887e246b0f33ff696dfd981659ab2 (diff)
- Added support for reading, and writing outside the
emulator's memory. All reads outside of the emulator's memory give back $/0xFF bytes, while all writes outside of the emulator's memory are ignored. - Implemented malloc(), and free() in the SuB Suite. In order to do this, I had to add support for a heap, which I did by reserving the first 3 banks of the address space (the first 192K), and by adding a routine that finds the end of the RAM. In this case, I set the starting address for the routine at bank 3 (bank 4 with one indexing), but, the routine's starting address isn't hardcoded, and thus, any starting address can be passed as an argument. The routine uses the fact that we can now read/write outside the emulator's memory, and also uses the fact that writing outside the emulator's memory will be ignored, and that reading outside the emulator's memory will always read $/0xFF bytes, and uses that to signal that it's reached the end of the RAM. - Added a test program for getting the size of RAM starting at address $/0x20000.
Diffstat (limited to 'sux.c')
-rw-r--r--sux.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/sux.c b/sux.c
index f1b07df..daabdc2 100644
--- a/sux.c
+++ b/sux.c
@@ -218,17 +218,12 @@ void *run(void *args) {
pthread_mutex_unlock(&mutex);
#endif
#endif
- prefix = addr[cpu->pc];
- if ((prefix & 0x03) != 0x03) {
- prefix = 0;
- }
- cpu->pc += ((prefix & 0x03) == 0x03);
- opcode = addr[cpu->pc];
- ++cpu->pc;
+ uint16_t instr = read_value(cpu, 0, cpu->pc, 1, 1, 0);
+ uint8_t *tmp_inst = (uint8_t *)&instr;
+ prefix = ((instr & 3) == 3) ? *tmp_inst++ : 0;
+ opcode = *tmp_inst;
+ cpu->pc += ((instr & 3) == 3)+1;
address.u64 = cpu->pc;
- #if getclk
- ++cpu->clk;
- #endif
uint8_t am = optype[opcode];
uint8_t rs = (prefix >> 4) & 3;
uint8_t size = (/***/1 << rs) - 1;
@@ -246,15 +241,15 @@ void *run(void *args) {
#endif
if (am != IMPL && am != BREG) {
address.u64 = get_addr(cpu, opcode, prefix, 1, 1, thread);
- if (address.u64 > mem_size-1) {
+ /*if (address.u64 > mem_size-1) {
addr[STEP_ADDR] = 1;
step = 1;
- }
+ }*/
if (isrw(opcode) && am != REL && isread(opcode)) {
value.u64 = read_value(cpu, 0, address.u64, size, 1, check_io);
}
}
- switch(opcode) {
+ switch (opcode) {
case CPS_IMP: /* Clear Processor Status. */
cpu->ps.u64 = 0;
break;
@@ -563,16 +558,15 @@ void *run(void *args) {
default:
break;
}
- /*if (cpu->pc <= 0xFF) {
- step = 1;
- wrefresh(scr);
- }*/
#if !IO
ins++;
#endif
#if !bench
if (step) {
- int c = 0;;
+ int c = 0;
+ #if debug
+ wrefresh(scr);
+ #endif
for (; step && c != 19 && !end; c = get_key(scr));
#if debug
wrefresh(scr);