static void endinfo(void)
{
- printf("Last test: %lu\n", testcnt);
+ printf("Last test: %u\n", testcnt);
uae_u8 *p = opcode_memory;
for (int i = 0; i < 4 * 2; i += 2) {
if (!is_valid_test_addr_read((uae_u32)(&p[i])))
break;
uae_u16 v = (p[i] << 8) | (p[i + 1]);
- printf("%08lx %04x\n", &p[i], v);
+ printf("%08x %04x\n", (uae_u32)&p[i], v);
if (v == 0x4afc && i > 0)
break;
}
fseek(f, 0, SEEK_SET);
uae_u8 *gzbuf = malloc(gsize);
if (!gzbuf) {
- printf("Couldn't allocate %ld bytes (packed), file '%s'\n", gsize, fname);
+ printf("Couldn't allocate %d bytes (packed), file '%s'\n", gsize, fname);
exit(0);
}
if (fread(gzbuf, 1, gsize, f) != gsize) {
if (!inflatestack) {
inflatestack = malloc(INFLATE_STACK_SIZE);
if (!inflatestack) {
- printf("Couldn't allocate %ld bytes (inflate stack)\n", INFLATE_STACK_SIZE);
+ printf("Couldn't allocate %d bytes (inflate stack)\n", INFLATE_STACK_SIZE);
exit(0);
}
inflatestack += INFLATE_STACK_SIZE;
if (!p) {
p = calloc(1, size);
if (!p) {
- printf("Couldn't allocate %ld bytes, file '%s'\n", size, fname);
+ printf("Couldn't allocate %d bytes, file '%s'\n", size, fname);
exit(0);
}
- printf("Decompressing '%s' (%ld -> %ld)\n", fname, gsize, size);
+ printf("Decompressing '%s' (%d -> %d)\n", fname, gsize, size);
callinflate(p, gzdata, inflatestack);
*sizep = size;
return p;
} else if (candirect) {
- printf("Decompressing '%s' (%ld -> %ld)\n", fname, gsize, size);
+ printf("Decompressing '%s' (%d -> %d)\n", fname, gsize, size);
callinflate(p, gzdata, inflatestack);
*sizep = size;
return p;
} else {
unpack = calloc(1, size);
if (!unpack) {
- printf("Couldn't allocate %ld bytes (unpack), file '%s'\n", size, fname);
+ printf("Couldn't allocate %d bytes (unpack), file '%s'\n", size, fname);
exit(0);
}
- printf("Decompressing '%s' (%ld -> %ld)\n", fname, gsize, size);
+ printf("Decompressing '%s' (%d -> %d)\n", fname, gsize, size);
callinflate(unpack, gzdata, inflatestack);
*sizep = size;
}
if (!p) {
p = calloc(1, size);
if (!p) {
- printf("Couldn't allocate %ld bytes, file '%s'\n", size, fname);
+ printf("Couldn't allocate %d bytes, file '%s'\n", size, fname);
exit(0);
}
}
size2 = size;
uae_u8 *tmp = malloc(size2);
if (!tmp) {
- printf("Couldn't allocate safe tmp memory (%ld bytes)\n", size2);
+ printf("Couldn't allocate safe tmp memory (%d bytes)\n", size2);
exit(0);
}
readdata(tmp, size2, f, unpack, &unpackoffset);
}
if (*sizep != size) {
end:
- printf("Couldn't read file '%s' (%ld <> %ld)\n", fname, *sizep, size);
+ printf("Couldn't read file '%s' (%d <> %d)\n", fname, *sizep, size);
exit(0);
}
if (f) {
uae_u8 v = *p;
if (v & CT_END) {
end_test();
- printf("Unexpected end bit!? offset %ld\n", p - test_data);
+ printf("Unexpected end bit!? offset %d\n", p - test_data);
endinfo();
exit(0);
}
static void addinfo_bytes(char *name, uae_u8 *src, uae_u32 address, int offset, int len)
{
- sprintf(outbp, "%s %08lx ", name, address);
+ sprintf(outbp, "%s %08x ", name, address);
address += offset;
outbp += strlen(outbp);
int cnt = 0;
while (lines++ < 5) {
int v = 0;
if (!is_valid_test_addr_read((uae_u32)p) || !is_valid_test_addr_read((uae_u32)p + 1)) {
- sprintf(outbp, "%08lx -- INACCESSIBLE --\n", p);
+ sprintf(outbp, "%08x -- INACCESSIBLE --\n", (uae_u32)p);
outbp += strlen(outbp);
break;
}
tmpbuffer[0] = 0;
if (!(((uae_u32)code) & 1)) {
v = disasm_instr(code + offset, tmpbuffer, cpu_lvl);
- sprintf(outbp, "%08lx ", p);
+ sprintf(outbp, "%08x ", (uae_u32)p);
outbp += strlen(outbp);
for (int i = 0; i < v; i++) {
uae_u16 v = (p[i * 2 + 0] << 8) | (p[i * 2 + 1]);
v--;
}
} else {
- sprintf(outbp, "%08lx %02x\n", code, *((uae_u8*)code));
+ sprintf(outbp, "%08x %02x\n", (uae_u32)code, *((uae_u8*)code));
code = (uae_u16*)(((uae_u32)code) + 1);
p++;
outbp += strlen(outbp);
uae_u8 *b = (uae_u8 *)regs.branchtarget - SIZE_STORED_ADDRESS_OFFSET;
addinfo_bytes("B", b, regs.branchtarget, -SIZE_STORED_ADDRESS_OFFSET, SIZE_STORED_ADDRESS);
}
-// sprintf(outbp, "STARTPC=%08lx ENDPC=%08lx\n", startpc, endpc);
+// sprintf(outbp, "STARTPC=%08x ENDPC=%08x\n", startpc, endpc);
// outbp += strlen(outbp);
}
strcat(outbp, " ");
}
outbp += strlen(outbp);
- sprintf(outbp, "%c%d:%c%08lx", i < 8 ? 'D' : 'A', i & 7, test_regs.regs[i] != last_registers.regs[i] ? '*' : ' ', r->regs[i]);
+ sprintf(outbp, "%c%d:%c%08x", i < 8 ? 'D' : 'A', i & 7, test_regs.regs[i] != last_registers.regs[i] ? '*' : ' ', r->regs[i]);
outbp += strlen(outbp);
}
*outbp++ = '\n';
- sprintf(outbp, "SR:%c%04x PC: %08lx ISP: %08lx", test_sr != last_registers.sr ? '*' : ' ', test_sr, r->pc, r->ssp);
+ sprintf(outbp, "SR:%c%04x PC: %08x ISP: %08x", test_sr != last_registers.sr ? '*' : ' ', test_sr, r->pc, r->ssp);
} else {
// output only lines that have at least one modified register to save screen space
for (int i = 0; i < 4; i++) {
int idx = i * 4 + j;
if (j > 0)
*outbp++ = ' ';
- sprintf(outbp, "%c%d:%c%08lx", idx < 8 ? 'D' : 'A', idx & 7, test_regs.regs[idx] != last_registers.regs[idx] ? '*' : ' ', test_regs.regs[idx]);
+ sprintf(outbp, "%c%d:%c%08x", idx < 8 ? 'D' : 'A', idx & 7, test_regs.regs[idx] != last_registers.regs[idx] ? '*' : ' ', test_regs.regs[idx]);
outbp += strlen(outbp);
}
*outbp++ = '\n';
}
}
- sprintf(outbp, "SR:%c%04x/%04x PC: %08lx ISP: %08lx", test_sr != last_registers.sr ? '*' : ' ', test_regs.sr, test_regs.expsr, r->pc, r->ssp);
+ sprintf(outbp, "SR:%c%04x/%04x PC: %08x ISP: %08x", test_sr != last_registers.sr ? '*' : ' ', test_regs.sr, test_regs.expsr, r->pc, r->ssp);
}
outbp += strlen(outbp);
if (cpu_lvl >= 2 && cpu_lvl <= 4) {
- sprintf(outbp, " MSP: %08lx", r->msp);
+ sprintf(outbp, " MSP: %08x", r->msp);
outbp += strlen(outbp);
}
*outbp++ = '\n';
struct fpureg *f = &r->fpuregs[i];
void *f1 = ®s.fpuregs[i];
void *f2 = &test_regs.fpuregs[i];
- sprintf(outbp, "FP%d:%c%04x-%08lx%08lx %f",
+ sprintf(outbp, "FP%d:%c%04x-%08x%08x %f",
i,
memcmp(f1, f2, sizeof(struct fpureg)) ? '*' : ' ',
f->exp, f->m[0], f->m[1],
*((long double*)f));
outbp += strlen(outbp);
}
- sprintf(outbp, "\nFPSR:%c%08lx FPCR:%c%08lx FPIAR:%c%08lx\n",
+ sprintf(outbp, "\nFPSR:%c%08x FPCR:%c%08x FPIAR:%c%08x\n",
test_fpsr != test_regs.fpsr ? '*' : ' ', before ? test_fpsr : r->fpsr,
test_fpcr != test_regs.fpcr ? '*' : ' ', before ? test_fpcr : r->fpcr,
regs.fpiar != test_regs.fpiar ? '*' : ' ', r->fpiar);
}
uae_u32 retv = exceptiontableinuse + (excnum - 2) * 2;
if (ret != retv) {
- sprintf(outbp, "Trace (%d stacked) PC mismatch: %08lx != %08lx\n", excnum, ret, retv);
+ sprintf(outbp, "Trace (%d stacked) PC mismatch: %08x != %08x\n", excnum, ret, retv);
outbp += strlen(outbp);
*experr = 1;
}
v = opcode_memory_addr;
p = restore_rel_ordered(p, &v);
if (vsr != sr) {
- sprintf(outbp, "Trace (non-stacked) SR mismatch: %04x != %04x (PC=%08lx)\n", sr, vsr, v);
+ sprintf(outbp, "Trace (non-stacked) SR mismatch: %04x != %04x (PC=%08x)\n", sr, vsr, v);
outbp += strlen(outbp);
*experr = 1;
}
if (v != ret) {
- sprintf(outbp, "Trace (non-stacked) PC mismatch: %08lx != %08lx (SR=%04x)\n", ret, v, vsr);
+ sprintf(outbp, "Trace (non-stacked) PC mismatch: %08x != %08x (SR=%04x)\n", ret, v, vsr);
outbp += strlen(outbp);
*experr = 1;
}
if (regs->tracecnt > 0) {
uae_u32 ret = (regs->tracedata[1] << 16) | regs->tracedata[2];
uae_u16 sr = regs->tracedata[0];
- sprintf(outbp, "Got unexpected trace exception: SR=%04x PC=%08lx.\n", sr, ret);
+ sprintf(outbp, "Got unexpected trace exception: SR=%04x PC=%08x.\n", sr, ret);
outbp += strlen(outbp);
if (excnum >= 2) {
- sprintf(outbp, "Exception %ld also pending.\n", excnum);
+ sprintf(outbp, "Exception %d also pending.\n", excnum);
outbp += strlen(outbp);
}
*experr = 1;
alternate_exception3[24] = p[0];
alternate_exception3[25] = p[1];
if (excnum == 2 || !is_valid_test_addr_readwrite(fault_addr - 4) || !is_valid_test_addr_readwrite(fault_addr + 4)) {
- // bus error read: cpu may still the data, depends on hardware.
+ // bus error read: cpu may still read the data, depends on hardware.
// ignore input buffer contents
mask_exception = 1;
memset(masked_exception, 0, sizeof(masked_exception));
}
}
if (err) {
- sprintf(outbp, "Exception %ld stack frame mismatch:\n", excnum);
+ sprintf(outbp, "Exception %d stack frame mismatch:\n", excnum);
outbp += strlen(outbp);
strcpy(outbp, "Expected: ");
outbp += strlen(outbp);
}
#ifdef AMIGA
+// 7MHz 68000 PAL A500 only!
static int get_cycles_amiga(void)
{
- // 7MHz 68000 PAL A500 only!
uae_u16 vstart = (test_regs.cycles >> 24) & 0xff;
uae_u16 vend = (test_regs.cycles >> 8) & 0xff;
uae_u16 hstart = (test_regs.cycles >> 16) & 0xff;
gotcycles = (test_regs.cycles & 0xffff) - (test_regs.cycles >> 16);
if (gotcycles == 0) {
end_test();
- printf("Cycle counter hardware address %lx returned zero.\n", cyclecounter_addr);
+ printf("Cycle counter hardware address 0x%08x returned zero cycles.\n", cyclecounter_addr);
exit(0);
}
} else {
if (0 || abs(gotcycles - expectedcycles) > cycles_range) {
addinfo();
- sprintf(outbp, "Got %ld cycles but expected %ld cycles (%08x %08x)\n", gotcycles, expectedcycles, test_regs.cycles, test_regs.cycles2);
+ sprintf(outbp, "Got %d cycles (%d + %d) but expected %d (%d + %d) cycles\n",
+ gotcycles, gotcycles - exceptioncycles, exceptioncycles,
+ expectedcycles, expectedcycles - exceptioncycles, exceptioncycles);
outbp += strlen(outbp);
return 0;
}
p++;
if ((v & CT_END_INIT) == CT_END_INIT) {
end_test();
- printf("Unexpected CT_END_INIT %02x %08lx\n", v, p - test_data);
+ printf("Unexpected CT_END_INIT %02x %08x\n", v, p - test_data);
endinfo();
exit(0);
}
if (exc == 0 && cpuexc == 4) {
// successful complete generates exception 4 with matching PC
if (last_registers.pc != test_regs.pc && dooutput) {
- sprintf(outbp, "PC: expected %08lx but got %08lx\n", last_registers.pc, test_regs.pc);
+ sprintf(outbp, "PC: expected %08x but got %08x\n", last_registers.pc, test_regs.pc);
outbp += strlen(outbp);
errflag |= 1 << 16;
}
if (val != test_regs.regs[mode] && !ignore_errors) {
addinfo();
if (dooutput) {
- sprintf(outbp, "%c%d: expected %08lx but got %08lx\n", mode < CT_AREG ? 'D' : 'A', mode & 7, val, test_regs.regs[mode]);
+ sprintf(outbp, "%c%d: expected %08x but got %08x\n", mode < CT_AREG ? 'D' : 'A', mode & 7, val, test_regs.regs[mode]);
outbp += strlen(outbp);
}
errflag |= 1 << 0;
if (memcmp(&val, &test_regs.fpuregs[mode], sizeof(struct fpureg)) && !ignore_errors) {
addinfo();
if (dooutput) {
- sprintf(outbp, "FP%d: expected %04x-%08lx%08lx but got %04x-%08lx%08lx\n", mode,
+ sprintf(outbp, "FP%d: expected %04x-%08x%08x but got %04x-%08x%08x\n", mode,
val.exp, val.m[0], val.m[1],
test_regs.fpuregs[mode].exp, test_regs.fpuregs[mode].m[0], test_regs.fpuregs[mode].m[1]);
outbp += strlen(outbp);
if (val != test_regs.fpcr && !ignore_errors) {
addinfo();
if (dooutput) {
- sprintf(outbp, "FPCR: expected %08lx -> %08lx but got %08lx\n", test_fpcr, val, test_regs.fpcr);
+ sprintf(outbp, "FPCR: expected %08x -> %08x but got %08x\n", test_fpcr, val, test_regs.fpcr);
outbp += strlen(outbp);
}
errflag |= 1 << 3;
if (val != test_regs.fpsr && !ignore_errors) {
addinfo();
if (dooutput) {
- sprintf(outbp, "FPSR: expected %08lx -> %08lx but got %08lx\n", test_fpsr, val, test_regs.fpsr);
+ sprintf(outbp, "FPSR: expected %08x -> %08x but got %08x\n", test_fpsr, val, test_regs.fpsr);
outbp += strlen(outbp);
}
errflag |= 1 << 4;
if (mval != val && !ignore_errors) {
addinfo();
if (dooutput) {
- sprintf(outbp, "Memory byte write: address %08lx, expected %02x but got %02x\n", (uae_u32)addr, val, mval);
+ sprintf(outbp, "Memory byte write: address %08x, expected %02x but got %02x\n", (uae_u32)addr, val, mval);
outbp += strlen(outbp);
}
errflag |= 1 << 6;
if (mval != val && !ignore_errors) {
addinfo();
if (dooutput) {
- sprintf(outbp, "Memory word write: address %08lx, expected %04x but got %04x\n", (uae_u32)addr, val, mval);
+ sprintf(outbp, "Memory word write: address %08x, expected %04x but got %04x\n", (uae_u32)addr, val, mval);
outbp += strlen(outbp);
}
errflag |= 1 << 6;
if (mval != val && !ignore_errors) {
addinfo();
if (dooutput) {
- sprintf(outbp, "Memory long write: address %08lx, expected %08lx but got %08x\n", (uae_u32)addr, val, mval);
+ sprintf(outbp, "Memory long write: address %08x, expected %08x but got %08x\n", (uae_u32)addr, val, mval);
outbp += strlen(outbp);
}
errflag |= 1 << 6;
if (regs_changed[i]) {
addinfo();
if (dooutput) {
- sprintf(outbp, "%c%d: modified %08lx -> %08lx but expected no modifications\n", i < 8 ? 'D' : 'A', i & 7, last_registers.regs[i], test_regs.regs[i]);
+ sprintf(outbp, "%c%d: modified %08x -> %08x but expected no modifications\n", i < 8 ? 'D' : 'A', i & 7, last_registers.regs[i], test_regs.regs[i]);
outbp += strlen(outbp);
}
errflag |= 1 << 0;
if (regs_fpuchanged[i]) {
addinfo();
if (dooutput) {
- sprintf(outbp, "FP%d: modified %04x-%08lx%08lx -> %04x-%08lx%08lx but expected no modifications\n", i,
+ sprintf(outbp, "FP%d: modified %04x-%08x%08x -> %04x-%08x%08x but expected no modifications\n", i,
last_registers.fpuregs[i].exp, last_registers.fpuregs[i].m[0], last_registers.fpuregs[i].m[1],
test_regs.fpuregs[i].exp, test_regs.fpuregs[i].m[0], test_regs.fpuregs[i].m[1]);
outbp += strlen(outbp);
outbp += strlen(outbp);
}
} else {
- if (!check_cycles(exc)) {
+ if (!check_cycles(exc, extratrace)) {
errflag |= 1 << 8;
}
}
if (testexit()) {
end_test();
- printf("\nAborted (%ld)\n", testcnt);
+ printf("\nAborted (%d)\n", testcnt);
exit(0);
}
lvl2 = 4;
if (lvl != lvl2) {
- printf("Mismatched CPU model: %lu <> %lu\n",
+ printf("Mismatched CPU model: %u <> %u\n",
68000 + 10 * (cpu_lvl < 5 ? cpu_lvl : 6), 68000 + (lvl < 5 ? lvl : 6) * 10);
return 0;
}
if (!absallocated) {
test_memory = allocate_absolute(test_memory_addr, test_memory_size);
if (!test_memory) {
- printf("Couldn't allocate tmem area %08lx-%08lx\n", (uae_u32)test_memory_addr, test_memory_size);
+ printf("Couldn't allocate tmem area %08x-%08x\n", (uae_u32)test_memory_addr, test_memory_size);
exit(0);
}
absallocated = test_memory;
exit(0);
}
- printf("CPUlvl=%d, Mask=%08lx Code=%08lx SP=%08lx ISP=%08lx\n",
- cpu_lvl, addressing_mask, opcode_memory,
+ printf("CPUlvl=%d, Mask=%08x Code=%08x SP=%08x ISP=%08x\n",
+ cpu_lvl, addressing_mask, (uae_u32)opcode_memory,
user_stack_memory, super_stack_memory);
- printf(" Low: %08lx-%08lx High: %08lx-%08lx\n",
+ printf(" Low: %08x-%08x High: %08x-%08x\n",
test_low_memory_start, test_low_memory_end,
test_high_memory_start, test_high_memory_end);
- printf("Test: %08lx-%08lx Safe: %08lx-%08lx\n",
+ printf("Test: %08x-%08x Safe: %08x-%08x\n",
test_memory_addr, test_memory_end,
- safe_memory_start, safe_memory_end);
+ (uae_u32)safe_memory_start, (uae_u32)safe_memory_end);
printf("%s (%s):\n", inst_name, group);
testcnt = 0;
supercnt = 0;
for (;;) {
- printf("%s (%s). %lu...\n", tfname, group, testcnt);
+ printf("%s (%s). %u...\n", tfname, group, testcnt);
- sprintf(tfname, "%s/%04ld.dat", opcode, filecnt);
+ sprintf(tfname, "%s/%04d.dat", opcode, filecnt);
test_data_size = -1;
test_data = load_file(path, tfname, NULL, &test_data_size, 0, 1);
filecnt++;
}
- printf("%lu ", testcnt);
- printf("S=%ld", supercnt);
+ printf("%u ", testcnt);
+ printf("S=%d", supercnt);
for (int i = 0; i < 128; i++) {
if (exceptioncount[0][i] || exceptioncount[1][i] || exceptioncount[2][i]) {
if (i == 2 || i == 3) {
- printf(" E%02d=%ld/%ld/%ld", i, exceptioncount[0][i], exceptioncount[1][i], exceptioncount[2][i]);
+ printf(" E%02d=%d/%d/%d", i, exceptioncount[0][i], exceptioncount[1][i], exceptioncount[2][i]);
} else {
- printf(" E%02d=%ld", i, exceptioncount[0][i]);
+ printf(" E%02d=%d", i, exceptioncount[0][i]);
}
}
}
printf("\n");
if (!errors && !quit) {
- printf("All tests complete (total %lu).\n", testcnt);
+ printf("All tests complete (total %u).\n", testcnt);
}
return errors || quit;
for (int i = 1; i < argc; i++) {
char *s = argv[i];
- char *next = i + 1 < argc ? argv[i + 1] : NULL;
+ char *next = i + 1 < argc && argv[i + 1][0] != '-' ? argv[i + 1] : NULL;
if (s[0] != '-' && opcode[0] == 0 && strlen(s) < sizeof(opcode) - 1) {
strcpy(opcode, s);
continue;
}
} else if (!_stricmp(s, "-cycles")) {
cycles = 1;
- if (i + 1 < argc) {
+ if (i + 1 < argc && argv[i][0] != '-') {
i++;
cycles_range = atoi(argv[i]);
- if (i + 1 < argc) {
+ if (i + 1 < argc && argv[i][0] != '-') {
i++;
cycles_adjust = atoi(argv[i]);
}
if(cyclecounter_addr != 0xffffffff) {
// yes, this is far too ugly
extern uae_u32 cyclereg_address1;
- extern uae_u32 *cyclereg_address2;
- extern uae_u32 *cyclereg_address3;
- extern uae_u32 *cyclereg_address4;
- extern uae_u32 *cyclereg_address5;
- extern uae_u32 *cyclereg_address6;
+ extern uae_u32 cyclereg_address2;
+ extern uae_u32 cyclereg_address3;
+ extern uae_u32 cyclereg_address4;
+ extern uae_u32 cyclereg_address5;
+ extern uae_u32 cyclereg_address6;
*((uae_u32*)((uae_u32)(&cyclereg_address1) + 2)) = cyclecounter_addr;
*((uae_u32*)((uae_u32)(&cyclereg_address2) + 2)) = cyclecounter_addr;
*((uae_u32*)((uae_u32)(&cyclereg_address3) + 2)) = cyclecounter_addr;
}
int cpumodel = 68000 + (cpu_lvl == 5 ? 6 : cpu_lvl) * 10;
- sprintf(cpustr, "%lu_", cpumodel);
+ sprintf(cpustr, "%u_", cpumodel);
char *pathptr = path + strlen(path);
for (;;) {
sprintf(pathptr, "%s/", groupdr->d_name);
strcpy(group, groupdr->d_name + strlen(cpustr));
} else {
- sprintf(pathptr, "%lu_%s/",cpumodel, group);
+ sprintf(pathptr, "%u_%s/",cpumodel, group);
}
low_memory_size = -1;