static unsigned int BS_Read(unsigned int address) { if (address >= 0x8000) { return prgrom[address]; } return memory_read8(address); }
void emul_bench (struct _sim_cpu* cpu) { int op; op = cpu_get_d (cpu); switch (op) { case 0: bench_mode = 0; gettimeofday (&bench_start, 0); break; case 1: gettimeofday (&bench_stop, 0); if (bench_mode != 0) printf ("bench start not called...\n"); bench_mode = 1; break; case 2: { int sz = 0; int addr = cpu_get_x (cpu); double t_start, t_stop, t; char buf[1024]; op = cpu_get_y (cpu); t_start = (double) (bench_start.tv_sec) * 1.0e6; t_start += (double) (bench_start.tv_usec); t_stop = (double) (bench_stop.tv_sec) * 1.0e6; t_stop += (double) (bench_stop.tv_usec); while (sz < 1024) { buf[sz] = memory_read8 (cpu, addr); if (buf[sz] == 0) break; sz ++; addr++; } buf[1023] = 0; if (bench_mode != 1) printf ("bench_stop not called"); bench_mode = -1; t = t_stop - t_start; printf ("%-40.40s [%6d] %3.3f us\n", buf, op, t / (double) (op)); break; } } }
void emul_write(struct _sim_cpu* state) { int addr = cpu_get_x (state) & 0x0FFFF; int size = cpu_get_d (state) & 0x0FFFF; if (addr + size > 0x0FFFF) { size = 0x0FFFF - addr; } state->cpu_running = 0; while (size) { uint8 val = memory_read8 (state, addr); write(0, &val, 1); addr ++; size--; } }