mirror of
https://github.com/zoriya/dasm.git
synced 2026-08-15 18:44:40 +00:00
Implement lea
This commit is contained in:
+1
-1
@@ -149,7 +149,7 @@ const instruction_t instructions[] = {
|
||||
{.opcode = 0x8A, .extended = -1, .name = "mov", .mode = {REG8, R_M8, END}, .exec = &mov},
|
||||
{.opcode = 0x8B, .extended = -1, .name = "mov", .mode = {REG16, R_M16, END}, .exec = &mov},
|
||||
// {.opcode = 0x8C, .extended = -1, .name = "mov", .mode = {R_M16, sreg, END}, .exec = &mov},
|
||||
{.opcode = 0x8D, .extended = -1, .name = "lea", .mode = {REG16, R_M16, END}, .exec = NULL},
|
||||
{.opcode = 0x8D, .extended = -1, .name = "lea", .mode = {REG16, R_M16, END}, .exec = &lea},
|
||||
// {.opcode = 0x8E, .extended = -1, .name = "mov", .mode = {sreg, R_M16, END}, .exec = &mov},
|
||||
{.opcode = 0x8F, .extended = -1, .name = "pop", .mode = {R_M16, END}, .exec = NULL},
|
||||
{.opcode = 0x90, .extended = -1, .name = "xchg ax, ax", .mode = {END}, .exec = NULL},
|
||||
|
||||
@@ -8,6 +8,7 @@ void push(const instruction_t *self, state_t *state);
|
||||
void call(const instruction_t *self, state_t *state);
|
||||
void jmp(const instruction_t *self, state_t *state);
|
||||
void int_inst(const instruction_t *self, state_t *state);
|
||||
void lea(const instruction_t *self, state_t *state);
|
||||
|
||||
void sub(const instruction_t *self, state_t *state);
|
||||
void xor_inst(const instruction_t *self, state_t *state);
|
||||
|
||||
@@ -74,3 +74,12 @@ void int_inst(const instruction_t *self, state_t *state)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lea(const instruction_t *self, state_t *state)
|
||||
{
|
||||
operand_t to = get_operand(self, 0, state);
|
||||
operand_t memory = get_operand(self, 1, state);
|
||||
|
||||
// to = &memory;
|
||||
write_op(to, memory.ptr - state->memory);
|
||||
}
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ operand_t get_rm_operand(state_t *state, unsigned *imm_idx, bool is16bit)
|
||||
.ptr = &state->binary[state->pc + state->parse_data.imm_idx],
|
||||
.type = mod == 0b10 ? BIT16 : BIT8}
|
||||
);
|
||||
state->parse_data.imm_idx += mod == 0b10 ? 2 : 1;
|
||||
*imm_idx += mod == 0b10 ? 2 : 1;
|
||||
}
|
||||
|
||||
operand_t ret = {.ptr = NULL, .type = is16bit ? BIT16 : BIT8};
|
||||
|
||||
Reference in New Issue
Block a user