diff --git a/include/instructions.h b/include/instructions.h index 65c3508..8e81bff 100644 --- a/include/instructions.h +++ b/include/instructions.h @@ -136,5 +136,6 @@ public: void or_rm32_imm(int imm_flag); void adc_rm32_imm(int imm_flag); void sbb_rm32_imm(int imm_flag); + void and_rm32_imm(int imm_flag); void cmp_rm32_imm8(); }; diff --git a/instructions.cpp b/instructions.cpp index eb36fe9..a5dc016 100644 --- a/instructions.cpp +++ b/instructions.cpp @@ -484,7 +484,7 @@ void Instructions::opcode_81(){ sbb_rm32_imm(IMM32); break; case 4: - // TODO: and_rm32_imm32(); + and_rm32_imm(IMM32); break; case 5: // TODO: sub_rm32_imm32(); @@ -520,7 +520,7 @@ void Instructions::opcode_83(){ sbb_rm32_imm(IMM8); break; case 4: - // TODO: and_rm32_imm8(); + and_rm32_imm(IMM8); break; case 5: // TODO: sub_rm32_imm8(); @@ -856,6 +856,24 @@ void Instructions::sbb_rm32_imm(int imm_flag){ this->eip++; } +void Instructions::and_rm32_imm(int imm_flag){ + //printf("and_rm32_imm called.\n"); + + this->eip++; + + if(imm_flag == IMM8){ + uint8_t imm8 = memory.read_uint8(this->eip); + this->registers[this->M] &= imm8; + } else if(imm_flag == IMM32){ + uint32_t imm32 = memory.read_uint32(this->eip); + imm32 = swap_endian32(imm32); + this->registers[this->M] &= imm32; + } else { + } + + this->eip++; +} + void Instructions::cmp_rm32_imm8(){ //printf("cmp_rm32_imm8 called.\n");