Add leave(0xc9) instruction

This commit is contained in:
tuz358
2018-03-06 15:51:11 +09:00
parent d9e09da12b
commit 21cfae7d29
2 changed files with 11 additions and 0 deletions

View File

@@ -91,6 +91,7 @@ public:
void mov_ebp_imm32(); // 0xbd void mov_ebp_imm32(); // 0xbd
void mov_esi_imm32(); // 0xbe void mov_esi_imm32(); // 0xbe
void mov_edi_imm32(); // 0xbf void mov_edi_imm32(); // 0xbf
void leave(); // 0xc9
void call_imm32(); // 0xe8 void call_imm32(); // 0xe8
void jmp_imm8(); // 0xeb void jmp_imm8(); // 0xeb
void hlt(); // 0xf4 void hlt(); // 0xf4

View File

@@ -87,6 +87,7 @@ void Instructions::init_instructions(){
this->instructions[0xbd] = &Instructions::mov_ebp_imm32; this->instructions[0xbd] = &Instructions::mov_ebp_imm32;
this->instructions[0xbe] = &Instructions::mov_esi_imm32; this->instructions[0xbe] = &Instructions::mov_esi_imm32;
this->instructions[0xbf] = &Instructions::mov_edi_imm32; this->instructions[0xbf] = &Instructions::mov_edi_imm32;
this->instructions[0xc9] = &Instructions::leave;
this->instructions[0xe8] = &Instructions::call_imm32; this->instructions[0xe8] = &Instructions::call_imm32;
this->instructions[0xeb] = &Instructions::jmp_imm8; this->instructions[0xeb] = &Instructions::jmp_imm8;
this->instructions[0xf4] = &Instructions::hlt; this->instructions[0xf4] = &Instructions::hlt;
@@ -1063,6 +1064,15 @@ void Instructions::mov_edi_imm32(){
this->eip += 4; this->eip += 4;
} }
void Instructions::leave(){
//printf("leave called.\n");
// mov esp, ebp
this->registers[4] = this->registers[5];
// pop ebp
this->pop_ebp();
}
void Instructions::call_imm32(){ void Instructions::call_imm32(){
//printf("call_imm32 called.\n"); //printf("call_imm32 called.\n");