Verified Commit 298b717d authored by Recolic Keghart's avatar Recolic Keghart
Browse files

> Manual commit: add movs, reconstruct arith.

U201614531
recolic
Linux RECOLICPC 5.4.6-arch3-1 #1 SMP PREEMPT Tue, 24 Dec 2019 04:36:53 +0000 x86_64 GNU/Linux
 03:11:31 up  8:45,  1 user,  load average: 0.32, 0.54, 0.71
9d85abd478d81af6df0544f9fb8670238f902f2
parent 80d96057
Pipeline #788 failed with stage
in 60 minutes and 1 second
......@@ -87,6 +87,7 @@ namespace DHelperImpl {
make_DHelper(I_E2G);
make_DHelper(I_G2E);
make_DHelper(I);
make_DHelper(O);
make_DHelper(r);
make_DHelper(E);
make_DHelper(setcc_E);
......
......@@ -35,7 +35,7 @@ typedef union {
extern CPU_state cpu;
namespace cpu_eflags {
enum {CF = 0, PF, AF, ZF, SF, OF, SIZE_OF_EFLAGS};
enum {CF = 0, PF, AF, ZF, SF, OF, DF, SIZE_OF_EFLAGS};
template <size_t Which>
inline bool &get() {
static bool actual_buffer[SIZE_OF_EFLAGS];
......
......@@ -8,6 +8,7 @@ make_EHelper(pop);
make_EHelper(pusha);
make_EHelper(popa);
make_EHelper(leave);
make_EHelper(movs);
make_EHelper(movsx);
make_EHelper(movzx);
make_EHelper(cltd);
......
......@@ -60,37 +60,36 @@ namespace EHelperImpl {
}
make_EHelper(inc) {
rtl_addi(&t2, &id_dest->val, 1);
operand_write(id_dest, &t2);
rtl_update_ZFSF(&t2, id_dest->width);
rtl_xor(&t0, &id_dest->val, &id_src->val);
rtl_not(&t0, &t0);
rtl_xor(&t1, &id_dest->val, &t2);
rtl_and(&t0, &t0, &t1);
rtl_msb(&t0, &t0, id_dest->width);
rtl_set_OF(&t0);
cpu_eflags::get<cpu_eflags::OF>() = id_dest->val == 0x7fffffff;
++ id_dest->val;
operand_write(id_dest, &id_dest->val);
rtl_update_ZFSF(&id_dest->val, id_dest->width);
print_asm_template1(inc);
}
make_EHelper(dec) {
rtl_subi(&t2, &id_dest->val, 1);
operand_write(id_dest, &t2);
rtl_update_ZFSF(&t2, id_dest->width);
rtl_xor(&t0, &id_dest->val, &id_src->val);
rtl_xor(&t1, &id_dest->val, &t2);
rtl_and(&t0, &t0, &t1);
rtl_msb(&t0, &t0, id_dest->width);
rtl_set_OF(&t0);
cpu_eflags::get<cpu_eflags::OF>() = id_dest->val == 0x80000000;
-- id_dest->val;
operand_write(id_dest, &id_dest->val);
rtl_update_ZFSF(&id_dest->val, id_dest->width);
print_asm_template1(dec);
}
make_EHelper(neg) {
TODO();
cpu_eflags::get<cpu_eflags::CF>() = id_dest->val != 0;
cpu_eflags::get<cpu_eflags::OF>() = id_dest->val == 0x80000000;
id_dest->val = - id_dest->val;
operand_write(id_dest, &id_dest->val);
rtl_update_ZFSF(&id_dest->val, id_dest->width);
print_asm_template1(neg);
}
......
......@@ -102,4 +102,30 @@ namespace EHelperImpl {
operand_write(id_dest, &id_src->addr);
print_asm_template2(lea);
}
make_EHelper(movs) {
// movsb, movsw, movsd
// address size is always 32bit.
const auto source_index = cpu.esi,
dest_index = cpu.edi;
auto copy_bytes = 4;
if(decoding.opcode == 0xa4) {
// movsb
copy_bytes = 1;
}
else if(decoding.is_operand_size_16) {
// movsw
// r: dbt
copy_bytes = 2;
}
else {
// movsd
}
vaddr_write(dest_index, vaddr_read(source_index, 4), copy_bytes);
print_asm_template2(movs);
}
} // end namespace
......@@ -111,7 +111,7 @@ opcode_entry opcode_table [512] = {
/* 0x98 */ EX(cwtl), EX(cltd), IDEX(I,call), EMPTY,
/* 0x9c */ EMPTY, EMPTY, EMPTY, EMPTY,
/* 0xa0 */ IDEXW(O2a, mov, 1), IDEX(O2a, mov), IDEXW(a2O, mov, 1), IDEX(a2O, mov),
/* 0xa4 */ EMPTY, EMPTY, EMPTY, EMPTY,
/* 0xa4 */ EX(movs), EX(movs), EMPTY, EMPTY,
/* 0xa8 */ IDEXW(I2a,test,1), IDEX(I2a,test), EMPTY, EMPTY,
/* 0xac */ EMPTY, EMPTY, EMPTY, EMPTY,
/* 0xb0 */ IDEXW(mov_I2r, mov, 1), IDEXW(mov_I2r, mov, 1), IDEXW(mov_I2r, mov, 1), IDEXW(mov_I2r, mov, 1),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment