50
50
#define OPCODE_MOV_I32_TO_R32 (0xb8)
51
51
//#define OPCODE_MOV_I32_TO_RM32 (0xc7)
52
52
#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 */
55
57
#define OPCODE_LEA_MEM_TO_R32 (0x8d) /* /r */
56
58
#define OPCODE_AND_R32_TO_RM32 (0x21) /* /r */
57
59
#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) {
244
246
asm_x86_generic_r32_r32 (as , dest_r32 , src_r32 , OPCODE_MOV_R32_TO_RM32 );
245
247
}
246
248
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 ) {
248
250
asm_x86_write_byte_1 (as , OPCODE_MOV_R8_TO_RM8 );
249
251
asm_x86_write_r32_disp (as , src_r32 , dest_r32 , dest_disp );
250
252
}
251
253
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 ) {
253
255
asm_x86_write_byte_2 (as , OP_SIZE_PREFIX , OPCODE_MOV_R32_TO_RM32 );
254
256
asm_x86_write_r32_disp (as , src_r32 , dest_r32 , dest_disp );
255
257
}
256
258
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 ) {
258
260
asm_x86_write_byte_1 (as , OPCODE_MOV_R32_TO_RM32 );
259
261
asm_x86_write_r32_disp (as , src_r32 , dest_r32 , dest_disp );
260
262
}
261
263
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 ) {
263
275
asm_x86_write_byte_1 (as , OPCODE_MOV_RM32_TO_R32 );
264
276
asm_x86_write_r32_disp (as , dest_r32 , src_r32 , src_disp );
265
277
}
@@ -474,12 +486,12 @@ void asm_x86_push_arg(asm_x86_t *as, int src_arg_num) {
474
486
#endif
475
487
476
488
void 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 );
478
490
}
479
491
480
492
#if 0
481
493
void 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 );
483
495
}
484
496
#endif
485
497
@@ -499,11 +511,11 @@ STATIC int asm_x86_local_offset_from_ebp(asm_x86_t *as, int local_num) {
499
511
}
500
512
501
513
void 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 );
503
515
}
504
516
505
517
void 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 ));
507
519
}
508
520
509
521
void asm_x86_mov_local_addr_to_r32 (asm_x86_t * as , int local_num , int dest_r32 ) {
0 commit comments