cleanup things, stop trying with CS
This commit is contained in:
parent
7687c2b7d2
commit
b58f315c98
@ -237,6 +237,7 @@ struct ComLoader : public DosLoader {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#if 0
|
||||||
struct RomLoader {
|
struct RomLoader {
|
||||||
bool canLoad(QFile &fp) {
|
bool canLoad(QFile &fp) {
|
||||||
fp.seek(0xFFF0);
|
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 {
|
struct ExeLoader : public DosLoader {
|
||||||
bool canLoad(QFile &fp) {
|
bool canLoad(QFile &fp) {
|
||||||
if(fp.size()<sizeof(header))
|
if(fp.size()<sizeof(header))
|
||||||
|
|||||||
@ -202,12 +202,7 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
|
|||||||
}
|
}
|
||||||
StCopy = *pstate;
|
StCopy = *pstate;
|
||||||
|
|
||||||
if (pstate->IP > 0x100000)
|
//printf("From %X condJump to %X\n", lastIp, pstate->IP);
|
||||||
{
|
|
||||||
printf("Something wrong with IP...\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("From %X condJump to %X\n", lastIp, pstate->IP);
|
|
||||||
|
|
||||||
/* Straight line code */
|
/* Straight line code */
|
||||||
this->FollowCtrl (pcallGraph, &StCopy); // recurrent ?
|
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();
|
pstate->IP = pIcode.ll()->src().getImm2();
|
||||||
|
|
||||||
if (pstate->IP == 0)
|
//printf("From seg:%04X JMP(F) to %X\n", lastIp, pstate->IP);
|
||||||
{
|
|
||||||
printf("debug...\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Need to use CS! */
|
if (pstate->IP == 0xFFFF0)
|
||||||
if ((pIcode.ll()->getOpcode() != iJMPF) && (pIcode.ll()->getOpcode() != iJMP))
|
|
||||||
{
|
{
|
||||||
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();
|
int64_t i = pIcode.ll()->src().getImm2();
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
@ -808,20 +789,12 @@ bool Function::process_CALL(ICODE & pIcode, CALL_GRAPH * pcallGraph, STATE *psta
|
|||||||
if (pIcode.ll()->getOpcode() == iCALLF)
|
if (pIcode.ll()->getOpcode() == iCALLF)
|
||||||
pstate->setState( rCS, LH(prog.image() + pIcode.ll()->label + 3));
|
pstate->setState( rCS, LH(prog.image() + pIcode.ll()->label + 3));
|
||||||
|
|
||||||
/* Need to use CS! */
|
|
||||||
pstate->IP += pstate->r[rCS] << 4;
|
|
||||||
|
|
||||||
x.state = *pstate;
|
x.state = *pstate;
|
||||||
|
|
||||||
/* Insert new procedure in call graph */
|
/* Insert new procedure in call graph */
|
||||||
- pcallGraph->insertCallGraph (this, iter);
|
- pcallGraph->insertCallGraph (this, iter);
|
||||||
|
|
||||||
if (pstate->IP > 0x100000)
|
//printf("From %X CALL to %X\n", lastIp, pstate->IP);
|
||||||
{
|
|
||||||
printf("Something wrong with IP (was %x)...\n", lastIp);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("From %X CALL to %X\n", lastIp, pstate->IP);
|
|
||||||
|
|
||||||
/* Process new procedure */
|
/* Process new procedure */
|
||||||
x.FollowCtrl (pcallGraph, pstate);
|
x.FollowCtrl (pcallGraph, pstate);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user