1
0
mirror of https://github.com/simh/simh.git synced 2026-02-27 01:00:07 +00:00

3b2: Improved sim_load procedure

The previous implementation of sim_load was riddled with little errors.
This change fixes those errors, improves user feedback, and limits the
allowable flags to '-r' and '-o'.
This commit is contained in:
Seth Morabito
2022-11-08 09:49:02 -08:00
committed by Mark Pizzolato
parent 9b3f1c9d2e
commit b145541121

View File

@@ -68,21 +68,26 @@ t_stat sim_load(FILE *fileref, CONST char *cptr, CONST char *fnam, int flag)
int32 cnt = 0;
if (flag) {
return sim_messagef(SCPE_NOFNC, "Command not implemented.");
return sim_messagef(SCPE_NOFNC, "Command not implemented.\n");
}
if (sim_switches & SWMASK('R')) {
origin = ROM_BASE;
limit = ROM_BASE + ROM_SIZE;
} else {
origin = 0;
limit = (uint32) cpu_unit.capac;
if (sim_switches & SWMASK('O')) {
origin = (uint32) get_uint(cptr, 16, 0xffffffff, &r);
if (r != SCPE_OK) {
return SCPE_ARG;
}
origin = ROM_BASE;
} else if (sim_switches & SWMASK('O')) {
limit = PHYS_MEM_BASE + (uint32) cpu_unit.capac;
origin = (uint32) get_uint(cptr, 16, 0xffffffff, &r);
if (r != SCPE_OK) {
return SCPE_ARG;
}
if (origin < PHYS_MEM_BASE) {
return sim_messagef(SCPE_ARG,
"Address not in RAM.\n");
}
} else {
return sim_messagef(SCPE_ARG,
"Flag not understood. Use -r to load ROM "
"or -o to load RAM.\n");
}
while ((i = Fgetc (fileref)) != EOF) {
@@ -100,12 +105,10 @@ t_stat sim_load(FILE *fileref, CONST char *cptr, CONST char *fnam, int flag)
if (sim_switches & SWMASK('R')) {
rom_loaded = TRUE;
sim_messagef(SCPE_OK, "%d bytes loaded into ROM\n", cnt);
return sim_messagef(SCPE_OK, "%d bytes loaded into ROM\n", cnt);
} else {
sim_messagef(SCPE_OK, "%d bytes loaded at address 0x%08x\n", cnt, origin - cnt);
return sim_messagef(SCPE_OK, "%d bytes loaded at address 0x%08x\n", cnt, origin - cnt);
}
return SCPE_OK;
}
t_stat parse_sym(CONST char *cptr, t_addr exta, UNIT *uptr, t_value *val, int32 sw)