lar can accept multiple sizes as well (wlx), like lsl. When using autosize it's important to look at the destination operand first; when it's a register that one determines the size, not the input operand.
Unified · Split
| @@ -733,7 +733,11 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode) · 732 unmodified lines | ||
| 733 | 733 | autosize = NBWLX-2; |
| 734 | 734 | #endif |
| 735 | 735 | if (s == autosize) { |
| 736 | − for(i = 0; s == autosize && i < nb_ops; i++) { | |
| 736 | + /* Check for register operands providing hints about the size. | |
| 737 | + Start from the end, i.e. destination operands. This matters | |
| 738 | + only for opcodes accepting different sized registers, lar and lsl | |
| 739 | + are such opcodes. */ | |
| 740 | + for(i = nb_ops - 1; s == autosize && i >= 0; i--) { | |
| 737 | 741 | if ((ops[i].type & OP_REG) && !(op_type[i] & (OP_CL | OP_DX))) |
| 738 | 742 | s = reg_to_size[ops[i].type & OP_REG]; |
| 739 | 743 | } |
| @@ -341,7 +341,7 @@ ALT(DEF_ASM_OP1(fstsw, 0xdd, 7, OPC_MODRM | OPC_FWAIT, OPT_EA )) · 340 unmodified lines | ||
| 341 | 341 | |
| 342 | 342 | /* segments */ |
| 343 | 343 | DEF_ASM_OP2(arpl, 0x63, 0, OPC_MODRM, OPT_REG16, OPT_REG16 | OPT_EA) |
| 344 | − DEF_ASM_OP2(lar, 0x0f02, 0, OPC_MODRM, OPT_REG32 | OPT_EA, OPT_REG32) | |
| 344 | +ALT(DEF_ASM_OP2(larw, 0x0f02, 0, OPC_MODRM | OPC_WLX, OPT_REG | OPT_EA, OPT_REG)) | |
| 345 | 345 | DEF_ASM_OP1(lgdt, 0x0f01, 2, OPC_MODRM, OPT_EA) |
| 346 | 346 | DEF_ASM_OP1(lidt, 0x0f01, 3, OPC_MODRM, OPT_EA) |
| 347 | 347 | DEF_ASM_OP1(lldt, 0x0f00, 2, OPC_MODRM, OPT_EA | OPT_REG) |
| @@ -185,6 +185,7 @@ · 184 unmodified lines | ||
| 185 | 185 | DEF_WLX(btr) |
| 186 | 186 | DEF_WLX(btc) |
| 187 | 187 | |
| 188 | + DEF_WLX(lar) | |
| 188 | 189 | DEF_WLX(lsl) |
| 189 | 190 | |
| 190 | 191 | /* generic FP ops */ |
| @@ -625,8 +625,15 @@ int $0x10 · 624 unmodified lines | ||
| 625 | 625 | clflush 0x1000(%rax,%rcx) |
| 626 | 626 | fxsaveq (%rdx) |
| 627 | 627 | fxrstorq (%rcx) |
| 628 | + | |
| 628 | 629 | #endif |
| 629 | 630 | |
| 631 | + lar %ax,%dx | |
| 632 | + lar %eax,%dx | |
| 633 | + lar %ax,%edx | |
| 634 | + lar %eax,%edx | |
| 635 | + lar %ax,%rdx | |
| 636 | + lar %eax,%rdx | |
| 630 | 637 | emms |
| 631 | 638 | movd %edx, %mm3 |
| 632 | 639 | movd 0x1000, %mm2 |
| @@ -359,7 +359,7 @@ ALT(DEF_ASM_OP1(fstsw, 0xdd, 7, OPC_MODRM | OPC_FWAIT, OPT_EA )) · 358 unmodified lines | ||
| 359 | 359 | |
| 360 | 360 | /* segments */ |
| 361 | 361 | DEF_ASM_OP2(arpl, 0x63, 0, OPC_MODRM, OPT_REG16, OPT_REG16 | OPT_EA) |
| 362 | − DEF_ASM_OP2(lar, 0x0f02, 0, OPC_MODRM, OPT_REG32 | OPT_EA, OPT_REG32) | |
| 362 | +ALT(DEF_ASM_OP2(larw, 0x0f02, 0, OPC_MODRM | OPC_WLX, OPT_REG | OPT_EA, OPT_REG)) | |
| 363 | 363 | DEF_ASM_OP1(lgdt, 0x0f01, 2, OPC_MODRM, OPT_EA) |
| 364 | 364 | DEF_ASM_OP1(lgdtq, 0x0f01, 2, OPC_MODRM, OPT_EA) |
| 365 | 365 | DEF_ASM_OP1(lidt, 0x0f01, 3, OPC_MODRM, OPT_EA) |