Skip to content

Commit

Permalink
Implement movsx
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed May 25, 2018
1 parent ef28790 commit 8d05e5e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
33 changes: 16 additions & 17 deletions emu/gadgets-x86/math.S
Original file line number Diff line number Diff line change
Expand Up @@ -130,33 +130,32 @@ do_op_size imul, 32
gret
.endr

.macro do_extend size, s, ss
.if \size != 32
movs\ss\()l %tmp\s, %tmpd
.endif
.endm
.macro do_div size, s, ss
.gadget div_\size
div\ss %r10\s
gret
div\ss %tmp\s
.endm
.macro do_idiv size, s, ss
.gadget idiv_\size
idiv\ss %r10\s
gret
idiv\ss %tmp\s
.endm
.macro do_neg size, s, ss
.gadget neg_\size
setf_a src=$0 dst=%r10\s ss=\ss
neg\ss %r10\s
setf_oc
setf_zsp %r10\s, \ss
gret
setf_a src=$0 dst=%tmp\s ss=\ss
neg\ss %tmp\s
setf_oc
setf_zsp %tmp\s, \ss
.endm
.macro do_not size, s, ss
.gadget not_\size
not\ss %r10\s
gret
not\ss %tmp\s
.endm

.irp op, idiv,div,neg,not
.irp op, extend,idiv,div,neg,not
.irp size, SIZE_LIST
ss \size, do_\op
.gadget \op\()_\size
ss \size, do_\op
gret
.endr
.gadget_list \op, SIZE_LIST
.endr
Expand Down
2 changes: 1 addition & 1 deletion emu/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static inline void gen_op(struct gen_state *state, gadget_t *gadgets, enum arg a

#define MOV(src, dst,z) load(src, z); store(dst, z)
#define MOVZX(src, dst,zs,zd) load(src, zs); store(dst, zd)
#define MOVSX(src, dst,zs,zd) UNDEFINED
#define MOVSX(src, dst,zs,zd) load(src, zs); ga(extend, sz(zs)); store(dst, zd)
#define XCHG(src, dst,z) UNDEFINED

#define ADD(src, dst,z) los(add, src, dst, z)
Expand Down

0 comments on commit 8d05e5e

Please sign in to comment.