Skip to content

Commit

Permalink
Implement idiv
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed May 25, 2018
1 parent 210f2c5 commit f3a4e7b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
29 changes: 21 additions & 8 deletions emu/gadgets-x86/math.S
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@
div\ss %r10\s
gret
.endm
.macro do_idiv size, s, ss
.gadget idiv_\size
idiv\ss %r10\s
gret
.endm
.macro do_imul size, s, ss
.if \size != 8
.gadget imul_\size
imul\ss (%_ip), %r10\s
gret 1
.endif
.endm
.macro do_neg size, s, ss
.gadget neg_\size
setf_a src=$0 dst=%r10\s ss=\ss
Expand All @@ -138,17 +150,18 @@
not\ss %r10\s
gret
.endm
.macro do_imul size, s, ss
.if \size != 8
.gadget imul_\size
imul\ss (%_ip), %r10\s
gret 1
.endif
.endm

.irp op, div,neg,not,imul
.irp op, idiv,div,imul,neg,not
.irp size, SIZE_LIST
ss \size, do_\op
.endr
.gadget_list \op, SIZE_LIST
.endr

.gadget cvt_16
cwd
gret
.gadget cvt_32
cdq
gret
.gadget_list cvt, SIZE_LIST
4 changes: 2 additions & 2 deletions emu/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ static inline void gen_op(struct gen_state *state, gadget_t *gadgets, enum arg a
#define IMUL2(val, reg,z) UNDEFINED
#define IMUL3(imm, src, dst,z) load(src,z); gag(imul, sz(z), imm); store(dst,z)
#define DIV(val, z) load(val, z); ga(div, sz(z)); store(val, z)
#define IDIV(val, z) UNDEFINED
#define IDIV(val, z) load(val, z); ga(idiv, sz(z)); store(val, z)

#define CVT UNDEFINED
#define CVT ga(cvt, sz(oz))
#define CVTE UNDEFINED

#define ROL(count, val,z) UNDEFINED
Expand Down

0 comments on commit f3a4e7b

Please sign in to comment.