5050#define OPCODE_MOV_I32_TO_R32 (0xb8)
5151//#define OPCODE_MOV_I32_TO_RM32 (0xc7)
5252#define OPCODE_MOV_R8_TO_RM8 (0x88) /* /r */
53- #define OPCODE_MOV_R32_TO_RM32 (0x89)
54- #define OPCODE_MOV_RM32_TO_R32 (0x8b)
53+ #define OPCODE_MOV_R32_TO_RM32 (0x89) /* /r */
54+ #define OPCODE_MOV_RM32_TO_R32 (0x8b) /* /r */
55+ #define OPCODE_MOVZX_RM8_TO_R32 (0xb6) /* 0x0f 0xb6/r */
56+ #define OPCODE_MOVZX_RM16_TO_R32 (0xb7) /* 0x0f 0xb7/r */
5557#define OPCODE_LEA_MEM_TO_R32 (0x8d) /* /r */
5658#define OPCODE_AND_R32_TO_RM32 (0x21) /* /r */
5759#define OPCODE_OR_R32_TO_RM32 (0x09) /* /r */
@@ -244,22 +246,32 @@ void asm_x86_mov_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
244246 asm_x86_generic_r32_r32 (as , dest_r32 , src_r32 , OPCODE_MOV_R32_TO_RM32 );
245247}
246248
247- void asm_x86_mov_r8_to_disp (asm_x86_t * as , int src_r32 , int dest_r32 , int dest_disp ) {
249+ void asm_x86_mov_r8_to_mem8 (asm_x86_t * as , int src_r32 , int dest_r32 , int dest_disp ) {
248250 asm_x86_write_byte_1 (as , OPCODE_MOV_R8_TO_RM8 );
249251 asm_x86_write_r32_disp (as , src_r32 , dest_r32 , dest_disp );
250252}
251253
252- void asm_x86_mov_r16_to_disp (asm_x86_t * as , int src_r32 , int dest_r32 , int dest_disp ) {
254+ void asm_x86_mov_r16_to_mem16 (asm_x86_t * as , int src_r32 , int dest_r32 , int dest_disp ) {
253255 asm_x86_write_byte_2 (as , OP_SIZE_PREFIX , OPCODE_MOV_R32_TO_RM32 );
254256 asm_x86_write_r32_disp (as , src_r32 , dest_r32 , dest_disp );
255257}
256258
257- void asm_x86_mov_r32_to_disp (asm_x86_t * as , int src_r32 , int dest_r32 , int dest_disp ) {
259+ void asm_x86_mov_r32_to_mem32 (asm_x86_t * as , int src_r32 , int dest_r32 , int dest_disp ) {
258260 asm_x86_write_byte_1 (as , OPCODE_MOV_R32_TO_RM32 );
259261 asm_x86_write_r32_disp (as , src_r32 , dest_r32 , dest_disp );
260262}
261263
262- STATIC void asm_x86_mov_disp_to_r32 (asm_x86_t * as , int src_r32 , int src_disp , int dest_r32 ) {
264+ void asm_x86_mov_mem8_to_r32zx (asm_x86_t * as , int src_r32 , int src_disp , int dest_r32 ) {
265+ asm_x86_write_byte_2 (as , 0x0f , OPCODE_MOVZX_RM8_TO_R32 );
266+ asm_x86_write_r32_disp (as , dest_r32 , src_r32 , src_disp );
267+ }
268+
269+ void asm_x86_mov_mem16_to_r32zx (asm_x86_t * as , int src_r32 , int src_disp , int dest_r32 ) {
270+ asm_x86_write_byte_2 (as , 0x0f , OPCODE_MOVZX_RM16_TO_R32 );
271+ asm_x86_write_r32_disp (as , dest_r32 , src_r32 , src_disp );
272+ }
273+
274+ void asm_x86_mov_mem32_to_r32 (asm_x86_t * as , int src_r32 , int src_disp , int dest_r32 ) {
263275 asm_x86_write_byte_1 (as , OPCODE_MOV_RM32_TO_R32 );
264276 asm_x86_write_r32_disp (as , dest_r32 , src_r32 , src_disp );
265277}
@@ -474,12 +486,12 @@ void asm_x86_push_arg(asm_x86_t *as, int src_arg_num) {
474486#endif
475487
476488void asm_x86_mov_arg_to_r32 (asm_x86_t * as , int src_arg_num , int dest_r32 ) {
477- asm_x86_mov_disp_to_r32 (as , ASM_X86_REG_EBP , 2 * WORD_SIZE + src_arg_num * WORD_SIZE , dest_r32 );
489+ asm_x86_mov_mem32_to_r32 (as , ASM_X86_REG_EBP , 2 * WORD_SIZE + src_arg_num * WORD_SIZE , dest_r32 );
478490}
479491
480492#if 0
481493void asm_x86_mov_r32_to_arg (asm_x86_t * as , int src_r32 , int dest_arg_num ) {
482- asm_x86_mov_r32_to_disp (as , src_r32 , ASM_X86_REG_EBP , 2 * WORD_SIZE + dest_arg_num * WORD_SIZE );
494+ asm_x86_mov_r32_to_mem32 (as , src_r32 , ASM_X86_REG_EBP , 2 * WORD_SIZE + dest_arg_num * WORD_SIZE );
483495}
484496#endif
485497
@@ -499,11 +511,11 @@ STATIC int asm_x86_local_offset_from_ebp(asm_x86_t *as, int local_num) {
499511}
500512
501513void asm_x86_mov_local_to_r32 (asm_x86_t * as , int src_local_num , int dest_r32 ) {
502- asm_x86_mov_disp_to_r32 (as , ASM_X86_REG_EBP , asm_x86_local_offset_from_ebp (as , src_local_num ), dest_r32 );
514+ asm_x86_mov_mem32_to_r32 (as , ASM_X86_REG_EBP , asm_x86_local_offset_from_ebp (as , src_local_num ), dest_r32 );
503515}
504516
505517void asm_x86_mov_r32_to_local (asm_x86_t * as , int src_r32 , int dest_local_num ) {
506- asm_x86_mov_r32_to_disp (as , src_r32 , ASM_X86_REG_EBP , asm_x86_local_offset_from_ebp (as , dest_local_num ));
518+ asm_x86_mov_r32_to_mem32 (as , src_r32 , ASM_X86_REG_EBP , asm_x86_local_offset_from_ebp (as , dest_local_num ));
507519}
508520
509521void asm_x86_mov_local_addr_to_r32 (asm_x86_t * as , int local_num , int dest_r32 ) {
0 commit comments