cleanup things, stop trying with CS

This commit is contained in:
Godzil 2018-09-19 17:59:25 +01:00
parent 7687c2b7d2
commit b58f315c98
2 changed files with 58 additions and 35 deletions

View File

@ -237,6 +237,7 @@ struct ComLoader : public DosLoader {
return true;
}
};
#if 0
struct RomLoader {
bool canLoad(QFile &fp) {
fp.seek(0xFFF0);
@ -301,6 +302,55 @@ protected:
}
}
};
#else
struct RomLoader {
bool canLoad(QFile &fp) {
fp.seek(0xFFF0);
uint8_t sig[1];
if(fp.read((char *)sig,1) == 1)
{
return (sig[0] == 0xEA);
}
return false;
}
bool load(PROG &prog,QFile &fp) {
fp.seek(0);
/* COM file
* In this case the load module size is just the file length
*/
auto cb = fp.size();
/* COM programs start off with an ORG 100H (to leave room for a PSP)
* This is also the implied start address so if we load the image
* at offset 100H addresses should all line up properly again.
*/
prog.initCS = 0;
prog.initIP = 0x000;
prog.initSS = 0;
prog.initSP = 0xFFFE;
prog.cReloc = 0;
prepareImage(prog, cb, fp);
/* Set up memory map */
cb = (prog.cbImage + 3) / 4;
prog.map = (uint8_t *)malloc(cb);
memset(prog.map, BM_UNKNOWN, (size_t)cb);
return true;
}
protected:
void prepareImage(PROG &prog, size_t sz, QFile &fp)
{
/* Allocate a block of memory for the program. */
prog.cbImage = sz;
prog.Imagez = new uint8_t[prog.cbImage];
if (sz != fp.read((char *)prog.Imagez, sz))
fatalError(CANNOT_READ, fp.fileName().toLocal8Bit().data());
}
};
#endif
struct ExeLoader : public DosLoader {
bool canLoad(QFile &fp) {
if(fp.size()<sizeof(header))

View File

@ -202,12 +202,7 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
}
StCopy = *pstate;
if (pstate->IP > 0x100000)
{
printf("Something wrong with IP...\n");
}
printf("From %X condJump to %X\n", lastIp, pstate->IP);
//printf("From %X condJump to %X\n", lastIp, pstate->IP);
/* Straight line code */
this->FollowCtrl (pcallGraph, &StCopy); // recurrent ?
@ -566,29 +561,15 @@ bool Function::process_JMP (ICODE & pIcode, STATE *pstate, CALL_GRAPH * pcallGra
pstate->IP = pIcode.ll()->src().getImm2();
if (pstate->IP == 0)
{
printf("debug...\n");
}
//printf("From seg:%04X JMP(F) to %X\n", lastIp, pstate->IP);
/* Need to use CS! */
if ((pIcode.ll()->getOpcode() != iJMPF) && (pIcode.ll()->getOpcode() != iJMP))
if (pstate->IP == 0xFFFF0)
{
printf("debug\n");
/* Nasty (wrong) trick use to reset, consider it as terminating */
pIcode.ll()->setFlags(TERMINATES);
pstate->setState( rCS, 0);
pstate->IP = 0;
}
if (pstate->IP > 0x10000)
{
printf("debug\n");
}
pstate->IP += pstate->r[rCS] << 4;
if (pstate->IP > 0x100000)
{
printf("Something wrong with IP (was %x)...\n", lastIp);
}
printf("From %X JMP(F) to %X\n", lastIp, pstate->IP);
int64_t i = pIcode.ll()->src().getImm2();
if (i < 0)
@ -808,20 +789,12 @@ bool Function::process_CALL(ICODE & pIcode, CALL_GRAPH * pcallGraph, STATE *psta
if (pIcode.ll()->getOpcode() == iCALLF)
pstate->setState( rCS, LH(prog.image() + pIcode.ll()->label + 3));
/* Need to use CS! */
pstate->IP += pstate->r[rCS] << 4;
x.state = *pstate;
/* Insert new procedure in call graph */
- pcallGraph->insertCallGraph (this, iter);
if (pstate->IP > 0x100000)
{
printf("Something wrong with IP (was %x)...\n", lastIp);
}
printf("From %X CALL to %X\n", lastIp, pstate->IP);
//printf("From %X CALL to %X\n", lastIp, pstate->IP);
/* Process new procedure */
x.FollowCtrl (pcallGraph, pstate);