Mise à jour du code à chaque itération

This commit is contained in:
Horde Nicolas 2021-07-11 16:34:50 +02:00
parent 73df49a5ba
commit d52a76a88e
3 changed files with 25 additions and 18 deletions

View File

@ -679,23 +679,24 @@ uint32_t VMEngine::getNextInstr()
std::vector<std::array<std::string, 5>> VMEngine::getInstr(int segment, int address,int size) std::vector<std::array<std::string, 5>> VMEngine::getInstr(int segment, int address,int size)
{ {
uint32_t realaddress=segment*16+address; uint32_t realaddress=segment*16+address;
bool changed=false;
if (realaddress<bufferaddress || realaddress+(size*7)>bufferaddress+500) if (realaddress<bufferaddress || realaddress+(size*7)>bufferaddress+500)
{ {
changed=true; log->append("read");
int begin=realaddress-30; bufferaddress=realaddress-30;
if (begin<0) begin=0x00000000; if (bufferaddress<0)
err = uc_mem_read(uc, begin, code, 500); bufferaddress=0x00000000;
address_old=address-30;
if (address_old<0)
address_old=0x00000000;
}
err = uc_mem_read(uc, bufferaddress, code, 500);
if (err) if (err)
{
throw Error("VM IA86 - cache instructions......................[ERREUR]"); throw Error("VM IA86 - cache instructions......................[ERREUR]");
}
bufferaddress=begin;
}
crc = crc32(0, code, 500); crc = crc32(0, code, 500);
if (crc != crc_old || changed) if (crc != crc_old)
{ {
unasmer.Desassemble(code, address, 500, &unasm); log->append("unasm");
unasmer.Desassemble(code, address_old, 500, &unasm);
if (unasm.src.size()==0) if (unasm.src.size()==0)
throw Error("VM IA86 - cache instructions......................[ERREUR]"); throw Error("VM IA86 - cache instructions......................[ERREUR]");
crc_old=crc; crc_old=crc;
@ -739,6 +740,7 @@ void VMEngine::Configure(State *init, std::string code)
return; return;
Close(); Close();
Init(); Init();
bufferaddress=-666;
this->initialized=false; this->initialized=false;
this->executed=false; this->executed=false;
//log->append("Mappage de la mémoire virtuelle"); //log->append("Mappage de la mémoire virtuelle");

2
ia86.h
View File

@ -327,7 +327,7 @@ class VMEngine
bool initialized=false; bool initialized=false;
uc_engine *uc; uc_engine *uc;
uc_err err; uc_err err;
int bufferaddress=-555; int bufferaddress;
int address_old; int address_old;
uint8_t *code; uint8_t *code;
uLong crc,crc_old; uLong crc,crc_old;

View File

@ -8,8 +8,13 @@
"niveau_tutoriel" : "Ceci vous...", "niveau_tutoriel" : "Ceci vous...",
"niveau_code" : "mov ax,0x545 "niveau_code" : "mov ax,0x545
inc dx inc dx
mov esi,0x44441234 mov esi,0x44440234
hlt", hlt
.org 0x8D
mov es,ax
.org 0x14D
mov es,ax
",
"niveau_droits" : 10, "niveau_droits" : 10,
"niveau_initial" : "niveau_initial" :
{ {