Subversion Repositories Kolibri OS

Rev

Rev 4039 | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. ; flat assembler core
  3. ; Copyright (c) 1999-2016, Tomasz Grysztar.
  4. ; All rights reserved.
  5.  
  6. simple_instruction_except64:
  7.         cmp     [code_type],64
  8.         je      illegal_instruction
  9. simple_instruction:
  10.         stos    byte [edi]
  11.         jmp     instruction_assembled
  12. simple_instruction_only64:
  13.         cmp     [code_type],64
  14.         jne     illegal_instruction
  15.         jmp     simple_instruction
  16. simple_instruction_16bit_except64:
  17.         cmp     [code_type],64
  18.         je      illegal_instruction
  19. simple_instruction_16bit:
  20.         cmp     [code_type],16
  21.         jne     size_prefix
  22.         stos    byte [edi]
  23.         jmp     instruction_assembled
  24.       size_prefix:
  25.         mov     ah,al
  26.         mov     al,66h
  27.         stos    word [edi]
  28.         jmp     instruction_assembled
  29. simple_instruction_32bit_except64:
  30.         cmp     [code_type],64
  31.         je      illegal_instruction
  32. simple_instruction_32bit:
  33.         cmp     [code_type],16
  34.         je      size_prefix
  35.         stos    byte [edi]
  36.         jmp     instruction_assembled
  37. iret_instruction:
  38.         cmp     [code_type],64
  39.         jne     simple_instruction
  40. simple_instruction_64bit:
  41.         cmp     [code_type],64
  42.         jne     illegal_instruction
  43.         mov     ah,al
  44.         mov     al,48h
  45.         stos    word [edi]
  46.         jmp     instruction_assembled
  47. simple_extended_instruction_64bit:
  48.         cmp     [code_type],64
  49.         jne     illegal_instruction
  50.         mov     byte [edi],48h
  51.         inc     edi
  52. simple_extended_instruction:
  53.         mov     ah,al
  54.         mov     al,0Fh
  55.         stos    word [edi]
  56.         jmp     instruction_assembled
  57. prefix_instruction:
  58.         stos    byte [edi]
  59.         or      [prefix_flags],1
  60.         jmp     continue_line
  61. segment_prefix:
  62.         mov     ah,al
  63.         shr     ah,4
  64.         cmp     ah,3
  65.         jne     illegal_instruction
  66.         and     al,1111b
  67.         mov     [segment_register],al
  68.         call    store_segment_prefix
  69.         or      [prefix_flags],1
  70.         jmp     continue_line
  71. bnd_prefix_instruction:
  72.         stos    byte [edi]
  73.         or      [prefix_flags],1 + 10h
  74.         jmp     continue_line
  75. int_instruction:
  76.         lods    byte [esi]
  77.         call    get_size_operator
  78.         cmp     ah,1
  79.         ja      invalid_operand_size
  80.         cmp     al,'('
  81.         jne     invalid_operand
  82.         call    get_byte_value
  83.         test    eax,eax
  84.         jns     int_imm_ok
  85.         call    recoverable_overflow
  86.       int_imm_ok:
  87.         mov     ah,al
  88.         mov     al,0CDh
  89.         stos    word [edi]
  90.         jmp     instruction_assembled
  91. aa_instruction:
  92.         cmp     [code_type],64
  93.         je      illegal_instruction
  94.         push    eax
  95.         mov     bl,10
  96.         cmp     byte [esi],'('
  97.         jne     aa_store
  98.         inc     esi
  99.         xor     al,al
  100.         xchg    al,[operand_size]
  101.         cmp     al,1
  102.         ja      invalid_operand_size
  103.         call    get_byte_value
  104.         mov     bl,al
  105.       aa_store:
  106.         cmp     [operand_size],0
  107.         jne     invalid_operand
  108.         pop     eax
  109.         mov     ah,bl
  110.         stos    word [edi]
  111.         jmp     instruction_assembled
  112.  
  113. basic_instruction:
  114.         mov     [base_code],al
  115.         lods    byte [esi]
  116.         call    get_size_operator
  117.         cmp     al,10h
  118.         je      basic_reg
  119.         cmp     al,'['
  120.         jne     invalid_operand
  121.       basic_mem:
  122.         call    get_address
  123.         push    edx ebx ecx
  124.         lods    byte [esi]
  125.         cmp     al,','
  126.         jne     invalid_operand
  127.         lods    byte [esi]
  128.         call    get_size_operator
  129.         cmp     al,'('
  130.         je      basic_mem_imm
  131.         cmp     al,10h
  132.         jne     invalid_operand
  133.       basic_mem_reg:
  134.         lods    byte [esi]
  135.         call    convert_register
  136.         mov     [postbyte_register],al
  137.         pop     ecx ebx edx
  138.         mov     al,ah
  139.         cmp     al,1
  140.         je      instruction_ready
  141.         call    operand_autodetect
  142.         inc     [base_code]
  143.       instruction_ready:
  144.         call    store_instruction
  145.         jmp     instruction_assembled
  146.       basic_mem_imm:
  147.         mov     al,[operand_size]
  148.         cmp     al,1
  149.         jb      basic_mem_imm_nosize
  150.         je      basic_mem_imm_8bit
  151.         cmp     al,2
  152.         je      basic_mem_imm_16bit
  153.         cmp     al,4
  154.         je      basic_mem_imm_32bit
  155.         cmp     al,8
  156.         jne     invalid_operand_size
  157.       basic_mem_imm_64bit:
  158.         cmp     [size_declared],0
  159.         jne     long_immediate_not_encodable
  160.         call    operand_64bit
  161.         call    get_simm32
  162.         cmp     [value_type],4
  163.         jae     long_immediate_not_encodable
  164.         jmp     basic_mem_imm_32bit_ok
  165.       basic_mem_imm_nosize:
  166.         call    recoverable_unknown_size
  167.       basic_mem_imm_8bit:
  168.         call    get_byte_value
  169.         mov     byte [value],al
  170.         mov     al,[base_code]
  171.         shr     al,3
  172.         mov     [postbyte_register],al
  173.         pop     ecx ebx edx
  174.         mov     [base_code],80h
  175.         call    store_instruction_with_imm8
  176.         jmp     instruction_assembled
  177.       basic_mem_imm_16bit:
  178.         call    operand_16bit
  179.         call    get_word_value
  180.         mov     word [value],ax
  181.         mov     al,[base_code]
  182.         shr     al,3
  183.         mov     [postbyte_register],al
  184.         pop     ecx ebx edx
  185.         cmp     [value_type],0
  186.         jne     basic_mem_imm_16bit_store
  187.         cmp     [size_declared],0
  188.         jne     basic_mem_imm_16bit_store
  189.         cmp     word [value],80h
  190.         jb      basic_mem_simm_8bit
  191.         cmp     word [value],-80h
  192.         jae     basic_mem_simm_8bit
  193.       basic_mem_imm_16bit_store:
  194.         mov     [base_code],81h
  195.         call    store_instruction_with_imm16
  196.         jmp     instruction_assembled
  197.       basic_mem_simm_8bit:
  198.         mov     [base_code],83h
  199.         call    store_instruction_with_imm8
  200.         jmp     instruction_assembled
  201.       basic_mem_imm_32bit:
  202.         call    operand_32bit
  203.         call    get_dword_value
  204.       basic_mem_imm_32bit_ok:
  205.         mov     dword [value],eax
  206.         mov     al,[base_code]
  207.         shr     al,3
  208.         mov     [postbyte_register],al
  209.         pop     ecx ebx edx
  210.         cmp     [value_type],0
  211.         jne     basic_mem_imm_32bit_store
  212.         cmp     [size_declared],0
  213.         jne     basic_mem_imm_32bit_store
  214.         cmp     dword [value],80h
  215.         jb      basic_mem_simm_8bit
  216.         cmp     dword [value],-80h
  217.         jae     basic_mem_simm_8bit
  218.       basic_mem_imm_32bit_store:
  219.         mov     [base_code],81h
  220.         call    store_instruction_with_imm32
  221.         jmp     instruction_assembled
  222.       get_simm32:
  223.         call    get_qword_value
  224.         mov     ecx,edx
  225.         cdq
  226.         cmp     ecx,edx
  227.         jne     value_out_of_range
  228.         cmp     [value_type],4
  229.         jne     get_simm32_ok
  230.         mov     [value_type],2
  231.       get_simm32_ok:
  232.         ret
  233.       basic_reg:
  234.         lods    byte [esi]
  235.         call    convert_register
  236.         mov     [postbyte_register],al
  237.         lods    byte [esi]
  238.         cmp     al,','
  239.         jne     invalid_operand
  240.         lods    byte [esi]
  241.         call    get_size_operator
  242.         cmp     al,10h
  243.         je      basic_reg_reg
  244.         cmp     al,'('
  245.         je      basic_reg_imm
  246.         cmp     al,'['
  247.         jne     invalid_operand
  248.       basic_reg_mem:
  249.         call    get_address
  250.         mov     al,[operand_size]
  251.         cmp     al,1
  252.         je      basic_reg_mem_8bit
  253.         call    operand_autodetect
  254.         add     [base_code],3
  255.         jmp     instruction_ready
  256.       basic_reg_mem_8bit:
  257.         add     [base_code],2
  258.         jmp     instruction_ready
  259.       basic_reg_reg:
  260.         lods    byte [esi]
  261.         call    convert_register
  262.         mov     bl,[postbyte_register]
  263.         mov     [postbyte_register],al
  264.         mov     al,ah
  265.         cmp     al,1
  266.         je      nomem_instruction_ready
  267.         call    operand_autodetect
  268.         inc     [base_code]
  269.       nomem_instruction_ready:
  270.         call    store_nomem_instruction
  271.         jmp     instruction_assembled
  272.       basic_reg_imm:
  273.         mov     al,[operand_size]
  274.         cmp     al,1
  275.         je      basic_reg_imm_8bit
  276.         cmp     al,2
  277.         je      basic_reg_imm_16bit
  278.         cmp     al,4
  279.         je      basic_reg_imm_32bit
  280.         cmp     al,8
  281.         jne     invalid_operand_size
  282.       basic_reg_imm_64bit:
  283.         cmp     [size_declared],0
  284.         jne     long_immediate_not_encodable
  285.         call    operand_64bit
  286.         call    get_simm32
  287.         cmp     [value_type],4
  288.         jae     long_immediate_not_encodable
  289.         jmp     basic_reg_imm_32bit_ok
  290.       basic_reg_imm_8bit:
  291.         call    get_byte_value
  292.         mov     dl,al
  293.         mov     bl,[base_code]
  294.         shr     bl,3
  295.         xchg    bl,[postbyte_register]
  296.         or      bl,bl
  297.         jz      basic_al_imm
  298.         mov     [base_code],80h
  299.         call    store_nomem_instruction
  300.         mov     al,dl
  301.         stos    byte [edi]
  302.         jmp     instruction_assembled
  303.       basic_al_imm:
  304.         mov     al,[base_code]
  305.         add     al,4
  306.         stos    byte [edi]
  307.         mov     al,dl
  308.         stos    byte [edi]
  309.         jmp     instruction_assembled
  310.       basic_reg_imm_16bit:
  311.         call    operand_16bit
  312.         call    get_word_value
  313.         mov     dx,ax
  314.         mov     bl,[base_code]
  315.         shr     bl,3
  316.         xchg    bl,[postbyte_register]
  317.         cmp     [value_type],0
  318.         jne     basic_reg_imm_16bit_store
  319.         cmp     [size_declared],0
  320.         jne     basic_reg_imm_16bit_store
  321.         cmp     dx,80h
  322.         jb      basic_reg_simm_8bit
  323.         cmp     dx,-80h
  324.         jae     basic_reg_simm_8bit
  325.       basic_reg_imm_16bit_store:
  326.         or      bl,bl
  327.         jz      basic_ax_imm
  328.         mov     [base_code],81h
  329.         call    store_nomem_instruction
  330.       basic_store_imm_16bit:
  331.         mov     ax,dx
  332.         call    mark_relocation
  333.         stos    word [edi]
  334.         jmp     instruction_assembled
  335.       basic_reg_simm_8bit:
  336.         mov     [base_code],83h
  337.         call    store_nomem_instruction
  338.         mov     al,dl
  339.         stos    byte [edi]
  340.         jmp     instruction_assembled
  341.       basic_ax_imm:
  342.         add     [base_code],5
  343.         call    store_classic_instruction_code
  344.         jmp     basic_store_imm_16bit
  345.       basic_reg_imm_32bit:
  346.         call    operand_32bit
  347.         call    get_dword_value
  348.       basic_reg_imm_32bit_ok:
  349.         mov     edx,eax
  350.         mov     bl,[base_code]
  351.         shr     bl,3
  352.         xchg    bl,[postbyte_register]
  353.         cmp     [value_type],0
  354.         jne     basic_reg_imm_32bit_store
  355.         cmp     [size_declared],0
  356.         jne     basic_reg_imm_32bit_store
  357.         cmp     edx,80h
  358.         jb      basic_reg_simm_8bit
  359.         cmp     edx,-80h
  360.         jae     basic_reg_simm_8bit
  361.       basic_reg_imm_32bit_store:
  362.         or      bl,bl
  363.         jz      basic_eax_imm
  364.         mov     [base_code],81h
  365.         call    store_nomem_instruction
  366.       basic_store_imm_32bit:
  367.         mov     eax,edx
  368.         call    mark_relocation
  369.         stos    dword [edi]
  370.         jmp     instruction_assembled
  371.       basic_eax_imm:
  372.         add     [base_code],5
  373.         call    store_classic_instruction_code
  374.         jmp     basic_store_imm_32bit
  375.       recoverable_unknown_size:
  376.         cmp     [error_line],0
  377.         jne     ignore_unknown_size
  378.         push    [current_line]
  379.         pop     [error_line]
  380.         mov     [error],operand_size_not_specified
  381.       ignore_unknown_size:
  382.         ret
  383. single_operand_instruction:
  384.         mov     [base_code],0F6h
  385.         mov     [postbyte_register],al
  386.         lods    byte [esi]
  387.         call    get_size_operator
  388.         cmp     al,10h
  389.         je      single_reg
  390.         cmp     al,'['
  391.         jne     invalid_operand
  392.       single_mem:
  393.         call    get_address
  394.         mov     al,[operand_size]
  395.         cmp     al,1
  396.         je      single_mem_8bit
  397.         jb      single_mem_nosize
  398.         call    operand_autodetect
  399.         inc     [base_code]
  400.         jmp     instruction_ready
  401.       single_mem_nosize:
  402.         call    recoverable_unknown_size
  403.       single_mem_8bit:
  404.         jmp     instruction_ready
  405.       single_reg:
  406.         lods    byte [esi]
  407.         call    convert_register
  408.         mov     bl,al
  409.         mov     al,ah
  410.         cmp     al,1
  411.         je      single_reg_8bit
  412.         call    operand_autodetect
  413.         inc     [base_code]
  414.       single_reg_8bit:
  415.         jmp     nomem_instruction_ready
  416. mov_instruction:
  417.         mov     [base_code],88h
  418.         lods    byte [esi]
  419.         call    get_size_operator
  420.         cmp     al,10h
  421.         je      mov_reg
  422.         cmp     al,14h
  423.         je      mov_creg
  424.         cmp     al,'['
  425.         jne     invalid_operand
  426.       mov_mem:
  427.         call    get_address
  428.         push    edx ebx ecx
  429.         lods    byte [esi]
  430.         cmp     al,','
  431.         jne     invalid_operand
  432.         lods    byte [esi]
  433.         call    get_size_operator
  434.         cmp     al,'('
  435.         je      mov_mem_imm
  436.         cmp     al,10h
  437.         jne     invalid_operand
  438.       mov_mem_reg:
  439.         lods    byte [esi]
  440.         cmp     al,30h
  441.         jb      mov_mem_general_reg
  442.         cmp     al,40h
  443.         jb      mov_mem_sreg
  444.       mov_mem_general_reg:
  445.         call    convert_register
  446.         mov     [postbyte_register],al
  447.         pop     ecx ebx edx
  448.         cmp     ah,1
  449.         je      mov_mem_reg_8bit
  450.         mov     al,ah
  451.         call    operand_autodetect
  452.         mov     al,[postbyte_register]
  453.         or      al,bl
  454.         or      al,bh
  455.         jz      mov_mem_ax
  456.         inc     [base_code]
  457.         jmp     instruction_ready
  458.       mov_mem_reg_8bit:
  459.         or      al,bl
  460.         or      al,bh
  461.         jnz     instruction_ready
  462.       mov_mem_al:
  463.         test    ch,22h
  464.         jnz     mov_mem_address16_al
  465.         test    ch,44h
  466.         jnz     mov_mem_address32_al
  467.         test    ch,88h
  468.         jnz     mov_mem_address64_al
  469.         or      ch,ch
  470.         jnz     invalid_address_size
  471.         cmp     [code_type],64
  472.         je      mov_mem_address64_al
  473.         cmp     [code_type],32
  474.         je      mov_mem_address32_al
  475.         cmp     edx,10000h
  476.         jb      mov_mem_address16_al
  477.       mov_mem_address32_al:
  478.         call    store_segment_prefix_if_necessary
  479.         call    address_32bit_prefix
  480.         mov     [base_code],0A2h
  481.       store_mov_address32:
  482.         call    store_classic_instruction_code
  483.         call    store_address_32bit_value
  484.         jmp     instruction_assembled
  485.       mov_mem_address16_al:
  486.         call    store_segment_prefix_if_necessary
  487.         call    address_16bit_prefix
  488.         mov     [base_code],0A2h
  489.       store_mov_address16:
  490.         cmp     [code_type],64
  491.         je      invalid_address
  492.         call    store_classic_instruction_code
  493.         mov     eax,edx
  494.         stos    word [edi]
  495.         cmp     edx,10000h
  496.         jge     value_out_of_range
  497.         jmp     instruction_assembled
  498.       mov_mem_address64_al:
  499.         call    store_segment_prefix_if_necessary
  500.         mov     [base_code],0A2h
  501.       store_mov_address64:
  502.         call    store_classic_instruction_code
  503.         call    store_address_64bit_value
  504.         jmp     instruction_assembled
  505.       mov_mem_ax:
  506.         test    ch,22h
  507.         jnz     mov_mem_address16_ax
  508.         test    ch,44h
  509.         jnz     mov_mem_address32_ax
  510.         test    ch,88h
  511.         jnz     mov_mem_address64_ax
  512.         or      ch,ch
  513.         jnz     invalid_address_size
  514.         cmp     [code_type],64
  515.         je      mov_mem_address64_ax
  516.         cmp     [code_type],32
  517.         je      mov_mem_address32_ax
  518.         cmp     edx,10000h
  519.         jb      mov_mem_address16_ax
  520.       mov_mem_address32_ax:
  521.         call    store_segment_prefix_if_necessary
  522.         call    address_32bit_prefix
  523.         mov     [base_code],0A3h
  524.         jmp     store_mov_address32
  525.       mov_mem_address16_ax:
  526.         call    store_segment_prefix_if_necessary
  527.         call    address_16bit_prefix
  528.         mov     [base_code],0A3h
  529.         jmp     store_mov_address16
  530.       mov_mem_address64_ax:
  531.         call    store_segment_prefix_if_necessary
  532.         mov     [base_code],0A3h
  533.         jmp     store_mov_address64
  534.       mov_mem_sreg:
  535.         sub     al,31h
  536.         mov     [postbyte_register],al
  537.         pop     ecx ebx edx
  538.         mov     ah,[operand_size]
  539.         or      ah,ah
  540.         jz      mov_mem_sreg_store
  541.         cmp     ah,2
  542.         jne     invalid_operand_size
  543.       mov_mem_sreg_store:
  544.         mov     [base_code],8Ch
  545.         jmp     instruction_ready
  546.       mov_mem_imm:
  547.         mov     al,[operand_size]
  548.         cmp     al,1
  549.         jb      mov_mem_imm_nosize
  550.         je      mov_mem_imm_8bit
  551.         cmp     al,2
  552.         je      mov_mem_imm_16bit
  553.         cmp     al,4
  554.         je      mov_mem_imm_32bit
  555.         cmp     al,8
  556.         jne     invalid_operand_size
  557.       mov_mem_imm_64bit:
  558.         cmp     [size_declared],0
  559.         jne     long_immediate_not_encodable
  560.         call    operand_64bit
  561.         call    get_simm32
  562.         cmp     [value_type],4
  563.         jae     long_immediate_not_encodable
  564.         jmp     mov_mem_imm_32bit_store
  565.       mov_mem_imm_nosize:
  566.         call    recoverable_unknown_size
  567.       mov_mem_imm_8bit:
  568.         call    get_byte_value
  569.         mov     byte [value],al
  570.         mov     [postbyte_register],0
  571.         mov     [base_code],0C6h
  572.         pop     ecx ebx edx
  573.         call    store_instruction_with_imm8
  574.         jmp     instruction_assembled
  575.       mov_mem_imm_16bit:
  576.         call    operand_16bit
  577.         call    get_word_value
  578.         mov     word [value],ax
  579.         mov     [postbyte_register],0
  580.         mov     [base_code],0C7h
  581.         pop     ecx ebx edx
  582.         call    store_instruction_with_imm16
  583.         jmp     instruction_assembled
  584.       mov_mem_imm_32bit:
  585.         call    operand_32bit
  586.         call    get_dword_value
  587.       mov_mem_imm_32bit_store:
  588.         mov     dword [value],eax
  589.         mov     [postbyte_register],0
  590.         mov     [base_code],0C7h
  591.         pop     ecx ebx edx
  592.         call    store_instruction_with_imm32
  593.         jmp     instruction_assembled
  594.       mov_reg:
  595.         lods    byte [esi]
  596.         mov     ah,al
  597.         sub     ah,10h
  598.         and     ah,al
  599.         test    ah,0F0h
  600.         jnz     mov_sreg
  601.         call    convert_register
  602.         mov     [postbyte_register],al
  603.         lods    byte [esi]
  604.         cmp     al,','
  605.         jne     invalid_operand
  606.         lods    byte [esi]
  607.         call    get_size_operator
  608.         cmp     al,'['
  609.         je      mov_reg_mem
  610.         cmp     al,'('
  611.         je      mov_reg_imm
  612.         cmp     al,14h
  613.         je      mov_reg_creg
  614.         cmp     al,10h
  615.         jne     invalid_operand
  616.       mov_reg_reg:
  617.         lods    byte [esi]
  618.         mov     ah,al
  619.         sub     ah,10h
  620.         and     ah,al
  621.         test    ah,0F0h
  622.         jnz     mov_reg_sreg
  623.         call    convert_register
  624.         mov     bl,[postbyte_register]
  625.         mov     [postbyte_register],al
  626.         mov     al,ah
  627.         cmp     al,1
  628.         je      mov_reg_reg_8bit
  629.         call    operand_autodetect
  630.         inc     [base_code]
  631.       mov_reg_reg_8bit:
  632.         jmp     nomem_instruction_ready
  633.       mov_reg_sreg:
  634.         mov     bl,[postbyte_register]
  635.         mov     ah,al
  636.         and     al,1111b
  637.         mov     [postbyte_register],al
  638.         shr     ah,4
  639.         cmp     ah,3
  640.         jne     invalid_operand
  641.         dec     [postbyte_register]
  642.         cmp     [operand_size],8
  643.         je      mov_reg_sreg64
  644.         cmp     [operand_size],4
  645.         je      mov_reg_sreg32
  646.         cmp     [operand_size],2
  647.         jne     invalid_operand_size
  648.         call    operand_16bit
  649.         jmp     mov_reg_sreg_store
  650.       mov_reg_sreg64:
  651.         call    operand_64bit
  652.         jmp     mov_reg_sreg_store
  653.       mov_reg_sreg32:
  654.         call    operand_32bit
  655.       mov_reg_sreg_store:
  656.         mov     [base_code],8Ch
  657.         jmp     nomem_instruction_ready
  658.       mov_reg_creg:
  659.         lods    byte [esi]
  660.         mov     bl,al
  661.         shr     al,4
  662.         cmp     al,4
  663.         ja      invalid_operand
  664.         add     al,20h
  665.         mov     [extended_code],al
  666.         and     bl,1111b
  667.         xchg    bl,[postbyte_register]
  668.         mov     [base_code],0Fh
  669.         cmp     [code_type],64
  670.         je      mov_reg_creg_64bit
  671.         cmp     [operand_size],4
  672.         jne     invalid_operand_size
  673.         cmp     [postbyte_register],8
  674.         jb      mov_reg_creg_store
  675.         cmp     [extended_code],20h
  676.         jne     mov_reg_creg_store
  677.         mov     al,0F0h
  678.         stos    byte [edi]
  679.         mov     [postbyte_register],0
  680.       mov_reg_creg_store:
  681.         jmp     nomem_instruction_ready
  682.       mov_reg_creg_64bit:
  683.         cmp     [operand_size],8
  684.         jne     invalid_operand_size
  685.         jmp     nomem_instruction_ready
  686.       mov_reg_mem:
  687.         call    get_address
  688.         mov     al,[operand_size]
  689.         cmp     al,1
  690.         je      mov_reg_mem_8bit
  691.         call    operand_autodetect
  692.         mov     al,[postbyte_register]
  693.         or      al,bl
  694.         or      al,bh
  695.         jz      mov_ax_mem
  696.         add     [base_code],3
  697.         jmp     instruction_ready
  698.       mov_reg_mem_8bit:
  699.         mov     al,[postbyte_register]
  700.         or      al,bl
  701.         or      al,bh
  702.         jz      mov_al_mem
  703.         add     [base_code],2
  704.         jmp     instruction_ready
  705.       mov_al_mem:
  706.         test    ch,22h
  707.         jnz     mov_al_mem_address16
  708.         test    ch,44h
  709.         jnz     mov_al_mem_address32
  710.         test    ch,88h
  711.         jnz     mov_al_mem_address64
  712.         or      ch,ch
  713.         jnz     invalid_address_size
  714.         cmp     [code_type],64
  715.         je      mov_al_mem_address64
  716.         cmp     [code_type],32
  717.         je      mov_al_mem_address32
  718.         cmp     edx,10000h
  719.         jb      mov_al_mem_address16
  720.       mov_al_mem_address32:
  721.         call    store_segment_prefix_if_necessary
  722.         call    address_32bit_prefix
  723.         mov     [base_code],0A0h
  724.         jmp     store_mov_address32
  725.       mov_al_mem_address16:
  726.         call    store_segment_prefix_if_necessary
  727.         call    address_16bit_prefix
  728.         mov     [base_code],0A0h
  729.         jmp     store_mov_address16
  730.       mov_al_mem_address64:
  731.         call    store_segment_prefix_if_necessary
  732.         mov     [base_code],0A0h
  733.         jmp     store_mov_address64
  734.       mov_ax_mem:
  735.         test    ch,22h
  736.         jnz     mov_ax_mem_address16
  737.         test    ch,44h
  738.         jnz     mov_ax_mem_address32
  739.         test    ch,88h
  740.         jnz     mov_ax_mem_address64
  741.         or      ch,ch
  742.         jnz     invalid_address_size
  743.         cmp     [code_type],64
  744.         je      mov_ax_mem_address64
  745.         cmp     [code_type],32
  746.         je      mov_ax_mem_address32
  747.         cmp     edx,10000h
  748.         jb      mov_ax_mem_address16
  749.       mov_ax_mem_address32:
  750.         call    store_segment_prefix_if_necessary
  751.         call    address_32bit_prefix
  752.         mov     [base_code],0A1h
  753.         jmp     store_mov_address32
  754.       mov_ax_mem_address16:
  755.         call    store_segment_prefix_if_necessary
  756.         call    address_16bit_prefix
  757.         mov     [base_code],0A1h
  758.         jmp     store_mov_address16
  759.       mov_ax_mem_address64:
  760.         call    store_segment_prefix_if_necessary
  761.         mov     [base_code],0A1h
  762.         jmp     store_mov_address64
  763.       mov_reg_imm:
  764.         mov     al,[operand_size]
  765.         cmp     al,1
  766.         je      mov_reg_imm_8bit
  767.         cmp     al,2
  768.         je      mov_reg_imm_16bit
  769.         cmp     al,4
  770.         je      mov_reg_imm_32bit
  771.         cmp     al,8
  772.         jne     invalid_operand_size
  773.       mov_reg_imm_64bit:
  774.         call    operand_64bit
  775.         call    get_qword_value
  776.         mov     ecx,edx
  777.         cmp     [size_declared],0
  778.         jne     mov_reg_imm_64bit_store
  779.         cmp     [value_type],4
  780.         jae     mov_reg_imm_64bit_store
  781.         cdq
  782.         cmp     ecx,edx
  783.         je      mov_reg_64bit_imm_32bit
  784.       mov_reg_imm_64bit_store:
  785.         push    eax ecx
  786.         mov     al,0B8h
  787.         call    store_mov_reg_imm_code
  788.         pop     edx eax
  789.         call    mark_relocation
  790.         stos    dword [edi]
  791.         mov     eax,edx
  792.         stos    dword [edi]
  793.         jmp     instruction_assembled
  794.       mov_reg_imm_8bit:
  795.         call    get_byte_value
  796.         mov     dl,al
  797.         mov     al,0B0h
  798.         call    store_mov_reg_imm_code
  799.         mov     al,dl
  800.         stos    byte [edi]
  801.         jmp     instruction_assembled
  802.       mov_reg_imm_16bit:
  803.         call    get_word_value
  804.         mov     dx,ax
  805.         call    operand_16bit
  806.         mov     al,0B8h
  807.         call    store_mov_reg_imm_code
  808.         mov     ax,dx
  809.         call    mark_relocation
  810.         stos    word [edi]
  811.         jmp     instruction_assembled
  812.       mov_reg_imm_32bit:
  813.         call    operand_32bit
  814.         call    get_dword_value
  815.         mov     edx,eax
  816.         mov     al,0B8h
  817.         call    store_mov_reg_imm_code
  818.       mov_store_imm_32bit:
  819.         mov     eax,edx
  820.         call    mark_relocation
  821.         stos    dword [edi]
  822.         jmp     instruction_assembled
  823.       store_mov_reg_imm_code:
  824.         mov     ah,[postbyte_register]
  825.         test    ah,1000b
  826.         jz      mov_reg_imm_prefix_ok
  827.         or      [rex_prefix],41h
  828.       mov_reg_imm_prefix_ok:
  829.         and     ah,111b
  830.         add     al,ah
  831.         mov     [base_code],al
  832.         call    store_classic_instruction_code
  833.         ret
  834.       mov_reg_64bit_imm_32bit:
  835.         mov     edx,eax
  836.         mov     bl,[postbyte_register]
  837.         mov     [postbyte_register],0
  838.         mov     [base_code],0C7h
  839.         call    store_nomem_instruction
  840.         jmp     mov_store_imm_32bit
  841.       mov_sreg:
  842.         mov     ah,al
  843.         and     al,1111b
  844.         mov     [postbyte_register],al
  845.         shr     ah,4
  846.         cmp     ah,3
  847.         jne     invalid_operand
  848.         cmp     al,2
  849.         je      illegal_instruction
  850.         dec     [postbyte_register]
  851.         lods    byte [esi]
  852.         cmp     al,','
  853.         jne     invalid_operand
  854.         lods    byte [esi]
  855.         call    get_size_operator
  856.         cmp     al,'['
  857.         je      mov_sreg_mem
  858.         cmp     al,10h
  859.         jne     invalid_operand
  860.       mov_sreg_reg:
  861.         lods    byte [esi]
  862.         call    convert_register
  863.         or      ah,ah
  864.         jz      mov_sreg_reg_size_ok
  865.         cmp     ah,2
  866.         jne     invalid_operand_size
  867.         mov     bl,al
  868.       mov_sreg_reg_size_ok:
  869.         mov     [base_code],8Eh
  870.         jmp     nomem_instruction_ready
  871.       mov_sreg_mem:
  872.         call    get_address
  873.         mov     al,[operand_size]
  874.         or      al,al
  875.         jz      mov_sreg_mem_size_ok
  876.         cmp     al,2
  877.         jne     invalid_operand_size
  878.       mov_sreg_mem_size_ok:
  879.         mov     [base_code],8Eh
  880.         jmp     instruction_ready
  881.       mov_creg:
  882.         lods    byte [esi]
  883.         mov     ah,al
  884.         shr     ah,4
  885.         cmp     ah,4
  886.         ja      invalid_operand
  887.         add     ah,22h
  888.         mov     [extended_code],ah
  889.         and     al,1111b
  890.         mov     [postbyte_register],al
  891.         mov     [base_code],0Fh
  892.         lods    byte [esi]
  893.         cmp     al,','
  894.         jne     invalid_operand
  895.         call    take_register
  896.         mov     bl,al
  897.         cmp     [code_type],64
  898.         je      mov_creg_64bit
  899.         cmp     ah,4
  900.         jne     invalid_operand_size
  901.         cmp     [postbyte_register],8
  902.         jb      mov_creg_store
  903.         cmp     [extended_code],22h
  904.         jne     mov_creg_store
  905.         mov     al,0F0h
  906.         stos    byte [edi]
  907.         mov     [postbyte_register],0
  908.       mov_creg_store:
  909.         jmp     nomem_instruction_ready
  910.       mov_creg_64bit:
  911.         cmp     ah,8
  912.         je      mov_creg_store
  913.         jmp     invalid_operand_size
  914. test_instruction:
  915.         mov     [base_code],84h
  916.         lods    byte [esi]
  917.         call    get_size_operator
  918.         cmp     al,10h
  919.         je      test_reg
  920.         cmp     al,'['
  921.         jne     invalid_operand
  922.       test_mem:
  923.         call    get_address
  924.         push    edx ebx ecx
  925.         lods    byte [esi]
  926.         cmp     al,','
  927.         jne     invalid_operand
  928.         lods    byte [esi]
  929.         call    get_size_operator
  930.         cmp     al,'('
  931.         je      test_mem_imm
  932.         cmp     al,10h
  933.         jne     invalid_operand
  934.       test_mem_reg:
  935.         lods    byte [esi]
  936.         call    convert_register
  937.         mov     [postbyte_register],al
  938.         pop     ecx ebx edx
  939.         mov     al,ah
  940.         cmp     al,1
  941.         je      test_mem_reg_8bit
  942.         call    operand_autodetect
  943.         inc     [base_code]
  944.       test_mem_reg_8bit:
  945.         jmp     instruction_ready
  946.       test_mem_imm:
  947.         mov     al,[operand_size]
  948.         cmp     al,1
  949.         jb      test_mem_imm_nosize
  950.         je      test_mem_imm_8bit
  951.         cmp     al,2
  952.         je      test_mem_imm_16bit
  953.         cmp     al,4
  954.         je      test_mem_imm_32bit
  955.         cmp     al,8
  956.         jne     invalid_operand_size
  957.       test_mem_imm_64bit:
  958.         cmp     [size_declared],0
  959.         jne     long_immediate_not_encodable
  960.         call    operand_64bit
  961.         call    get_simm32
  962.         cmp     [value_type],4
  963.         jae     long_immediate_not_encodable
  964.         jmp     test_mem_imm_32bit_store
  965.       test_mem_imm_nosize:
  966.         call    recoverable_unknown_size
  967.       test_mem_imm_8bit:
  968.         call    get_byte_value
  969.         mov     byte [value],al
  970.         mov     [postbyte_register],0
  971.         mov     [base_code],0F6h
  972.         pop     ecx ebx edx
  973.         call    store_instruction_with_imm8
  974.         jmp     instruction_assembled
  975.       test_mem_imm_16bit:
  976.         call    operand_16bit
  977.         call    get_word_value
  978.         mov     word [value],ax
  979.         mov     [postbyte_register],0
  980.         mov     [base_code],0F7h
  981.         pop     ecx ebx edx
  982.         call    store_instruction_with_imm16
  983.         jmp     instruction_assembled
  984.       test_mem_imm_32bit:
  985.         call    operand_32bit
  986.         call    get_dword_value
  987.       test_mem_imm_32bit_store:
  988.         mov     dword [value],eax
  989.         mov     [postbyte_register],0
  990.         mov     [base_code],0F7h
  991.         pop     ecx ebx edx
  992.         call    store_instruction_with_imm32
  993.         jmp     instruction_assembled
  994.       test_reg:
  995.         lods    byte [esi]
  996.         call    convert_register
  997.         mov     [postbyte_register],al
  998.         lods    byte [esi]
  999.         cmp     al,','
  1000.         jne     invalid_operand
  1001.         lods    byte [esi]
  1002.         call    get_size_operator
  1003.         cmp     al,'['
  1004.         je      test_reg_mem
  1005.         cmp     al,'('
  1006.         je      test_reg_imm
  1007.         cmp     al,10h
  1008.         jne     invalid_operand
  1009.       test_reg_reg:
  1010.         lods    byte [esi]
  1011.         call    convert_register
  1012.         mov     bl,[postbyte_register]
  1013.         mov     [postbyte_register],al
  1014.         mov     al,ah
  1015.         cmp     al,1
  1016.         je      test_reg_reg_8bit
  1017.         call    operand_autodetect
  1018.         inc     [base_code]
  1019.       test_reg_reg_8bit:
  1020.         jmp     nomem_instruction_ready
  1021.       test_reg_imm:
  1022.         mov     al,[operand_size]
  1023.         cmp     al,1
  1024.         je      test_reg_imm_8bit
  1025.         cmp     al,2
  1026.         je      test_reg_imm_16bit
  1027.         cmp     al,4
  1028.         je      test_reg_imm_32bit
  1029.         cmp     al,8
  1030.         jne     invalid_operand_size
  1031.       test_reg_imm_64bit:
  1032.         cmp     [size_declared],0
  1033.         jne     long_immediate_not_encodable
  1034.         call    operand_64bit
  1035.         call    get_simm32
  1036.         cmp     [value_type],4
  1037.         jae     long_immediate_not_encodable
  1038.         jmp     test_reg_imm_32bit_store
  1039.       test_reg_imm_8bit:
  1040.         call    get_byte_value
  1041.         mov     dl,al
  1042.         mov     bl,[postbyte_register]
  1043.         mov     [postbyte_register],0
  1044.         mov     [base_code],0F6h
  1045.         or      bl,bl
  1046.         jz      test_al_imm
  1047.         call    store_nomem_instruction
  1048.         mov     al,dl
  1049.         stos    byte [edi]
  1050.         jmp     instruction_assembled
  1051.       test_al_imm:
  1052.         mov     [base_code],0A8h
  1053.         call    store_classic_instruction_code
  1054.         mov     al,dl
  1055.         stos    byte [edi]
  1056.         jmp     instruction_assembled
  1057.       test_reg_imm_16bit:
  1058.         call    operand_16bit
  1059.         call    get_word_value
  1060.         mov     dx,ax
  1061.         mov     bl,[postbyte_register]
  1062.         mov     [postbyte_register],0
  1063.         mov     [base_code],0F7h
  1064.         or      bl,bl
  1065.         jz      test_ax_imm
  1066.         call    store_nomem_instruction
  1067.         mov     ax,dx
  1068.         call    mark_relocation
  1069.         stos    word [edi]
  1070.         jmp     instruction_assembled
  1071.       test_ax_imm:
  1072.         mov     [base_code],0A9h
  1073.         call    store_classic_instruction_code
  1074.         mov     ax,dx
  1075.         stos    word [edi]
  1076.         jmp     instruction_assembled
  1077.       test_reg_imm_32bit:
  1078.         call    operand_32bit
  1079.         call    get_dword_value
  1080.       test_reg_imm_32bit_store:
  1081.         mov     edx,eax
  1082.         mov     bl,[postbyte_register]
  1083.         mov     [postbyte_register],0
  1084.         mov     [base_code],0F7h
  1085.         or      bl,bl
  1086.         jz      test_eax_imm
  1087.         call    store_nomem_instruction
  1088.         mov     eax,edx
  1089.         call    mark_relocation
  1090.         stos    dword [edi]
  1091.         jmp     instruction_assembled
  1092.       test_eax_imm:
  1093.         mov     [base_code],0A9h
  1094.         call    store_classic_instruction_code
  1095.         mov     eax,edx
  1096.         stos    dword [edi]
  1097.         jmp     instruction_assembled
  1098.       test_reg_mem:
  1099.         call    get_address
  1100.         mov     al,[operand_size]
  1101.         cmp     al,1
  1102.         je      test_reg_mem_8bit
  1103.         call    operand_autodetect
  1104.         inc     [base_code]
  1105.       test_reg_mem_8bit:
  1106.         jmp     instruction_ready
  1107. xchg_instruction:
  1108.         mov     [base_code],86h
  1109.         lods    byte [esi]
  1110.         call    get_size_operator
  1111.         cmp     al,10h
  1112.         je      xchg_reg
  1113.         cmp     al,'['
  1114.         jne     invalid_operand
  1115.       xchg_mem:
  1116.         call    get_address
  1117.         push    edx ebx ecx
  1118.         lods    byte [esi]
  1119.         cmp     al,','
  1120.         jne     invalid_operand
  1121.         lods    byte [esi]
  1122.         call    get_size_operator
  1123.         cmp     al,10h
  1124.         je      test_mem_reg
  1125.         jmp     invalid_operand
  1126.       xchg_reg:
  1127.         lods    byte [esi]
  1128.         call    convert_register
  1129.         mov     [postbyte_register],al
  1130.         lods    byte [esi]
  1131.         cmp     al,','
  1132.         jne     invalid_operand
  1133.         lods    byte [esi]
  1134.         call    get_size_operator
  1135.         cmp     al,'['
  1136.         je      test_reg_mem
  1137.         cmp     al,10h
  1138.         jne     invalid_operand
  1139.       xchg_reg_reg:
  1140.         lods    byte [esi]
  1141.         call    convert_register
  1142.         mov     bl,al
  1143.         mov     al,ah
  1144.         cmp     al,1
  1145.         je      xchg_reg_reg_8bit
  1146.         call    operand_autodetect
  1147.         cmp     [postbyte_register],0
  1148.         je      xchg_ax_reg
  1149.         or      bl,bl
  1150.         jnz     xchg_reg_reg_store
  1151.         mov     bl,[postbyte_register]
  1152.       xchg_ax_reg:
  1153.         cmp     [code_type],64
  1154.         jne     xchg_ax_reg_ok
  1155.         cmp     ah,4
  1156.         jne     xchg_ax_reg_ok
  1157.         or      bl,bl
  1158.         jz      xchg_reg_reg_store
  1159.       xchg_ax_reg_ok:
  1160.         test    bl,1000b
  1161.         jz      xchg_ax_reg_store
  1162.         or      [rex_prefix],41h
  1163.         and     bl,111b
  1164.       xchg_ax_reg_store:
  1165.         add     bl,90h
  1166.         mov     [base_code],bl
  1167.         call    store_classic_instruction_code
  1168.         jmp     instruction_assembled
  1169.       xchg_reg_reg_store:
  1170.         inc     [base_code]
  1171.       xchg_reg_reg_8bit:
  1172.         jmp     nomem_instruction_ready
  1173. push_instruction:
  1174.         mov     [push_size],al
  1175.       push_next:
  1176.         lods    byte [esi]
  1177.         call    get_size_operator
  1178.         cmp     al,10h
  1179.         je      push_reg
  1180.         cmp     al,'('
  1181.         je      push_imm
  1182.         cmp     al,'['
  1183.         jne     invalid_operand
  1184.       push_mem:
  1185.         call    get_address
  1186.         mov     al,[operand_size]
  1187.         mov     ah,[push_size]
  1188.         cmp     al,2
  1189.         je      push_mem_16bit
  1190.         cmp     al,4
  1191.         je      push_mem_32bit
  1192.         cmp     al,8
  1193.         je      push_mem_64bit
  1194.         or      al,al
  1195.         jnz     invalid_operand_size
  1196.         cmp     ah,2
  1197.         je      push_mem_16bit
  1198.         cmp     ah,4
  1199.         je      push_mem_32bit
  1200.         cmp     ah,8
  1201.         je      push_mem_64bit
  1202.         call    recoverable_unknown_size
  1203.         jmp     push_mem_store
  1204.       push_mem_16bit:
  1205.         test    ah,not 2
  1206.         jnz     invalid_operand_size
  1207.         call    operand_16bit
  1208.         jmp     push_mem_store
  1209.       push_mem_32bit:
  1210.         test    ah,not 4
  1211.         jnz     invalid_operand_size
  1212.         cmp     [code_type],64
  1213.         je      illegal_instruction
  1214.         call    operand_32bit
  1215.         jmp     push_mem_store
  1216.       push_mem_64bit:
  1217.         test    ah,not 8
  1218.         jnz     invalid_operand_size
  1219.         cmp     [code_type],64
  1220.         jne     illegal_instruction
  1221.       push_mem_store:
  1222.         mov     [base_code],0FFh
  1223.         mov     [postbyte_register],110b
  1224.         call    store_instruction
  1225.         jmp     push_done
  1226.       push_reg:
  1227.         lods    byte [esi]
  1228.         mov     ah,al
  1229.         sub     ah,10h
  1230.         and     ah,al
  1231.         test    ah,0F0h
  1232.         jnz     push_sreg
  1233.         call    convert_register
  1234.         test    al,1000b
  1235.         jz      push_reg_ok
  1236.         or      [rex_prefix],41h
  1237.         and     al,111b
  1238.       push_reg_ok:
  1239.         add     al,50h
  1240.         mov     [base_code],al
  1241.         mov     al,ah
  1242.         mov     ah,[push_size]
  1243.         cmp     al,2
  1244.         je      push_reg_16bit
  1245.         cmp     al,4
  1246.         je      push_reg_32bit
  1247.         cmp     al,8
  1248.         jne     invalid_operand_size
  1249.       push_reg_64bit:
  1250.         test    ah,not 8
  1251.         jnz     invalid_operand_size
  1252.         cmp     [code_type],64
  1253.         jne     illegal_instruction
  1254.         jmp     push_reg_store
  1255.       push_reg_32bit:
  1256.         test    ah,not 4
  1257.         jnz     invalid_operand_size
  1258.         cmp     [code_type],64
  1259.         je      illegal_instruction
  1260.         call    operand_32bit
  1261.         jmp     push_reg_store
  1262.       push_reg_16bit:
  1263.         test    ah,not 2
  1264.         jnz     invalid_operand_size
  1265.         call    operand_16bit
  1266.       push_reg_store:
  1267.         call    store_classic_instruction_code
  1268.         jmp     push_done
  1269.       push_sreg:
  1270.         mov     bl,al
  1271.         mov     dl,[operand_size]
  1272.         mov     dh,[push_size]
  1273.         cmp     dl,2
  1274.         je      push_sreg16
  1275.         cmp     dl,4
  1276.         je      push_sreg32
  1277.         cmp     dl,8
  1278.         je      push_sreg64
  1279.         or      dl,dl
  1280.         jnz     invalid_operand_size
  1281.         cmp     dh,2
  1282.         je      push_sreg16
  1283.         cmp     dh,4
  1284.         je      push_sreg32
  1285.         cmp     dh,8
  1286.         je      push_sreg64
  1287.         jmp     push_sreg_store
  1288.       push_sreg16:
  1289.         test    dh,not 2
  1290.         jnz     invalid_operand_size
  1291.         call    operand_16bit
  1292.         jmp     push_sreg_store
  1293.       push_sreg32:
  1294.         test    dh,not 4
  1295.         jnz     invalid_operand_size
  1296.         cmp     [code_type],64
  1297.         je      illegal_instruction
  1298.         call    operand_32bit
  1299.         jmp     push_sreg_store
  1300.       push_sreg64:
  1301.         test    dh,not 8
  1302.         jnz     invalid_operand_size
  1303.         cmp     [code_type],64
  1304.         jne     illegal_instruction
  1305.       push_sreg_store:
  1306.         mov     al,bl
  1307.         cmp     al,40h
  1308.         jae     invalid_operand
  1309.         sub     al,31h
  1310.         jc      invalid_operand
  1311.         cmp     al,4
  1312.         jae     push_sreg_386
  1313.         shl     al,3
  1314.         add     al,6
  1315.         mov     [base_code],al
  1316.         cmp     [code_type],64
  1317.         je      illegal_instruction
  1318.         jmp     push_reg_store
  1319.       push_sreg_386:
  1320.         sub     al,4
  1321.         shl     al,3
  1322.         add     al,0A0h
  1323.         mov     [extended_code],al
  1324.         mov     [base_code],0Fh
  1325.         jmp     push_reg_store
  1326.       push_imm:
  1327.         mov     al,[operand_size]
  1328.         mov     ah,[push_size]
  1329.         or      al,al
  1330.         je      push_imm_size_ok
  1331.         or      ah,ah
  1332.         je      push_imm_size_ok
  1333.         cmp     al,ah
  1334.         jne     invalid_operand_size
  1335.       push_imm_size_ok:
  1336.         cmp     al,2
  1337.         je      push_imm_16bit
  1338.         cmp     al,4
  1339.         je      push_imm_32bit
  1340.         cmp     al,8
  1341.         je      push_imm_64bit
  1342.         cmp     ah,2
  1343.         je      push_imm_optimized_16bit
  1344.         cmp     ah,4
  1345.         je      push_imm_optimized_32bit
  1346.         cmp     ah,8
  1347.         je      push_imm_optimized_64bit
  1348.         or      al,al
  1349.         jnz     invalid_operand_size
  1350.         cmp     [code_type],16
  1351.         je      push_imm_optimized_16bit
  1352.         cmp     [code_type],32
  1353.         je      push_imm_optimized_32bit
  1354.       push_imm_optimized_64bit:
  1355.         cmp     [code_type],64
  1356.         jne     illegal_instruction
  1357.         call    get_simm32
  1358.         mov     edx,eax
  1359.         cmp     [value_type],0
  1360.         jne     push_imm_32bit_store
  1361.         cmp     eax,-80h
  1362.         jl      push_imm_32bit_store
  1363.         cmp     eax,80h
  1364.         jge     push_imm_32bit_store
  1365.         jmp     push_imm_8bit
  1366.       push_imm_optimized_32bit:
  1367.         cmp     [code_type],64
  1368.         je      illegal_instruction
  1369.         call    get_dword_value
  1370.         mov     edx,eax
  1371.         call    operand_32bit
  1372.         cmp     [value_type],0
  1373.         jne     push_imm_32bit_store
  1374.         cmp     eax,-80h
  1375.         jl      push_imm_32bit_store
  1376.         cmp     eax,80h
  1377.         jge     push_imm_32bit_store
  1378.         jmp     push_imm_8bit
  1379.       push_imm_optimized_16bit:
  1380.         call    get_word_value
  1381.         mov     dx,ax
  1382.         call    operand_16bit
  1383.         cmp     [value_type],0
  1384.         jne     push_imm_16bit_store
  1385.         cmp     ax,-80h
  1386.         jl      push_imm_16bit_store
  1387.         cmp     ax,80h
  1388.         jge     push_imm_16bit_store
  1389.       push_imm_8bit:
  1390.         mov     ah,al
  1391.         mov     [base_code],6Ah
  1392.         call    store_classic_instruction_code
  1393.         mov     al,ah
  1394.         stos    byte [edi]
  1395.         jmp     push_done
  1396.       push_imm_16bit:
  1397.         call    get_word_value
  1398.         mov     dx,ax
  1399.         call    operand_16bit
  1400.       push_imm_16bit_store:
  1401.         mov     [base_code],68h
  1402.         call    store_classic_instruction_code
  1403.         mov     ax,dx
  1404.         call    mark_relocation
  1405.         stos    word [edi]
  1406.         jmp     push_done
  1407.       push_imm_64bit:
  1408.         cmp     [code_type],64
  1409.         jne     illegal_instruction
  1410.         call    get_simm32
  1411.         mov     edx,eax
  1412.         jmp     push_imm_32bit_store
  1413.       push_imm_32bit:
  1414.         cmp     [code_type],64
  1415.         je      illegal_instruction
  1416.         call    get_dword_value
  1417.         mov     edx,eax
  1418.         call    operand_32bit
  1419.       push_imm_32bit_store:
  1420.         mov     [base_code],68h
  1421.         call    store_classic_instruction_code
  1422.         mov     eax,edx
  1423.         call    mark_relocation
  1424.         stos    dword [edi]
  1425.       push_done:
  1426.         lods    byte [esi]
  1427.         dec     esi
  1428.         cmp     al,0Fh
  1429.         je      instruction_assembled
  1430.         or      al,al
  1431.         jz      instruction_assembled
  1432. ;        mov     [operand_size],0
  1433. ;        mov     [operand_flags],0
  1434. ;        mov     [operand_prefix],0
  1435. ;        mov     [rex_prefix],0
  1436.         and     dword [operand_size],0
  1437.         jmp     push_next
  1438. pop_instruction:
  1439.         mov     [push_size],al
  1440.       pop_next:
  1441.         lods    byte [esi]
  1442.         call    get_size_operator
  1443.         cmp     al,10h
  1444.         je      pop_reg
  1445.         cmp     al,'['
  1446.         jne     invalid_operand
  1447.       pop_mem:
  1448.         call    get_address
  1449.         mov     al,[operand_size]
  1450.         mov     ah,[push_size]
  1451.         cmp     al,2
  1452.         je      pop_mem_16bit
  1453.         cmp     al,4
  1454.         je      pop_mem_32bit
  1455.         cmp     al,8
  1456.         je      pop_mem_64bit
  1457.         or      al,al
  1458.         jnz     invalid_operand_size
  1459.         cmp     ah,2
  1460.         je      pop_mem_16bit
  1461.         cmp     ah,4
  1462.         je      pop_mem_32bit
  1463.         cmp     ah,8
  1464.         je      pop_mem_64bit
  1465.         call    recoverable_unknown_size
  1466.         jmp     pop_mem_store
  1467.       pop_mem_16bit:
  1468.         test    ah,not 2
  1469.         jnz     invalid_operand_size
  1470.         call    operand_16bit
  1471.         jmp     pop_mem_store
  1472.       pop_mem_32bit:
  1473.         test    ah,not 4
  1474.         jnz     invalid_operand_size
  1475.         cmp     [code_type],64
  1476.         je      illegal_instruction
  1477.         call    operand_32bit
  1478.         jmp     pop_mem_store
  1479.       pop_mem_64bit:
  1480.         test    ah,not 8
  1481.         jnz     invalid_operand_size
  1482.         cmp     [code_type],64
  1483.         jne     illegal_instruction
  1484.       pop_mem_store:
  1485.         mov     [base_code],08Fh
  1486.         mov     [postbyte_register],0
  1487.         call    store_instruction
  1488.         jmp     pop_done
  1489.       pop_reg:
  1490.         lods    byte [esi]
  1491.         mov     ah,al
  1492.         sub     ah,10h
  1493.         and     ah,al
  1494.         test    ah,0F0h
  1495.         jnz     pop_sreg
  1496.         call    convert_register
  1497.         test    al,1000b
  1498.         jz      pop_reg_ok
  1499.         or      [rex_prefix],41h
  1500.         and     al,111b
  1501.       pop_reg_ok:
  1502.         add     al,58h
  1503.         mov     [base_code],al
  1504.         mov     al,ah
  1505.         mov     ah,[push_size]
  1506.         cmp     al,2
  1507.         je      pop_reg_16bit
  1508.         cmp     al,4
  1509.         je      pop_reg_32bit
  1510.         cmp     al,8
  1511.         je      pop_reg_64bit
  1512.         jmp     invalid_operand_size
  1513.       pop_reg_64bit:
  1514.         test    ah,not 8
  1515.         jnz     invalid_operand_size
  1516.         cmp     [code_type],64
  1517.         jne     illegal_instruction
  1518.         jmp     pop_reg_store
  1519.       pop_reg_32bit:
  1520.         test    ah,not 4
  1521.         jnz     invalid_operand_size
  1522.         cmp     [code_type],64
  1523.         je      illegal_instruction
  1524.         call    operand_32bit
  1525.         jmp     pop_reg_store
  1526.       pop_reg_16bit:
  1527.         test    ah,not 2
  1528.         jnz     invalid_operand_size
  1529.         call    operand_16bit
  1530.       pop_reg_store:
  1531.         call    store_classic_instruction_code
  1532.       pop_done:
  1533.         lods    byte [esi]
  1534.         dec     esi
  1535.         cmp     al,0Fh
  1536.         je      instruction_assembled
  1537.         or      al,al
  1538.         jz      instruction_assembled
  1539. ;        mov     [operand_size],0
  1540. ;        mov     [operand_flags],0
  1541. ;        mov     [operand_prefix],0
  1542. ;        mov     [rex_prefix],0
  1543.         and     dword [operand_size],0
  1544.         jmp     pop_next
  1545.       pop_sreg:
  1546.         mov     dl,[operand_size]
  1547.         mov     dh,[push_size]
  1548.         cmp     al,32h
  1549.         je      pop_cs
  1550.         mov     bl,al
  1551.         cmp     dl,2
  1552.         je      pop_sreg16
  1553.         cmp     dl,4
  1554.         je      pop_sreg32
  1555.         cmp     dl,8
  1556.         je      pop_sreg64
  1557.         or      dl,dl
  1558.         jnz     invalid_operand_size
  1559.         cmp     dh,2
  1560.         je      pop_sreg16
  1561.         cmp     dh,4
  1562.         je      pop_sreg32
  1563.         cmp     dh,8
  1564.         je      pop_sreg64
  1565.         jmp     pop_sreg_store
  1566.       pop_sreg16:
  1567.         test    dh,not 2
  1568.         jnz     invalid_operand_size
  1569.         call    operand_16bit
  1570.         jmp     pop_sreg_store
  1571.       pop_sreg32:
  1572.         test    dh,not 4
  1573.         jnz     invalid_operand_size
  1574.         cmp     [code_type],64
  1575.         je      illegal_instruction
  1576.         call    operand_32bit
  1577.         jmp     pop_sreg_store
  1578.       pop_sreg64:
  1579.         test    dh,not 8
  1580.         jnz     invalid_operand_size
  1581.         cmp     [code_type],64
  1582.         jne     illegal_instruction
  1583.       pop_sreg_store:
  1584.         mov     al,bl
  1585.         cmp     al,40h
  1586.         jae     invalid_operand
  1587.         sub     al,31h
  1588.         jc      invalid_operand
  1589.         cmp     al,4
  1590.         jae     pop_sreg_386
  1591.         shl     al,3
  1592.         add     al,7
  1593.         mov     [base_code],al
  1594.         cmp     [code_type],64
  1595.         je      illegal_instruction
  1596.         jmp     pop_reg_store
  1597.       pop_cs:
  1598.         cmp     [code_type],16
  1599.         jne     illegal_instruction
  1600.         cmp     dl,2
  1601.         je      pop_cs_store
  1602.         or      dl,dl
  1603.         jnz     invalid_operand_size
  1604.         cmp     dh,2
  1605.         je      pop_cs_store
  1606.         or      dh,dh
  1607.         jnz     illegal_instruction
  1608.       pop_cs_store:
  1609.         test    dh,not 2
  1610.         jnz     invalid_operand_size
  1611.         mov     al,0Fh
  1612.         stos    byte [edi]
  1613.         jmp     pop_done
  1614.       pop_sreg_386:
  1615.         sub     al,4
  1616.         shl     al,3
  1617.         add     al,0A1h
  1618.         mov     [extended_code],al
  1619.         mov     [base_code],0Fh
  1620.         jmp     pop_reg_store
  1621. inc_instruction:
  1622.         mov     [base_code],al
  1623.         lods    byte [esi]
  1624.         call    get_size_operator
  1625.         cmp     al,10h
  1626.         je      inc_reg
  1627.         cmp     al,'['
  1628.         je      inc_mem
  1629.         jne     invalid_operand
  1630.       inc_mem:
  1631.         call    get_address
  1632.         mov     al,[operand_size]
  1633.         cmp     al,1
  1634.         je      inc_mem_8bit
  1635.         jb      inc_mem_nosize
  1636.         call    operand_autodetect
  1637.         mov     al,0FFh
  1638.         xchg    al,[base_code]
  1639.         mov     [postbyte_register],al
  1640.         jmp     instruction_ready
  1641.       inc_mem_nosize:
  1642.         call    recoverable_unknown_size
  1643.       inc_mem_8bit:
  1644.         mov     al,0FEh
  1645.         xchg    al,[base_code]
  1646.         mov     [postbyte_register],al
  1647.         jmp     instruction_ready
  1648.       inc_reg:
  1649.         lods    byte [esi]
  1650.         call    convert_register
  1651.         mov     bl,al
  1652.         mov     al,0FEh
  1653.         xchg    al,[base_code]
  1654.         mov     [postbyte_register],al
  1655.         mov     al,ah
  1656.         cmp     al,1
  1657.         je      inc_reg_8bit
  1658.         call    operand_autodetect
  1659.         cmp     [code_type],64
  1660.         je      inc_reg_long_form
  1661.         mov     al,[postbyte_register]
  1662.         shl     al,3
  1663.         add     al,bl
  1664.         add     al,40h
  1665.         mov     [base_code],al
  1666.         call    store_classic_instruction_code
  1667.         jmp     instruction_assembled
  1668.       inc_reg_long_form:
  1669.         inc     [base_code]
  1670.       inc_reg_8bit:
  1671.         jmp     nomem_instruction_ready
  1672. set_instruction:
  1673.         mov     [base_code],0Fh
  1674.         mov     [extended_code],al
  1675.         lods    byte [esi]
  1676.         call    get_size_operator
  1677.         cmp     al,10h
  1678.         je      set_reg
  1679.         cmp     al,'['
  1680.         jne     invalid_operand
  1681.       set_mem:
  1682.         call    get_address
  1683.         cmp     [operand_size],1
  1684.         ja      invalid_operand_size
  1685.         mov     [postbyte_register],0
  1686.         jmp     instruction_ready
  1687.       set_reg:
  1688.         lods    byte [esi]
  1689.         call    convert_register
  1690.         cmp     ah,1
  1691.         jne     invalid_operand_size
  1692.         mov     bl,al
  1693.         mov     [postbyte_register],0
  1694.         jmp     nomem_instruction_ready
  1695. arpl_instruction:
  1696.         cmp     [code_type],64
  1697.         je      illegal_instruction
  1698.         mov     [base_code],63h
  1699.         lods    byte [esi]
  1700.         call    get_size_operator
  1701.         cmp     al,10h
  1702.         je      arpl_reg
  1703.         cmp     al,'['
  1704.         jne     invalid_operand
  1705.         call    get_address
  1706.         lods    byte [esi]
  1707.         cmp     al,','
  1708.         jne     invalid_operand
  1709.         call    take_register
  1710.         mov     [postbyte_register],al
  1711.         cmp     ah,2
  1712.         jne     invalid_operand_size
  1713.         jmp     instruction_ready
  1714.       arpl_reg:
  1715.         lods    byte [esi]
  1716.         call    convert_register
  1717.         cmp     ah,2
  1718.         jne     invalid_operand_size
  1719.         mov     bl,al
  1720.         lods    byte [esi]
  1721.         cmp     al,','
  1722.         jne     invalid_operand
  1723.         call    take_register
  1724.         mov     [postbyte_register],al
  1725.         jmp     nomem_instruction_ready
  1726. bound_instruction:
  1727.         cmp     [code_type],64
  1728.         je      illegal_instruction
  1729.         call    take_register
  1730.         mov     [postbyte_register],al
  1731.         lods    byte [esi]
  1732.         cmp     al,','
  1733.         jne     invalid_operand
  1734.         lods    byte [esi]
  1735.         call    get_size_operator
  1736.         cmp     al,'['
  1737.         jne     invalid_operand
  1738.         call    get_address
  1739.         mov     al,[operand_size]
  1740.         cmp     al,2
  1741.         je      bound_store
  1742.         cmp     al,4
  1743.         jne     invalid_operand_size
  1744.       bound_store:
  1745.         call    operand_autodetect
  1746.         mov     [base_code],62h
  1747.         jmp     instruction_ready
  1748. enter_instruction:
  1749.         lods    byte [esi]
  1750.         call    get_size_operator
  1751.         cmp     ah,2
  1752.         je      enter_imm16_size_ok
  1753.         or      ah,ah
  1754.         jnz     invalid_operand_size
  1755.       enter_imm16_size_ok:
  1756.         cmp     al,'('
  1757.         jne     invalid_operand
  1758.         call    get_word_value
  1759.         cmp     [next_pass_needed],0
  1760.         jne     enter_imm16_ok
  1761.         cmp     [value_type],0
  1762.         jne     invalid_use_of_symbol
  1763.         test    eax,eax
  1764.         js      value_out_of_range
  1765.       enter_imm16_ok:
  1766.         push    eax
  1767.         mov     [operand_size],0
  1768.         lods    byte [esi]
  1769.         cmp     al,','
  1770.         jne     invalid_operand
  1771.         lods    byte [esi]
  1772.         call    get_size_operator
  1773.         cmp     ah,1
  1774.         je      enter_imm8_size_ok
  1775.         or      ah,ah
  1776.         jnz     invalid_operand_size
  1777.       enter_imm8_size_ok:
  1778.         cmp     al,'('
  1779.         jne     invalid_operand
  1780.         call    get_byte_value
  1781.         cmp     [next_pass_needed],0
  1782.         jne     enter_imm8_ok
  1783.         test    eax,eax
  1784.         js      value_out_of_range
  1785.       enter_imm8_ok:
  1786.         mov     dl,al
  1787.         pop     ebx
  1788.         mov     al,0C8h
  1789.         stos    byte [edi]
  1790.         mov     ax,bx
  1791.         stos    word [edi]
  1792.         mov     al,dl
  1793.         stos    byte [edi]
  1794.         jmp     instruction_assembled
  1795. ret_instruction_only64:
  1796.         cmp     [code_type],64
  1797.         jne     illegal_instruction
  1798.         jmp     ret_instruction
  1799. ret_instruction_32bit_except64:
  1800.         cmp     [code_type],64
  1801.         je      illegal_instruction
  1802. ret_instruction_32bit:
  1803.         call    operand_32bit
  1804.         jmp     ret_instruction
  1805. ret_instruction_16bit:
  1806.         call    operand_16bit
  1807.         jmp     ret_instruction
  1808. ret_instruction_64bit:
  1809.         call    operand_64bit
  1810. ret_instruction:
  1811.         and     [prefix_flags],not 10h
  1812.       ret_common:
  1813.         mov     [base_code],al
  1814.         lods    byte [esi]
  1815.         dec     esi
  1816.         or      al,al
  1817.         jz      simple_ret
  1818.         cmp     al,0Fh
  1819.         je      simple_ret
  1820.         lods    byte [esi]
  1821.         call    get_size_operator
  1822.         or      ah,ah
  1823.         jz      ret_imm
  1824.         cmp     ah,2
  1825.         je      ret_imm
  1826.         jmp     invalid_operand_size
  1827.       ret_imm:
  1828.         cmp     al,'('
  1829.         jne     invalid_operand
  1830.         call    get_word_value
  1831.         cmp     [next_pass_needed],0
  1832.         jne     ret_imm_ok
  1833.         cmp     [value_type],0
  1834.         jne     invalid_use_of_symbol
  1835.         test    eax,eax
  1836.         js      value_out_of_range
  1837.       ret_imm_ok:
  1838.         cmp     [size_declared],0
  1839.         jne     ret_imm_store
  1840.         or      ax,ax
  1841.         jz      simple_ret
  1842.       ret_imm_store:
  1843.         mov     dx,ax
  1844.         call    store_classic_instruction_code
  1845.         mov     ax,dx
  1846.         stos    word [edi]
  1847.         jmp     instruction_assembled
  1848.       simple_ret:
  1849.         inc     [base_code]
  1850.         call    store_classic_instruction_code
  1851.         jmp     instruction_assembled
  1852. retf_instruction:
  1853.         cmp     [code_type],64
  1854.         jne     ret_common
  1855. retf_instruction_64bit:
  1856.         call    operand_64bit
  1857.         jmp     ret_common
  1858. retf_instruction_32bit:
  1859.         call    operand_32bit
  1860.         jmp     ret_common
  1861. retf_instruction_16bit:
  1862.         call    operand_16bit
  1863.         jmp     ret_common
  1864. lea_instruction:
  1865.         mov     [base_code],8Dh
  1866.         call    take_register
  1867.         mov     [postbyte_register],al
  1868.         lods    byte [esi]
  1869.         cmp     al,','
  1870.         jne     invalid_operand
  1871.         xor     al,al
  1872.         xchg    al,[operand_size]
  1873.         push    eax
  1874.         lods    byte [esi]
  1875.         call    get_size_operator
  1876.         cmp     al,'['
  1877.         jne     invalid_operand
  1878.         or      [operand_flags],1
  1879.         call    get_address
  1880.         pop     eax
  1881.         mov     [operand_size],al
  1882.         call    operand_autodetect
  1883.         jmp     instruction_ready
  1884. ls_instruction:
  1885.         or      al,al
  1886.         jz      les_instruction
  1887.         cmp     al,3
  1888.         jz      lds_instruction
  1889.         add     al,0B0h
  1890.         mov     [extended_code],al
  1891.         mov     [base_code],0Fh
  1892.         jmp     ls_code_ok
  1893.       les_instruction:
  1894.         mov     [base_code],0C4h
  1895.         jmp     ls_short_code
  1896.       lds_instruction:
  1897.         mov     [base_code],0C5h
  1898.       ls_short_code:
  1899.         cmp     [code_type],64
  1900.         je      illegal_instruction
  1901.       ls_code_ok:
  1902.         call    take_register
  1903.         mov     [postbyte_register],al
  1904.         lods    byte [esi]
  1905.         cmp     al,','
  1906.         jne     invalid_operand
  1907.         add     [operand_size],2
  1908.         lods    byte [esi]
  1909.         call    get_size_operator
  1910.         cmp     al,'['
  1911.         jne     invalid_operand
  1912.         call    get_address
  1913.         mov     al,[operand_size]
  1914.         cmp     al,4
  1915.         je      ls_16bit
  1916.         cmp     al,6
  1917.         je      ls_32bit
  1918.         cmp     al,10
  1919.         je      ls_64bit
  1920.         jmp     invalid_operand_size
  1921.       ls_16bit:
  1922.         call    operand_16bit
  1923.         jmp     instruction_ready
  1924.       ls_32bit:
  1925.         call    operand_32bit
  1926.         jmp     instruction_ready
  1927.       ls_64bit:
  1928.         call    operand_64bit
  1929.         jmp     instruction_ready
  1930. sh_instruction:
  1931.         mov     [postbyte_register],al
  1932.         lods    byte [esi]
  1933.         call    get_size_operator
  1934.         cmp     al,10h
  1935.         je      sh_reg
  1936.         cmp     al,'['
  1937.         jne     invalid_operand
  1938.       sh_mem:
  1939.         call    get_address
  1940.         push    edx ebx ecx
  1941.         mov     al,[operand_size]
  1942.         push    eax
  1943.         mov     [operand_size],0
  1944.         lods    byte [esi]
  1945.         cmp     al,','
  1946.         jne     invalid_operand
  1947.         lods    byte [esi]
  1948.         call    get_size_operator
  1949.         cmp     al,'('
  1950.         je      sh_mem_imm
  1951.         cmp     al,10h
  1952.         jne     invalid_operand
  1953.       sh_mem_reg:
  1954.         lods    byte [esi]
  1955.         cmp     al,11h
  1956.         jne     invalid_operand
  1957.         pop     eax ecx ebx edx
  1958.         cmp     al,1
  1959.         je      sh_mem_cl_8bit
  1960.         jb      sh_mem_cl_nosize
  1961.         call    operand_autodetect
  1962.         mov     [base_code],0D3h
  1963.         jmp     instruction_ready
  1964.       sh_mem_cl_nosize:
  1965.         call    recoverable_unknown_size
  1966.       sh_mem_cl_8bit:
  1967.         mov     [base_code],0D2h
  1968.         jmp     instruction_ready
  1969.       sh_mem_imm:
  1970.         mov     al,[operand_size]
  1971.         or      al,al
  1972.         jz      sh_mem_imm_size_ok
  1973.         cmp     al,1
  1974.         jne     invalid_operand_size
  1975.       sh_mem_imm_size_ok:
  1976.         call    get_byte_value
  1977.         mov     byte [value],al
  1978.         pop     eax ecx ebx edx
  1979.         cmp     al,1
  1980.         je      sh_mem_imm_8bit
  1981.         jb      sh_mem_imm_nosize
  1982.         call    operand_autodetect
  1983.         cmp     byte [value],1
  1984.         je      sh_mem_1
  1985.         mov     [base_code],0C1h
  1986.         call    store_instruction_with_imm8
  1987.         jmp     instruction_assembled
  1988.       sh_mem_1:
  1989.         mov     [base_code],0D1h
  1990.         jmp     instruction_ready
  1991.       sh_mem_imm_nosize:
  1992.         call    recoverable_unknown_size
  1993.       sh_mem_imm_8bit:
  1994.         cmp     byte [value],1
  1995.         je      sh_mem_1_8bit
  1996.         mov     [base_code],0C0h
  1997.         call    store_instruction_with_imm8
  1998.         jmp     instruction_assembled
  1999.       sh_mem_1_8bit:
  2000.         mov     [base_code],0D0h
  2001.         jmp     instruction_ready
  2002.       sh_reg:
  2003.         lods    byte [esi]
  2004.         call    convert_register
  2005.         mov     bx,ax
  2006.         mov     [operand_size],0
  2007.         lods    byte [esi]
  2008.         cmp     al,','
  2009.         jne     invalid_operand
  2010.         lods    byte [esi]
  2011.         call    get_size_operator
  2012.         cmp     al,'('
  2013.         je      sh_reg_imm
  2014.         cmp     al,10h
  2015.         jne     invalid_operand
  2016.       sh_reg_reg:
  2017.         lods    byte [esi]
  2018.         cmp     al,11h
  2019.         jne     invalid_operand
  2020.         mov     al,bh
  2021.         cmp     al,1
  2022.         je      sh_reg_cl_8bit
  2023.         call    operand_autodetect
  2024.         mov     [base_code],0D3h
  2025.         jmp     nomem_instruction_ready
  2026.       sh_reg_cl_8bit:
  2027.         mov     [base_code],0D2h
  2028.         jmp     nomem_instruction_ready
  2029.       sh_reg_imm:
  2030.         mov     al,[operand_size]
  2031.         or      al,al
  2032.         jz      sh_reg_imm_size_ok
  2033.         cmp     al,1
  2034.         jne     invalid_operand_size
  2035.       sh_reg_imm_size_ok:
  2036.         push    ebx
  2037.         call    get_byte_value
  2038.         mov     dl,al
  2039.         pop     ebx
  2040.         mov     al,bh
  2041.         cmp     al,1
  2042.         je      sh_reg_imm_8bit
  2043.         call    operand_autodetect
  2044.         cmp     dl,1
  2045.         je      sh_reg_1
  2046.         mov     [base_code],0C1h
  2047.         call    store_nomem_instruction
  2048.         mov     al,dl
  2049.         stos    byte [edi]
  2050.         jmp     instruction_assembled
  2051.       sh_reg_1:
  2052.         mov     [base_code],0D1h
  2053.         jmp     nomem_instruction_ready
  2054.       sh_reg_imm_8bit:
  2055.         cmp     dl,1
  2056.         je      sh_reg_1_8bit
  2057.         mov     [base_code],0C0h
  2058.         call    store_nomem_instruction
  2059.         mov     al,dl
  2060.         stos    byte [edi]
  2061.         jmp     instruction_assembled
  2062.       sh_reg_1_8bit:
  2063.         mov     [base_code],0D0h
  2064.         jmp     nomem_instruction_ready
  2065. shd_instruction:
  2066.         mov     [base_code],0Fh
  2067.         mov     [extended_code],al
  2068.         lods    byte [esi]
  2069.         call    get_size_operator
  2070.         cmp     al,10h
  2071.         je      shd_reg
  2072.         cmp     al,'['
  2073.         jne     invalid_operand
  2074.       shd_mem:
  2075.         call    get_address
  2076.         push    edx ebx ecx
  2077.         lods    byte [esi]
  2078.         cmp     al,','
  2079.         jne     invalid_operand
  2080.         call    take_register
  2081.         mov     [postbyte_register],al
  2082.         lods    byte [esi]
  2083.         cmp     al,','
  2084.         jne     invalid_operand
  2085.         mov     al,ah
  2086.         mov     [operand_size],0
  2087.         push    eax
  2088.         lods    byte [esi]
  2089.         call    get_size_operator
  2090.         cmp     al,'('
  2091.         je      shd_mem_reg_imm
  2092.         cmp     al,10h
  2093.         jne     invalid_operand
  2094.         lods    byte [esi]
  2095.         cmp     al,11h
  2096.         jne     invalid_operand
  2097.         pop     eax ecx ebx edx
  2098.         call    operand_autodetect
  2099.         inc     [extended_code]
  2100.         jmp     instruction_ready
  2101.       shd_mem_reg_imm:
  2102.         mov     al,[operand_size]
  2103.         or      al,al
  2104.         jz      shd_mem_reg_imm_size_ok
  2105.         cmp     al,1
  2106.         jne     invalid_operand_size
  2107.       shd_mem_reg_imm_size_ok:
  2108.         call    get_byte_value
  2109.         mov     byte [value],al
  2110.         pop     eax ecx ebx edx
  2111.         call    operand_autodetect
  2112.         call    store_instruction_with_imm8
  2113.         jmp     instruction_assembled
  2114.       shd_reg:
  2115.         lods    byte [esi]
  2116.         call    convert_register
  2117.         mov     [postbyte_register],al
  2118.         lods    byte [esi]
  2119.         cmp     al,','
  2120.         jne     invalid_operand
  2121.         call    take_register
  2122.         mov     bl,[postbyte_register]
  2123.         mov     [postbyte_register],al
  2124.         mov     al,ah
  2125.         push    eax ebx
  2126.         lods    byte [esi]
  2127.         cmp     al,','
  2128.         jne     invalid_operand
  2129.         mov     [operand_size],0
  2130.         lods    byte [esi]
  2131.         call    get_size_operator
  2132.         cmp     al,'('
  2133.         je      shd_reg_reg_imm
  2134.         cmp     al,10h
  2135.         jne     invalid_operand
  2136.         lods    byte [esi]
  2137.         cmp     al,11h
  2138.         jne     invalid_operand
  2139.         pop     ebx eax
  2140.         call    operand_autodetect
  2141.         inc     [extended_code]
  2142.         jmp     nomem_instruction_ready
  2143.       shd_reg_reg_imm:
  2144.         mov     al,[operand_size]
  2145.         or      al,al
  2146.         jz      shd_reg_reg_imm_size_ok
  2147.         cmp     al,1
  2148.         jne     invalid_operand_size
  2149.       shd_reg_reg_imm_size_ok:
  2150.         call    get_byte_value
  2151.         mov     dl,al
  2152.         pop     ebx eax
  2153.         call    operand_autodetect
  2154.         call    store_nomem_instruction
  2155.         mov     al,dl
  2156.         stos    byte [edi]
  2157.         jmp     instruction_assembled
  2158. movx_instruction:
  2159.         mov     [base_code],0Fh
  2160.         mov     [extended_code],al
  2161.         call    take_register
  2162.         mov     [postbyte_register],al
  2163.         mov     al,ah
  2164.         push    eax
  2165.         lods    byte [esi]
  2166.         cmp     al,','
  2167.         jne     invalid_operand
  2168.         mov     [operand_size],0
  2169.         lods    byte [esi]
  2170.         call    get_size_operator
  2171.         cmp     al,10h
  2172.         je      movx_reg
  2173.         cmp     al,'['
  2174.         jne     invalid_operand
  2175.         call    get_address
  2176.         pop     eax
  2177.         mov     ah,[operand_size]
  2178.         or      ah,ah
  2179.         jz      movx_unknown_size
  2180.         cmp     ah,al
  2181.         jae     invalid_operand_size
  2182.         cmp     ah,1
  2183.         je      movx_mem_store
  2184.         cmp     ah,2
  2185.         jne     invalid_operand_size
  2186.         inc     [extended_code]
  2187.       movx_mem_store:
  2188.         call    operand_autodetect
  2189.         jmp     instruction_ready
  2190.       movx_unknown_size:
  2191.         call    recoverable_unknown_size
  2192.         jmp     movx_mem_store
  2193.       movx_reg:
  2194.         lods    byte [esi]
  2195.         call    convert_register
  2196.         pop     ebx
  2197.         xchg    bl,al
  2198.         cmp     ah,al
  2199.         jae     invalid_operand_size
  2200.         cmp     ah,1
  2201.         je      movx_reg_8bit
  2202.         cmp     ah,2
  2203.         je      movx_reg_16bit
  2204.         jmp     invalid_operand_size
  2205.       movx_reg_8bit:
  2206.         call    operand_autodetect
  2207.         jmp     nomem_instruction_ready
  2208.       movx_reg_16bit:
  2209.         call    operand_autodetect
  2210.         inc     [extended_code]
  2211.         jmp     nomem_instruction_ready
  2212. movsxd_instruction:
  2213.         mov     [base_code],al
  2214.         call    take_register
  2215.         mov     [postbyte_register],al
  2216.         cmp     ah,8
  2217.         jne     invalid_operand_size
  2218.         lods    byte [esi]
  2219.         cmp     al,','
  2220.         jne     invalid_operand
  2221.         mov     [operand_size],0
  2222.         lods    byte [esi]
  2223.         call    get_size_operator
  2224.         cmp     al,10h
  2225.         je      movsxd_reg
  2226.         cmp     al,'['
  2227.         jne     invalid_operand
  2228.         call    get_address
  2229.         cmp     [operand_size],4
  2230.         je      movsxd_mem_store
  2231.         cmp     [operand_size],0
  2232.         jne     invalid_operand_size
  2233.       movsxd_mem_store:
  2234.         call    operand_64bit
  2235.         jmp     instruction_ready
  2236.       movsxd_reg:
  2237.         lods    byte [esi]
  2238.         call    convert_register
  2239.         cmp     ah,4
  2240.         jne     invalid_operand_size
  2241.         mov     bl,al
  2242.         call    operand_64bit
  2243.         jmp     nomem_instruction_ready
  2244. bt_instruction:
  2245.         mov     [postbyte_register],al
  2246.         shl     al,3
  2247.         add     al,83h
  2248.         mov     [extended_code],al
  2249.         mov     [base_code],0Fh
  2250.         lods    byte [esi]
  2251.         call    get_size_operator
  2252.         cmp     al,10h
  2253.         je      bt_reg
  2254.         cmp     al,'['
  2255.         jne     invalid_operand
  2256.         call    get_address
  2257.         push    eax ebx ecx
  2258.         lods    byte [esi]
  2259.         cmp     al,','
  2260.         jne     invalid_operand
  2261.         cmp     byte [esi],'('
  2262.         je      bt_mem_imm
  2263.         cmp     byte [esi],11h
  2264.         jne     bt_mem_reg
  2265.         cmp     byte [esi+2],'('
  2266.         je      bt_mem_imm
  2267.       bt_mem_reg:
  2268.         call    take_register
  2269.         mov     [postbyte_register],al
  2270.         pop     ecx ebx edx
  2271.         mov     al,ah
  2272.         call    operand_autodetect
  2273.         jmp     instruction_ready
  2274.       bt_mem_imm:
  2275.         xor     al,al
  2276.         xchg    al,[operand_size]
  2277.         push    eax
  2278.         lods    byte [esi]
  2279.         call    get_size_operator
  2280.         cmp     al,'('
  2281.         jne     invalid_operand
  2282.         mov     al,[operand_size]
  2283.         or      al,al
  2284.         jz      bt_mem_imm_size_ok
  2285.         cmp     al,1
  2286.         jne     invalid_operand_size
  2287.       bt_mem_imm_size_ok:
  2288.         call    get_byte_value
  2289.         mov     byte [value],al
  2290.         pop     eax
  2291.         or      al,al
  2292.         jz      bt_mem_imm_nosize
  2293.         call    operand_autodetect
  2294.       bt_mem_imm_store:
  2295.         pop     ecx ebx edx
  2296.         mov     [extended_code],0BAh
  2297.         call    store_instruction_with_imm8
  2298.         jmp     instruction_assembled
  2299.       bt_mem_imm_nosize:
  2300.         call    recoverable_unknown_size
  2301.         jmp     bt_mem_imm_store
  2302.       bt_reg:
  2303.         lods    byte [esi]
  2304.         call    convert_register
  2305.         mov     bl,al
  2306.         lods    byte [esi]
  2307.         cmp     al,','
  2308.         jne     invalid_operand
  2309.         cmp     byte [esi],'('
  2310.         je      bt_reg_imm
  2311.         cmp     byte [esi],11h
  2312.         jne     bt_reg_reg
  2313.         cmp     byte [esi+2],'('
  2314.         je      bt_reg_imm
  2315.       bt_reg_reg:
  2316.         call    take_register
  2317.         mov     [postbyte_register],al
  2318.         mov     al,ah
  2319.         call    operand_autodetect
  2320.         jmp     nomem_instruction_ready
  2321.       bt_reg_imm:
  2322.         xor     al,al
  2323.         xchg    al,[operand_size]
  2324.         push    eax ebx
  2325.         lods    byte [esi]
  2326.         call    get_size_operator
  2327.         cmp     al,'('
  2328.         jne     invalid_operand
  2329.         mov     al,[operand_size]
  2330.         or      al,al
  2331.         jz      bt_reg_imm_size_ok
  2332.         cmp     al,1
  2333.         jne     invalid_operand_size
  2334.       bt_reg_imm_size_ok:
  2335.         call    get_byte_value
  2336.         mov     byte [value],al
  2337.         pop     ebx eax
  2338.         call    operand_autodetect
  2339.       bt_reg_imm_store:
  2340.         mov     [extended_code],0BAh
  2341.         call    store_nomem_instruction
  2342.         mov     al,byte [value]
  2343.         stos    byte [edi]
  2344.         jmp     instruction_assembled
  2345. bs_instruction:
  2346.         mov     [extended_code],al
  2347.         mov     [base_code],0Fh
  2348.         call    get_reg_mem
  2349.         jc      bs_reg_reg
  2350.         mov     al,[operand_size]
  2351.         call    operand_autodetect
  2352.         jmp     instruction_ready
  2353.       bs_reg_reg:
  2354.         mov     al,ah
  2355.         call    operand_autodetect
  2356.         jmp     nomem_instruction_ready
  2357.       get_reg_mem:
  2358.         call    take_register
  2359.         mov     [postbyte_register],al
  2360.         lods    byte [esi]
  2361.         cmp     al,','
  2362.         jne     invalid_operand
  2363.         lods    byte [esi]
  2364.         call    get_size_operator
  2365.         cmp     al,10h
  2366.         je      get_reg_reg
  2367.         cmp     al,'['
  2368.         jne     invalid_argument
  2369.         call    get_address
  2370.         clc
  2371.         ret
  2372.       get_reg_reg:
  2373.         lods    byte [esi]
  2374.         call    convert_register
  2375.         mov     bl,al
  2376.         stc
  2377.         ret
  2378.  
  2379. imul_instruction:
  2380.         mov     [base_code],0F6h
  2381.         mov     [postbyte_register],5
  2382.         lods    byte [esi]
  2383.         call    get_size_operator
  2384.         cmp     al,10h
  2385.         je      imul_reg
  2386.         cmp     al,'['
  2387.         jne     invalid_operand
  2388.       imul_mem:
  2389.         call    get_address
  2390.         mov     al,[operand_size]
  2391.         cmp     al,1
  2392.         je      imul_mem_8bit
  2393.         jb      imul_mem_nosize
  2394.         call    operand_autodetect
  2395.         inc     [base_code]
  2396.         jmp     instruction_ready
  2397.       imul_mem_nosize:
  2398.         call    recoverable_unknown_size
  2399.       imul_mem_8bit:
  2400.         jmp     instruction_ready
  2401.       imul_reg:
  2402.         lods    byte [esi]
  2403.         call    convert_register
  2404.         cmp     byte [esi],','
  2405.         je      imul_reg_
  2406.         mov     bl,al
  2407.         mov     al,ah
  2408.         cmp     al,1
  2409.         je      imul_reg_8bit
  2410.         call    operand_autodetect
  2411.         inc     [base_code]
  2412.       imul_reg_8bit:
  2413.         jmp     nomem_instruction_ready
  2414.       imul_reg_:
  2415.         mov     [postbyte_register],al
  2416.         inc     esi
  2417.         cmp     byte [esi],'('
  2418.         je      imul_reg_imm
  2419.         cmp     byte [esi],11h
  2420.         jne     imul_reg_noimm
  2421.         cmp     byte [esi+2],'('
  2422.         je      imul_reg_imm
  2423.       imul_reg_noimm:
  2424.         lods    byte [esi]
  2425.         call    get_size_operator
  2426.         cmp     al,10h
  2427.         je      imul_reg_reg
  2428.         cmp     al,'['
  2429.         jne     invalid_operand
  2430.       imul_reg_mem:
  2431.         call    get_address
  2432.         push    edx ebx ecx
  2433.         cmp     byte [esi],','
  2434.         je      imul_reg_mem_imm
  2435.         mov     al,[operand_size]
  2436.         call    operand_autodetect
  2437.         pop     ecx ebx edx
  2438.         mov     [base_code],0Fh
  2439.         mov     [extended_code],0AFh
  2440.         jmp     instruction_ready
  2441.       imul_reg_mem_imm:
  2442.         inc     esi
  2443.         lods    byte [esi]
  2444.         call    get_size_operator
  2445.         cmp     al,'('
  2446.         jne     invalid_operand
  2447.         mov     al,[operand_size]
  2448.         cmp     al,2
  2449.         je      imul_reg_mem_imm_16bit
  2450.         cmp     al,4
  2451.         je      imul_reg_mem_imm_32bit
  2452.         cmp     al,8
  2453.         jne     invalid_operand_size
  2454.       imul_reg_mem_imm_64bit:
  2455.         cmp     [size_declared],0
  2456.         jne     long_immediate_not_encodable
  2457.         call    operand_64bit
  2458.         call    get_simm32
  2459.         cmp     [value_type],4
  2460.         jae     long_immediate_not_encodable
  2461.         jmp     imul_reg_mem_imm_32bit_ok
  2462.       imul_reg_mem_imm_16bit:
  2463.         call    operand_16bit
  2464.         call    get_word_value
  2465.         mov     word [value],ax
  2466.         cmp     [value_type],0
  2467.         jne     imul_reg_mem_imm_16bit_store
  2468.         cmp     [size_declared],0
  2469.         jne     imul_reg_mem_imm_16bit_store
  2470.         cmp     ax,-80h
  2471.         jl      imul_reg_mem_imm_16bit_store
  2472.         cmp     ax,80h
  2473.         jl      imul_reg_mem_imm_8bit_store
  2474.       imul_reg_mem_imm_16bit_store:
  2475.         pop     ecx ebx edx
  2476.         mov     [base_code],69h
  2477.         call    store_instruction_with_imm16
  2478.         jmp     instruction_assembled
  2479.       imul_reg_mem_imm_32bit:
  2480.         call    operand_32bit
  2481.         call    get_dword_value
  2482.       imul_reg_mem_imm_32bit_ok:
  2483.         mov     dword [value],eax
  2484.         cmp     [value_type],0
  2485.         jne     imul_reg_mem_imm_32bit_store
  2486.         cmp     [size_declared],0
  2487.         jne     imul_reg_mem_imm_32bit_store
  2488.         cmp     eax,-80h
  2489.         jl      imul_reg_mem_imm_32bit_store
  2490.         cmp     eax,80h
  2491.         jl      imul_reg_mem_imm_8bit_store
  2492.       imul_reg_mem_imm_32bit_store:
  2493.         pop     ecx ebx edx
  2494.         mov     [base_code],69h
  2495.         call    store_instruction_with_imm32
  2496.         jmp     instruction_assembled
  2497.       imul_reg_mem_imm_8bit_store:
  2498.         pop     ecx ebx edx
  2499.         mov     [base_code],6Bh
  2500.         call    store_instruction_with_imm8
  2501.         jmp     instruction_assembled
  2502.       imul_reg_imm:
  2503.         mov     bl,[postbyte_register]
  2504.         dec     esi
  2505.         jmp     imul_reg_reg_imm
  2506.       imul_reg_reg:
  2507.         lods    byte [esi]
  2508.         call    convert_register
  2509.         mov     bl,al
  2510.         cmp     byte [esi],','
  2511.         je      imul_reg_reg_imm
  2512.         mov     al,ah
  2513.         call    operand_autodetect
  2514.         mov     [base_code],0Fh
  2515.         mov     [extended_code],0AFh
  2516.         jmp     nomem_instruction_ready
  2517.       imul_reg_reg_imm:
  2518.         inc     esi
  2519.         lods    byte [esi]
  2520.         call    get_size_operator
  2521.         cmp     al,'('
  2522.         jne     invalid_operand
  2523.         mov     al,[operand_size]
  2524.         cmp     al,2
  2525.         je      imul_reg_reg_imm_16bit
  2526.         cmp     al,4
  2527.         je      imul_reg_reg_imm_32bit
  2528.         cmp     al,8
  2529.         jne     invalid_operand_size
  2530.       imul_reg_reg_imm_64bit:
  2531.         cmp     [size_declared],0
  2532.         jne     long_immediate_not_encodable
  2533.         call    operand_64bit
  2534.         push    ebx
  2535.         call    get_simm32
  2536.         cmp     [value_type],4
  2537.         jae     long_immediate_not_encodable
  2538.         jmp     imul_reg_reg_imm_32bit_ok
  2539.       imul_reg_reg_imm_16bit:
  2540.         call    operand_16bit
  2541.         push    ebx
  2542.         call    get_word_value
  2543.         pop     ebx
  2544.         mov     dx,ax
  2545.         cmp     [value_type],0
  2546.         jne     imul_reg_reg_imm_16bit_store
  2547.         cmp     [size_declared],0
  2548.         jne     imul_reg_reg_imm_16bit_store
  2549.         cmp     ax,-80h
  2550.         jl      imul_reg_reg_imm_16bit_store
  2551.         cmp     ax,80h
  2552.         jl      imul_reg_reg_imm_8bit_store
  2553.       imul_reg_reg_imm_16bit_store:
  2554.         mov     [base_code],69h
  2555.         call    store_nomem_instruction
  2556.         mov     ax,dx
  2557.         call    mark_relocation
  2558.         stos    word [edi]
  2559.         jmp     instruction_assembled
  2560.       imul_reg_reg_imm_32bit:
  2561.         call    operand_32bit
  2562.         push    ebx
  2563.         call    get_dword_value
  2564.       imul_reg_reg_imm_32bit_ok:
  2565.         pop     ebx
  2566.         mov     edx,eax
  2567.         cmp     [value_type],0
  2568.         jne     imul_reg_reg_imm_32bit_store
  2569.         cmp     [size_declared],0
  2570.         jne     imul_reg_reg_imm_32bit_store
  2571.         cmp     eax,-80h
  2572.         jl      imul_reg_reg_imm_32bit_store
  2573.         cmp     eax,80h
  2574.         jl      imul_reg_reg_imm_8bit_store
  2575.       imul_reg_reg_imm_32bit_store:
  2576.         mov     [base_code],69h
  2577.         call    store_nomem_instruction
  2578.         mov     eax,edx
  2579.         call    mark_relocation
  2580.         stos    dword [edi]
  2581.         jmp     instruction_assembled
  2582.       imul_reg_reg_imm_8bit_store:
  2583.         mov     [base_code],6Bh
  2584.         call    store_nomem_instruction
  2585.         mov     al,dl
  2586.         stos    byte [edi]
  2587.         jmp     instruction_assembled
  2588. in_instruction:
  2589.         call    take_register
  2590.         or      al,al
  2591.         jnz     invalid_operand
  2592.         lods    byte [esi]
  2593.         cmp     al,','
  2594.         jne     invalid_operand
  2595.         mov     al,ah
  2596.         push    eax
  2597.         mov     [operand_size],0
  2598.         lods    byte [esi]
  2599.         call    get_size_operator
  2600.         cmp     al,'('
  2601.         je      in_imm
  2602.         cmp     al,10h
  2603.         je      in_reg
  2604.         jmp     invalid_operand
  2605.       in_reg:
  2606.         lods    byte [esi]
  2607.         cmp     al,22h
  2608.         jne     invalid_operand
  2609.         pop     eax
  2610.         cmp     al,1
  2611.         je      in_al_dx
  2612.         cmp     al,2
  2613.         je      in_ax_dx
  2614.         cmp     al,4
  2615.         jne     invalid_operand_size
  2616.       in_ax_dx:
  2617.         call    operand_autodetect
  2618.         mov     [base_code],0EDh
  2619.         call    store_classic_instruction_code
  2620.         jmp     instruction_assembled
  2621.       in_al_dx:
  2622.         mov     al,0ECh
  2623.         stos    byte [edi]
  2624.         jmp     instruction_assembled
  2625.       in_imm:
  2626.         mov     al,[operand_size]
  2627.         or      al,al
  2628.         jz      in_imm_size_ok
  2629.         cmp     al,1
  2630.         jne     invalid_operand_size
  2631.       in_imm_size_ok:
  2632.         call    get_byte_value
  2633.         mov     dl,al
  2634.         pop     eax
  2635.         cmp     al,1
  2636.         je      in_al_imm
  2637.         cmp     al,2
  2638.         je      in_ax_imm
  2639.         cmp     al,4
  2640.         jne     invalid_operand_size
  2641.       in_ax_imm:
  2642.         call    operand_autodetect
  2643.         mov     [base_code],0E5h
  2644.         call    store_classic_instruction_code
  2645.         mov     al,dl
  2646.         stos    byte [edi]
  2647.         jmp     instruction_assembled
  2648.       in_al_imm:
  2649.         mov     al,0E4h
  2650.         stos    byte [edi]
  2651.         mov     al,dl
  2652.         stos    byte [edi]
  2653.         jmp     instruction_assembled
  2654. out_instruction:
  2655.         lods    byte [esi]
  2656.         call    get_size_operator
  2657.         cmp     al,'('
  2658.         je      out_imm
  2659.         cmp     al,10h
  2660.         jne     invalid_operand
  2661.         lods    byte [esi]
  2662.         cmp     al,22h
  2663.         jne     invalid_operand
  2664.         lods    byte [esi]
  2665.         cmp     al,','
  2666.         jne     invalid_operand
  2667.         mov     [operand_size],0
  2668.         call    take_register
  2669.         or      al,al
  2670.         jnz     invalid_operand
  2671.         mov     al,ah
  2672.         cmp     al,1
  2673.         je      out_dx_al
  2674.         cmp     al,2
  2675.         je      out_dx_ax
  2676.         cmp     al,4
  2677.         jne     invalid_operand_size
  2678.       out_dx_ax:
  2679.         call    operand_autodetect
  2680.         mov     [base_code],0EFh
  2681.         call    store_classic_instruction_code
  2682.         jmp     instruction_assembled
  2683.       out_dx_al:
  2684.         mov     al,0EEh
  2685.         stos    byte [edi]
  2686.         jmp     instruction_assembled
  2687.       out_imm:
  2688.         mov     al,[operand_size]
  2689.         or      al,al
  2690.         jz      out_imm_size_ok
  2691.         cmp     al,1
  2692.         jne     invalid_operand_size
  2693.       out_imm_size_ok:
  2694.         call    get_byte_value
  2695.         mov     dl,al
  2696.         lods    byte [esi]
  2697.         cmp     al,','
  2698.         jne     invalid_operand
  2699.         mov     [operand_size],0
  2700.         call    take_register
  2701.         or      al,al
  2702.         jnz     invalid_operand
  2703.         mov     al,ah
  2704.         cmp     al,1
  2705.         je      out_imm_al
  2706.         cmp     al,2
  2707.         je      out_imm_ax
  2708.         cmp     al,4
  2709.         jne     invalid_operand_size
  2710.       out_imm_ax:
  2711.         call    operand_autodetect
  2712.         mov     [base_code],0E7h
  2713.         call    store_classic_instruction_code
  2714.         mov     al,dl
  2715.         stos    byte [edi]
  2716.         jmp     instruction_assembled
  2717.       out_imm_al:
  2718.         mov     al,0E6h
  2719.         stos    byte [edi]
  2720.         mov     al,dl
  2721.         stos    byte [edi]
  2722.         jmp     instruction_assembled
  2723.  
  2724. call_instruction:
  2725.         mov     [postbyte_register],10b
  2726.         mov     [base_code],0E8h
  2727.         mov     [extended_code],9Ah
  2728.         jmp     process_jmp
  2729. jmp_instruction:
  2730.         mov     [postbyte_register],100b
  2731.         mov     [base_code],0E9h
  2732.         mov     [extended_code],0EAh
  2733.       process_jmp:
  2734.         lods    byte [esi]
  2735.         call    get_jump_operator
  2736.         test    [prefix_flags],10h
  2737.         jz      jmp_type_ok
  2738.         test    [jump_type],not 2
  2739.         jnz     illegal_instruction
  2740.         mov     [jump_type],2
  2741.         and     [prefix_flags],not 10h
  2742.       jmp_type_ok:
  2743.         call    get_size_operator
  2744.         cmp     al,'('
  2745.         je      jmp_imm
  2746.         mov     [base_code],0FFh
  2747.         cmp     al,10h
  2748.         je      jmp_reg
  2749.         cmp     al,'['
  2750.         jne     invalid_operand
  2751.       jmp_mem:
  2752.         cmp     [jump_type],1
  2753.         je      illegal_instruction
  2754.         call    get_address
  2755.         mov     edx,eax
  2756.         mov     al,[operand_size]
  2757.         or      al,al
  2758.         jz      jmp_mem_size_not_specified
  2759.         cmp     al,2
  2760.         je      jmp_mem_16bit
  2761.         cmp     al,4
  2762.         je      jmp_mem_32bit
  2763.         cmp     al,6
  2764.         je      jmp_mem_48bit
  2765.         cmp     al,8
  2766.         je      jmp_mem_64bit
  2767.         cmp     al,10
  2768.         je      jmp_mem_80bit
  2769.         jmp     invalid_operand_size
  2770.       jmp_mem_size_not_specified:
  2771.         cmp     [jump_type],3
  2772.         je      jmp_mem_far
  2773.         cmp     [jump_type],2
  2774.         je      jmp_mem_near
  2775.         call    recoverable_unknown_size
  2776.       jmp_mem_near:
  2777.         cmp     [code_type],16
  2778.         je      jmp_mem_16bit
  2779.         cmp     [code_type],32
  2780.         je      jmp_mem_near_32bit
  2781.       jmp_mem_64bit:
  2782.         cmp     [jump_type],3
  2783.         je      invalid_operand_size
  2784.         cmp     [code_type],64
  2785.         jne     illegal_instruction
  2786.         jmp     instruction_ready
  2787.       jmp_mem_far:
  2788.         cmp     [code_type],16
  2789.         je      jmp_mem_far_32bit
  2790.       jmp_mem_48bit:
  2791.         call    operand_32bit
  2792.       jmp_mem_far_store:
  2793.         cmp     [jump_type],2
  2794.         je      invalid_operand_size
  2795.         inc     [postbyte_register]
  2796.         jmp     instruction_ready
  2797.       jmp_mem_80bit:
  2798.         call    operand_64bit
  2799.         jmp     jmp_mem_far_store
  2800.       jmp_mem_far_32bit:
  2801.         call    operand_16bit
  2802.         jmp     jmp_mem_far_store
  2803.       jmp_mem_32bit:
  2804.         cmp     [jump_type],3
  2805.         je      jmp_mem_far_32bit
  2806.         cmp     [jump_type],2
  2807.         je      jmp_mem_near_32bit
  2808.         cmp     [code_type],16
  2809.         je      jmp_mem_far_32bit
  2810.       jmp_mem_near_32bit:
  2811.         cmp     [code_type],64
  2812.         je      illegal_instruction
  2813.         call    operand_32bit
  2814.         jmp     instruction_ready
  2815.       jmp_mem_16bit:
  2816.         cmp     [jump_type],3
  2817.         je      invalid_operand_size
  2818.         call    operand_16bit
  2819.         jmp     instruction_ready
  2820.       jmp_reg:
  2821.         test    [jump_type],1
  2822.         jnz     invalid_operand
  2823.         lods    byte [esi]
  2824.         call    convert_register
  2825.         mov     bl,al
  2826.         mov     al,ah
  2827.         cmp     al,2
  2828.         je      jmp_reg_16bit
  2829.         cmp     al,4
  2830.         je      jmp_reg_32bit
  2831.         cmp     al,8
  2832.         jne     invalid_operand_size
  2833.       jmp_reg_64bit:
  2834.         cmp     [code_type],64
  2835.         jne     illegal_instruction
  2836.         jmp     nomem_instruction_ready
  2837.       jmp_reg_32bit:
  2838.         cmp     [code_type],64
  2839.         je      illegal_instruction
  2840.         call    operand_32bit
  2841.         jmp     nomem_instruction_ready
  2842.       jmp_reg_16bit:
  2843.         call    operand_16bit
  2844.         jmp     nomem_instruction_ready
  2845.       jmp_imm:
  2846.         cmp     byte [esi],'.'
  2847.         je      invalid_value
  2848.         mov     ebx,esi
  2849.         dec     esi
  2850.         call    skip_symbol
  2851.         xchg    esi,ebx
  2852.         cmp     byte [ebx],':'
  2853.         je      jmp_far
  2854.         cmp     [jump_type],3
  2855.         je      invalid_operand
  2856.       jmp_near:
  2857.         mov     al,[operand_size]
  2858.         cmp     al,2
  2859.         je      jmp_imm_16bit
  2860.         cmp     al,4
  2861.         je      jmp_imm_32bit
  2862.         cmp     al,8
  2863.         je      jmp_imm_64bit
  2864.         or      al,al
  2865.         jnz     invalid_operand_size
  2866.         cmp     [code_type],16
  2867.         je      jmp_imm_16bit
  2868.         cmp     [code_type],64
  2869.         je      jmp_imm_64bit
  2870.       jmp_imm_32bit:
  2871.         cmp     [code_type],64
  2872.         je      invalid_operand_size
  2873.         call    get_address_dword_value
  2874.         cmp     [code_type],16
  2875.         jne     jmp_imm_32bit_prefix_ok
  2876.         mov     byte [edi],66h
  2877.         inc     edi
  2878.       jmp_imm_32bit_prefix_ok:
  2879.         call    calculate_jump_offset
  2880.         cdq
  2881.         call    check_for_short_jump
  2882.         jc      jmp_short
  2883.       jmp_imm_32bit_store:
  2884.         mov     edx,eax
  2885.         sub     edx,3
  2886.         jno     jmp_imm_32bit_ok
  2887.         cmp     [code_type],64
  2888.         je      jump_out_of_range
  2889.       jmp_imm_32bit_ok:
  2890.         mov     al,[base_code]
  2891.         stos    byte [edi]
  2892.         mov     eax,edx
  2893.         call    mark_relocation
  2894.         stos    dword [edi]
  2895.         jmp     instruction_assembled
  2896.       jmp_imm_64bit:
  2897.         cmp     [code_type],64
  2898.         jne     invalid_operand_size
  2899.         call    get_address_qword_value
  2900.         call    calculate_jump_offset
  2901.         mov     ecx,edx
  2902.         cdq
  2903.         cmp     edx,ecx
  2904.         jne     jump_out_of_range
  2905.         call    check_for_short_jump
  2906.         jnc     jmp_imm_32bit_store
  2907.       jmp_short:
  2908.         mov     ah,al
  2909.         mov     al,0EBh
  2910.         stos    word [edi]
  2911.         jmp     instruction_assembled
  2912.       jmp_imm_16bit:
  2913.         call    get_address_word_value
  2914.         cmp     [code_type],16
  2915.         je      jmp_imm_16bit_prefix_ok
  2916.         mov     byte [edi],66h
  2917.         inc     edi
  2918.       jmp_imm_16bit_prefix_ok:
  2919.         call    calculate_jump_offset
  2920.         cwde
  2921.         cdq
  2922.         call    check_for_short_jump
  2923.         jc      jmp_short
  2924.         cmp     [value_type],0
  2925.         jne     invalid_use_of_symbol
  2926.         mov     edx,eax
  2927.         dec     edx
  2928.         mov     al,[base_code]
  2929.         stos    byte [edi]
  2930.         mov     eax,edx
  2931.         stos    word [edi]
  2932.         jmp     instruction_assembled
  2933.       calculate_jump_offset:
  2934.         add     edi,2
  2935.         mov     ebp,[addressing_space]
  2936.         call    calculate_relative_offset
  2937.         sub     edi,2
  2938.         ret
  2939.       check_for_short_jump:
  2940.         cmp     [jump_type],1
  2941.         je      forced_short
  2942.         ja      no_short_jump
  2943.         cmp     [base_code],0E8h
  2944.         je      no_short_jump
  2945.         cmp     [value_type],0
  2946.         jne     no_short_jump
  2947.         cmp     eax,80h
  2948.         jb      short_jump
  2949.         cmp     eax,-80h
  2950.         jae     short_jump
  2951.       no_short_jump:
  2952.         clc
  2953.         ret
  2954.       forced_short:
  2955.         cmp     [base_code],0E8h
  2956.         je      illegal_instruction
  2957.         cmp     [next_pass_needed],0
  2958.         jne     jmp_short_value_type_ok
  2959.         cmp     [value_type],0
  2960.         jne     invalid_use_of_symbol
  2961.       jmp_short_value_type_ok:
  2962.         cmp     eax,-80h
  2963.         jae     short_jump
  2964.         cmp     eax,80h
  2965.         jae     jump_out_of_range
  2966.       short_jump:
  2967.         stc
  2968.         ret
  2969.       jump_out_of_range:
  2970.         cmp     [error_line],0
  2971.         jne     instruction_assembled
  2972.         mov     eax,[current_line]
  2973.         mov     [error_line],eax
  2974.         mov     [error],relative_jump_out_of_range
  2975.         jmp     instruction_assembled
  2976.       jmp_far:
  2977.         cmp     [jump_type],2
  2978.         je      invalid_operand
  2979.         cmp     [code_type],64
  2980.         je      illegal_instruction
  2981.         mov     al,[extended_code]
  2982.         mov     [base_code],al
  2983.         call    get_word_value
  2984.         push    eax
  2985.         inc     esi
  2986.         lods    byte [esi]
  2987.         cmp     al,'('
  2988.         jne     invalid_operand
  2989.         mov     al,[value_type]
  2990.         push    eax [symbol_identifier]
  2991.         cmp     byte [esi],'.'
  2992.         je      invalid_value
  2993.         mov     al,[operand_size]
  2994.         cmp     al,4
  2995.         je      jmp_far_16bit
  2996.         cmp     al,6
  2997.         je      jmp_far_32bit
  2998.         or      al,al
  2999.         jnz     invalid_operand_size
  3000.         cmp     [code_type],16
  3001.         jne     jmp_far_32bit
  3002.       jmp_far_16bit:
  3003.         call    get_word_value
  3004.         mov     ebx,eax
  3005.         call    operand_16bit
  3006.         call    store_classic_instruction_code
  3007.         mov     ax,bx
  3008.         call    mark_relocation
  3009.         stos    word [edi]
  3010.       jmp_far_segment:
  3011.         pop     [symbol_identifier] eax
  3012.         mov     [value_type],al
  3013.         pop     eax
  3014.         call    mark_relocation
  3015.         stos    word [edi]
  3016.         jmp     instruction_assembled
  3017.       jmp_far_32bit:
  3018.         call    get_dword_value
  3019.         mov     ebx,eax
  3020.         call    operand_32bit
  3021.         call    store_classic_instruction_code
  3022.         mov     eax,ebx
  3023.         call    mark_relocation
  3024.         stos    dword [edi]
  3025.         jmp     jmp_far_segment
  3026. conditional_jump:
  3027.         mov     [base_code],al
  3028.         and     [prefix_flags],not 10h
  3029.         lods    byte [esi]
  3030.         call    get_jump_operator
  3031.         cmp     [jump_type],3
  3032.         je      invalid_operand
  3033.         call    get_size_operator
  3034.         cmp     al,'('
  3035.         jne     invalid_operand
  3036.         cmp     byte [esi],'.'
  3037.         je      invalid_value
  3038.         mov     al,[operand_size]
  3039.         cmp     al,2
  3040.         je      conditional_jump_16bit
  3041.         cmp     al,4
  3042.         je      conditional_jump_32bit
  3043.         cmp     al,8
  3044.         je      conditional_jump_64bit
  3045.         or      al,al
  3046.         jnz     invalid_operand_size
  3047.         cmp     [code_type],16
  3048.         je      conditional_jump_16bit
  3049.         cmp     [code_type],64
  3050.         je      conditional_jump_64bit
  3051.       conditional_jump_32bit:
  3052.         cmp     [code_type],64
  3053.         je      invalid_operand_size
  3054.         call    get_address_dword_value
  3055.         cmp     [code_type],16
  3056.         jne     conditional_jump_32bit_prefix_ok
  3057.         mov     byte [edi],66h
  3058.         inc     edi
  3059.       conditional_jump_32bit_prefix_ok:
  3060.         call    calculate_jump_offset
  3061.         cdq
  3062.         call    check_for_short_jump
  3063.         jc      conditional_jump_short
  3064.       conditional_jump_32bit_store:
  3065.         mov     edx,eax
  3066.         sub     edx,4
  3067.         jno     conditional_jump_32bit_range_ok
  3068.         cmp     [code_type],64
  3069.         je      jump_out_of_range
  3070.       conditional_jump_32bit_range_ok:
  3071.         mov     ah,[base_code]
  3072.         add     ah,10h
  3073.         mov     al,0Fh
  3074.         stos    word [edi]
  3075.         mov     eax,edx
  3076.         call    mark_relocation
  3077.         stos    dword [edi]
  3078.         jmp     instruction_assembled
  3079.       conditional_jump_64bit:
  3080.         cmp     [code_type],64
  3081.         jne     invalid_operand_size
  3082.         call    get_address_qword_value
  3083.         call    calculate_jump_offset
  3084.         mov     ecx,edx
  3085.         cdq
  3086.         cmp     edx,ecx
  3087.         jne     jump_out_of_range
  3088.         call    check_for_short_jump
  3089.         jnc     conditional_jump_32bit_store
  3090.       conditional_jump_short:
  3091.         mov     ah,al
  3092.         mov     al,[base_code]
  3093.         stos    word [edi]
  3094.         jmp     instruction_assembled
  3095.       conditional_jump_16bit:
  3096.         call    get_address_word_value
  3097.         cmp     [code_type],16
  3098.         je      conditional_jump_16bit_prefix_ok
  3099.         mov     byte [edi],66h
  3100.         inc     edi
  3101.       conditional_jump_16bit_prefix_ok:
  3102.         call    calculate_jump_offset
  3103.         cwde
  3104.         cdq
  3105.         call    check_for_short_jump
  3106.         jc      conditional_jump_short
  3107.         cmp     [value_type],0
  3108.         jne     invalid_use_of_symbol
  3109.         mov     edx,eax
  3110.         sub     dx,2
  3111.         mov     ah,[base_code]
  3112.         add     ah,10h
  3113.         mov     al,0Fh
  3114.         stos    word [edi]
  3115.         mov     eax,edx
  3116.         stos    word [edi]
  3117.         jmp     instruction_assembled
  3118. loop_instruction_16bit:
  3119.         cmp     [code_type],64
  3120.         je      illegal_instruction
  3121.         cmp     [code_type],16
  3122.         je      loop_instruction
  3123.         mov     [operand_prefix],67h
  3124.         jmp     loop_instruction
  3125. loop_instruction_32bit:
  3126.         cmp     [code_type],32
  3127.         je      loop_instruction
  3128.         mov     [operand_prefix],67h
  3129.       jmp     loop_instruction
  3130. loop_instruction_64bit:
  3131.         cmp     [code_type],64
  3132.         jne     illegal_instruction
  3133. loop_instruction:
  3134.         mov     [base_code],al
  3135.         lods    byte [esi]
  3136.         call    get_jump_operator
  3137.         cmp     [jump_type],1
  3138.         ja      invalid_operand
  3139.         call    get_size_operator
  3140.         cmp     al,'('
  3141.         jne     invalid_operand
  3142.         cmp     byte [esi],'.'
  3143.         je      invalid_value
  3144.         mov     al,[operand_size]
  3145.         cmp     al,2
  3146.         je      loop_jump_16bit
  3147.         cmp     al,4
  3148.         je      loop_jump_32bit
  3149.         cmp     al,8
  3150.         je      loop_jump_64bit
  3151.         or      al,al
  3152.         jnz     invalid_operand_size
  3153.         cmp     [code_type],16
  3154.         je      loop_jump_16bit
  3155.         cmp     [code_type],64
  3156.         je      loop_jump_64bit
  3157.       loop_jump_32bit:
  3158.         cmp     [code_type],64
  3159.         je      invalid_operand_size
  3160.         call    get_address_dword_value
  3161.         cmp     [code_type],16
  3162.         jne     loop_jump_32bit_prefix_ok
  3163.         mov     byte [edi],66h
  3164.         inc     edi
  3165.       loop_jump_32bit_prefix_ok:
  3166.         call    loop_counter_size
  3167.         call    calculate_jump_offset
  3168.         cdq
  3169.       make_loop_jump:
  3170.         call    check_for_short_jump
  3171.         jc      conditional_jump_short
  3172.         scas    word [edi]
  3173.         jmp     jump_out_of_range
  3174.       loop_counter_size:
  3175.         cmp     [operand_prefix],0
  3176.         je      loop_counter_size_ok
  3177.         push    eax
  3178.         mov     al,[operand_prefix]
  3179.         stos    byte [edi]
  3180.         pop     eax
  3181.       loop_counter_size_ok:
  3182.         ret
  3183.       loop_jump_64bit:
  3184.         cmp     [code_type],64
  3185.         jne     invalid_operand_size
  3186.         call    get_address_qword_value
  3187.         call    loop_counter_size
  3188.         call    calculate_jump_offset
  3189.         mov     ecx,edx
  3190.         cdq
  3191.         cmp     edx,ecx
  3192.         jne     jump_out_of_range
  3193.         jmp     make_loop_jump
  3194.       loop_jump_16bit:
  3195.         call    get_address_word_value
  3196.         cmp     [code_type],16
  3197.         je      loop_jump_16bit_prefix_ok
  3198.         mov     byte [edi],66h
  3199.         inc     edi
  3200.       loop_jump_16bit_prefix_ok:
  3201.         call    loop_counter_size
  3202.         call    calculate_jump_offset
  3203.         cwde
  3204.         cdq
  3205.         jmp     make_loop_jump
  3206.  
  3207. movs_instruction:
  3208.         lods    byte [esi]
  3209.         call    get_size_operator
  3210.         cmp     al,'['
  3211.         jne     invalid_operand
  3212.         call    get_address
  3213.         or      eax,eax
  3214.         jnz     invalid_address
  3215.         or      bl,ch
  3216.         jnz     invalid_address
  3217.         cmp     [segment_register],1
  3218.         ja      invalid_address
  3219.         push    ebx
  3220.         lods    byte [esi]
  3221.         cmp     al,','
  3222.         jne     invalid_operand
  3223.         lods    byte [esi]
  3224.         call    get_size_operator
  3225.         cmp     al,'['
  3226.         jne     invalid_operand
  3227.         call    get_address
  3228.         pop     edx
  3229.         or      eax,eax
  3230.         jnz     invalid_address
  3231.         or      bl,ch
  3232.         jnz     invalid_address
  3233.         mov     al,dh
  3234.         mov     ah,bh
  3235.         shr     al,4
  3236.         shr     ah,4
  3237.         cmp     al,ah
  3238.         jne     address_sizes_do_not_agree
  3239.         and     bh,111b
  3240.         and     dh,111b
  3241.         cmp     bh,6
  3242.         jne     invalid_address
  3243.         cmp     dh,7
  3244.         jne     invalid_address
  3245.         cmp     al,2
  3246.         je      movs_address_16bit
  3247.         cmp     al,4
  3248.         je      movs_address_32bit
  3249.         cmp     [code_type],64
  3250.         jne     invalid_address_size
  3251.         jmp     movs_store
  3252.       movs_address_32bit:
  3253.         call    address_32bit_prefix
  3254.         jmp     movs_store
  3255.       movs_address_16bit:
  3256.         cmp     [code_type],64
  3257.         je      invalid_address_size
  3258.         call    address_16bit_prefix
  3259.       movs_store:
  3260.         xor     ebx,ebx
  3261.         call    store_segment_prefix_if_necessary
  3262.         mov     al,0A4h
  3263.       movs_check_size:
  3264.         mov     bl,[operand_size]
  3265.         cmp     bl,1
  3266.         je      simple_instruction
  3267.         inc     al
  3268.         cmp     bl,2
  3269.         je      simple_instruction_16bit
  3270.         cmp     bl,4
  3271.         je      simple_instruction_32bit
  3272.         cmp     bl,8
  3273.         je      simple_instruction_64bit
  3274.         or      bl,bl
  3275.         jnz     invalid_operand_size
  3276.         call    recoverable_unknown_size
  3277.         jmp     simple_instruction
  3278. lods_instruction:
  3279.         lods    byte [esi]
  3280.         call    get_size_operator
  3281.         cmp     al,'['
  3282.         jne     invalid_operand
  3283.         call    get_address
  3284.         or      eax,eax
  3285.         jnz     invalid_address
  3286.         or      bl,ch
  3287.         jnz     invalid_address
  3288.         cmp     bh,26h
  3289.         je      lods_address_16bit
  3290.         cmp     bh,46h
  3291.         je      lods_address_32bit
  3292.         cmp     bh,86h
  3293.         jne     invalid_address
  3294.         cmp     [code_type],64
  3295.         jne     invalid_address_size
  3296.         jmp     lods_store
  3297.       lods_address_32bit:
  3298.         call    address_32bit_prefix
  3299.         jmp     lods_store
  3300.       lods_address_16bit:
  3301.         cmp     [code_type],64
  3302.         je      invalid_address_size
  3303.         call    address_16bit_prefix
  3304.       lods_store:
  3305.         xor     ebx,ebx
  3306.         call    store_segment_prefix_if_necessary
  3307.         mov     al,0ACh
  3308.         jmp     movs_check_size
  3309. stos_instruction:
  3310.         mov     [base_code],al
  3311.         lods    byte [esi]
  3312.         call    get_size_operator
  3313.         cmp     al,'['
  3314.         jne     invalid_operand
  3315.         call    get_address
  3316.         or      eax,eax
  3317.         jnz     invalid_address
  3318.         or      bl,ch
  3319.         jnz     invalid_address
  3320.         cmp     bh,27h
  3321.         je      stos_address_16bit
  3322.         cmp     bh,47h
  3323.         je      stos_address_32bit
  3324.         cmp     bh,87h
  3325.         jne     invalid_address
  3326.         cmp     [code_type],64
  3327.         jne     invalid_address_size
  3328.         jmp     stos_store
  3329.       stos_address_32bit:
  3330.         call    address_32bit_prefix
  3331.         jmp     stos_store
  3332.       stos_address_16bit:
  3333.         cmp     [code_type],64
  3334.         je      invalid_address_size
  3335.         call    address_16bit_prefix
  3336.       stos_store:
  3337.         cmp     [segment_register],1
  3338.         ja      invalid_address
  3339.         mov     al,[base_code]
  3340.         jmp     movs_check_size
  3341. cmps_instruction:
  3342.         lods    byte [esi]
  3343.         call    get_size_operator
  3344.         cmp     al,'['
  3345.         jne     invalid_operand
  3346.         call    get_address
  3347.         or      eax,eax
  3348.         jnz     invalid_address
  3349.         or      bl,ch
  3350.         jnz     invalid_address
  3351.         mov     al,[segment_register]
  3352.         push    eax ebx
  3353.         lods    byte [esi]
  3354.         cmp     al,','
  3355.         jne     invalid_operand
  3356.         lods    byte [esi]
  3357.         call    get_size_operator
  3358.         cmp     al,'['
  3359.         jne     invalid_operand
  3360.         call    get_address
  3361.         or      eax,eax
  3362.         jnz     invalid_address
  3363.         or      bl,ch
  3364.         jnz     invalid_address
  3365.         pop     edx eax
  3366.         cmp     [segment_register],1
  3367.         ja      invalid_address
  3368.         mov     [segment_register],al
  3369.         mov     al,dh
  3370.         mov     ah,bh
  3371.         shr     al,4
  3372.         shr     ah,4
  3373.         cmp     al,ah
  3374.         jne     address_sizes_do_not_agree
  3375.         and     bh,111b
  3376.         and     dh,111b
  3377.         cmp     bh,7
  3378.         jne     invalid_address
  3379.         cmp     dh,6
  3380.         jne     invalid_address
  3381.         cmp     al,2
  3382.         je      cmps_address_16bit
  3383.         cmp     al,4
  3384.         je      cmps_address_32bit
  3385.         cmp     [code_type],64
  3386.         jne     invalid_address_size
  3387.         jmp     cmps_store
  3388.       cmps_address_32bit:
  3389.         call    address_32bit_prefix
  3390.         jmp     cmps_store
  3391.       cmps_address_16bit:
  3392.         cmp     [code_type],64
  3393.         je      invalid_address_size
  3394.         call    address_16bit_prefix
  3395.       cmps_store:
  3396.         xor     ebx,ebx
  3397.         call    store_segment_prefix_if_necessary
  3398.         mov     al,0A6h
  3399.         jmp     movs_check_size
  3400. ins_instruction:
  3401.         lods    byte [esi]
  3402.         call    get_size_operator
  3403.         cmp     al,'['
  3404.         jne     invalid_operand
  3405.         call    get_address
  3406.         or      eax,eax
  3407.         jnz     invalid_address
  3408.         or      bl,ch
  3409.         jnz     invalid_address
  3410.         cmp     bh,27h
  3411.         je      ins_address_16bit
  3412.         cmp     bh,47h
  3413.         je      ins_address_32bit
  3414.         cmp     bh,87h
  3415.         jne     invalid_address
  3416.         cmp     [code_type],64
  3417.         jne     invalid_address_size
  3418.         jmp     ins_store
  3419.       ins_address_32bit:
  3420.         call    address_32bit_prefix
  3421.         jmp     ins_store
  3422.       ins_address_16bit:
  3423.         cmp     [code_type],64
  3424.         je      invalid_address_size
  3425.         call    address_16bit_prefix
  3426.       ins_store:
  3427.         cmp     [segment_register],1
  3428.         ja      invalid_address
  3429.         lods    byte [esi]
  3430.         cmp     al,','
  3431.         jne     invalid_operand
  3432.         lods    byte [esi]
  3433.         cmp     al,10h
  3434.         jne     invalid_operand
  3435.         lods    byte [esi]
  3436.         cmp     al,22h
  3437.         jne     invalid_operand
  3438.         mov     al,6Ch
  3439.       ins_check_size:
  3440.         cmp     [operand_size],8
  3441.         jne     movs_check_size
  3442.         jmp     invalid_operand_size
  3443. outs_instruction:
  3444.         lods    byte [esi]
  3445.         cmp     al,10h
  3446.         jne     invalid_operand
  3447.         lods    byte [esi]
  3448.         cmp     al,22h
  3449.         jne     invalid_operand
  3450.         lods    byte [esi]
  3451.         cmp     al,','
  3452.         jne     invalid_operand
  3453.         lods    byte [esi]
  3454.         call    get_size_operator
  3455.         cmp     al,'['
  3456.         jne     invalid_operand
  3457.         call    get_address
  3458.         or      eax,eax
  3459.         jnz     invalid_address
  3460.         or      bl,ch
  3461.         jnz     invalid_address
  3462.         cmp     bh,26h
  3463.         je      outs_address_16bit
  3464.         cmp     bh,46h
  3465.         je      outs_address_32bit
  3466.         cmp     bh,86h
  3467.         jne     invalid_address
  3468.         cmp     [code_type],64
  3469.         jne     invalid_address_size
  3470.         jmp     outs_store
  3471.       outs_address_32bit:
  3472.         call    address_32bit_prefix
  3473.         jmp     outs_store
  3474.       outs_address_16bit:
  3475.         cmp     [code_type],64
  3476.         je      invalid_address_size
  3477.         call    address_16bit_prefix
  3478.       outs_store:
  3479.         xor     ebx,ebx
  3480.         call    store_segment_prefix_if_necessary
  3481.         mov     al,6Eh
  3482.         jmp     ins_check_size
  3483. xlat_instruction:
  3484.         lods    byte [esi]
  3485.         call    get_size_operator
  3486.         cmp     al,'['
  3487.         jne     invalid_operand
  3488.         call    get_address
  3489.         or      eax,eax
  3490.         jnz     invalid_address
  3491.         or      bl,ch
  3492.         jnz     invalid_address
  3493.         cmp     bh,23h
  3494.         je      xlat_address_16bit
  3495.         cmp     bh,43h
  3496.         je      xlat_address_32bit
  3497.         cmp     bh,83h
  3498.         jne     invalid_address
  3499.         cmp     [code_type],64
  3500.         jne     invalid_address_size
  3501.         jmp     xlat_store
  3502.       xlat_address_32bit:
  3503.         call    address_32bit_prefix
  3504.         jmp     xlat_store
  3505.       xlat_address_16bit:
  3506.         cmp     [code_type],64
  3507.         je      invalid_address_size
  3508.         call    address_16bit_prefix
  3509.       xlat_store:
  3510.         call    store_segment_prefix_if_necessary
  3511.         mov     al,0D7h
  3512.         cmp     [operand_size],1
  3513.         jbe     simple_instruction
  3514.         jmp     invalid_operand_size
  3515.  
  3516. pm_word_instruction:
  3517.         mov     ah,al
  3518.         shr     ah,4
  3519.         and     al,111b
  3520.         mov     [base_code],0Fh
  3521.         mov     [extended_code],ah
  3522.         mov     [postbyte_register],al
  3523.         lods    byte [esi]
  3524.         call    get_size_operator
  3525.         cmp     al,10h
  3526.         je      pm_reg
  3527.       pm_mem:
  3528.         cmp     al,'['
  3529.         jne     invalid_operand
  3530.         call    get_address
  3531.         mov     al,[operand_size]
  3532.         cmp     al,2
  3533.         je      pm_mem_store
  3534.         or      al,al
  3535.         jnz     invalid_operand_size
  3536.       pm_mem_store:
  3537.         jmp     instruction_ready
  3538.       pm_reg:
  3539.         lods    byte [esi]
  3540.         call    convert_register
  3541.         mov     bl,al
  3542.         cmp     ah,2
  3543.         jne     invalid_operand_size
  3544.         jmp     nomem_instruction_ready
  3545. pm_store_word_instruction:
  3546.         mov     ah,al
  3547.         shr     ah,4
  3548.         and     al,111b
  3549.         mov     [base_code],0Fh
  3550.         mov     [extended_code],ah
  3551.         mov     [postbyte_register],al
  3552.         lods    byte [esi]
  3553.         call    get_size_operator
  3554.         cmp     al,10h
  3555.         jne     pm_mem
  3556.         lods    byte [esi]
  3557.         call    convert_register
  3558.         mov     bl,al
  3559.         mov     al,ah
  3560.         call    operand_autodetect
  3561.         jmp     nomem_instruction_ready
  3562. lgdt_instruction:
  3563.         mov     [base_code],0Fh
  3564.         mov     [extended_code],1
  3565.         mov     [postbyte_register],al
  3566.         lods    byte [esi]
  3567.         call    get_size_operator
  3568.         cmp     al,'['
  3569.         jne     invalid_operand
  3570.         call    get_address
  3571.         mov     al,[operand_size]
  3572.         cmp     al,6
  3573.         je      lgdt_mem_48bit
  3574.         cmp     al,10
  3575.         je      lgdt_mem_80bit
  3576.         or      al,al
  3577.         jnz     invalid_operand_size
  3578.         jmp     lgdt_mem_store
  3579.       lgdt_mem_80bit:
  3580.         cmp     [code_type],64
  3581.         jne     illegal_instruction
  3582.         jmp     lgdt_mem_store
  3583.       lgdt_mem_48bit:
  3584.         cmp     [code_type],64
  3585.         je      illegal_instruction
  3586.         cmp     [postbyte_register],2
  3587.         jb      lgdt_mem_store
  3588.         call    operand_32bit
  3589.       lgdt_mem_store:
  3590.         jmp     instruction_ready
  3591. lar_instruction:
  3592.         mov     [extended_code],al
  3593.         mov     [base_code],0Fh
  3594.         call    take_register
  3595.         mov     [postbyte_register],al
  3596.         lods    byte [esi]
  3597.         cmp     al,','
  3598.         jne     invalid_operand
  3599.         xor     al,al
  3600.         xchg    al,[operand_size]
  3601.         call    operand_autodetect
  3602.         lods    byte [esi]
  3603.         call    get_size_operator
  3604.         cmp     al,10h
  3605.         je      lar_reg_reg
  3606.         cmp     al,'['
  3607.         jne     invalid_operand
  3608.         call    get_address
  3609.         mov     al,[operand_size]
  3610.         or      al,al
  3611.         jz      lar_reg_mem
  3612.         cmp     al,2
  3613.         jne     invalid_operand_size
  3614.       lar_reg_mem:
  3615.         jmp     instruction_ready
  3616.       lar_reg_reg:
  3617.         lods    byte [esi]
  3618.         call    convert_register
  3619.         cmp     ah,2
  3620.         jne     invalid_operand_size
  3621.         mov     bl,al
  3622.         jmp     nomem_instruction_ready
  3623. invlpg_instruction:
  3624.         mov     [base_code],0Fh
  3625.         mov     [extended_code],1
  3626.         mov     [postbyte_register],7
  3627.         lods    byte [esi]
  3628.         call    get_size_operator
  3629.         cmp     al,'['
  3630.         jne     invalid_operand
  3631.         call    get_address
  3632.         jmp     instruction_ready
  3633. swapgs_instruction:
  3634.         cmp     [code_type],64
  3635.         jne     illegal_instruction
  3636. simple_instruction_0f_01:
  3637.         mov     ah,al
  3638.         mov     al,0Fh
  3639.         stos    byte [edi]
  3640.         mov     al,1
  3641.         stos    word [edi]
  3642.         jmp     instruction_assembled
  3643.  
  3644. basic_486_instruction:
  3645.         mov     [base_code],0Fh
  3646.         mov     [extended_code],al
  3647.         lods    byte [esi]
  3648.         call    get_size_operator
  3649.         cmp     al,10h
  3650.         je      basic_486_reg
  3651.         cmp     al,'['
  3652.         jne     invalid_operand
  3653.         call    get_address
  3654.         push    edx ebx ecx
  3655.         lods    byte [esi]
  3656.         cmp     al,','
  3657.         jne     invalid_operand
  3658.         call    take_register
  3659.         mov     [postbyte_register],al
  3660.         pop     ecx ebx edx
  3661.         mov     al,ah
  3662.         cmp     al,1
  3663.         je      basic_486_mem_reg_8bit
  3664.         call    operand_autodetect
  3665.         inc     [extended_code]
  3666.       basic_486_mem_reg_8bit:
  3667.         jmp     instruction_ready
  3668.       basic_486_reg:
  3669.         lods    byte [esi]
  3670.         call    convert_register
  3671.         mov     [postbyte_register],al
  3672.         lods    byte [esi]
  3673.         cmp     al,','
  3674.         jne     invalid_operand
  3675.         call    take_register
  3676.         mov     bl,[postbyte_register]
  3677.         mov     [postbyte_register],al
  3678.         mov     al,ah
  3679.         cmp     al,1
  3680.         je      basic_486_reg_reg_8bit
  3681.         call    operand_autodetect
  3682.         inc     [extended_code]
  3683.       basic_486_reg_reg_8bit:
  3684.         jmp     nomem_instruction_ready
  3685. bswap_instruction:
  3686.         call    take_register
  3687.         test    al,1000b
  3688.         jz      bswap_reg_code_ok
  3689.         or      [rex_prefix],41h
  3690.         and     al,111b
  3691.       bswap_reg_code_ok:
  3692.         add     al,0C8h
  3693.         mov     [extended_code],al
  3694.         mov     [base_code],0Fh
  3695.         cmp     ah,8
  3696.         je      bswap_reg64
  3697.         cmp     ah,4
  3698.         jne     invalid_operand_size
  3699.         call    operand_32bit
  3700.         call    store_classic_instruction_code
  3701.         jmp     instruction_assembled
  3702.       bswap_reg64:
  3703.         call    operand_64bit
  3704.         call    store_classic_instruction_code
  3705.         jmp     instruction_assembled
  3706. cmpxchgx_instruction:
  3707.         mov     [base_code],0Fh
  3708.         mov     [extended_code],0C7h
  3709.         mov     [postbyte_register],al
  3710.         lods    byte [esi]
  3711.         call    get_size_operator
  3712.         cmp     al,'['
  3713.         jne     invalid_operand
  3714.         call    get_address
  3715.         mov     ah,1
  3716.         xchg    [postbyte_register],ah
  3717.         mov     al,[operand_size]
  3718.         or      al,al
  3719.         jz      cmpxchgx_size_ok
  3720.         cmp     al,ah
  3721.         jne     invalid_operand_size
  3722.       cmpxchgx_size_ok:
  3723.         cmp     ah,16
  3724.         jne     cmpxchgx_store
  3725.         call    operand_64bit
  3726.       cmpxchgx_store:
  3727.         jmp     instruction_ready
  3728. nop_instruction:
  3729.         mov     ah,[esi]
  3730.         cmp     ah,10h
  3731.         je      extended_nop
  3732.         cmp     ah,11h
  3733.         je      extended_nop
  3734.         cmp     ah,'['
  3735.         je      extended_nop
  3736.         stos    byte [edi]
  3737.         jmp     instruction_assembled
  3738.       extended_nop:
  3739.         mov     [base_code],0Fh
  3740.         mov     [extended_code],1Fh
  3741.         mov     [postbyte_register],0
  3742.         lods    byte [esi]
  3743.         call    get_size_operator
  3744.         cmp     al,10h
  3745.         je      extended_nop_reg
  3746.         cmp     al,'['
  3747.         jne     invalid_operand
  3748.         call    get_address
  3749.         mov     al,[operand_size]
  3750.         or      al,al
  3751.         jz      extended_nop_store
  3752.         call    operand_autodetect
  3753.       extended_nop_store:
  3754.         jmp     instruction_ready
  3755.       extended_nop_reg:
  3756.         lods    byte [esi]
  3757.         call    convert_register
  3758.         mov     bl,al
  3759.         mov     al,ah
  3760.         call    operand_autodetect
  3761.         jmp     nomem_instruction_ready
  3762.  
  3763. basic_fpu_instruction:
  3764.         mov     [postbyte_register],al
  3765.         mov     [base_code],0D8h
  3766.         lods    byte [esi]
  3767.         call    get_size_operator
  3768.         cmp     al,10h
  3769.         je      basic_fpu_streg
  3770.         cmp     al,'['
  3771.         je      basic_fpu_mem
  3772.         dec     esi
  3773.         mov     ah,[postbyte_register]
  3774.         cmp     ah,2
  3775.         jb      invalid_operand
  3776.         cmp     ah,3
  3777.         ja      invalid_operand
  3778.         mov     bl,1
  3779.         jmp     nomem_instruction_ready
  3780.       basic_fpu_mem:
  3781.         call    get_address
  3782.         mov     al,[operand_size]
  3783.         cmp     al,4
  3784.         je      basic_fpu_mem_32bit
  3785.         cmp     al,8
  3786.         je      basic_fpu_mem_64bit
  3787.         or      al,al
  3788.         jnz     invalid_operand_size
  3789.         call    recoverable_unknown_size
  3790.       basic_fpu_mem_32bit:
  3791.         jmp     instruction_ready
  3792.       basic_fpu_mem_64bit:
  3793.         mov     [base_code],0DCh
  3794.         jmp     instruction_ready
  3795.       basic_fpu_streg:
  3796.         lods    byte [esi]
  3797.         call    convert_fpu_register
  3798.         mov     bl,al
  3799.         mov     ah,[postbyte_register]
  3800.         cmp     ah,2
  3801.         je      basic_fpu_single_streg
  3802.         cmp     ah,3
  3803.         je      basic_fpu_single_streg
  3804.         or      al,al
  3805.         jz      basic_fpu_st0
  3806.         test    ah,110b
  3807.         jz      basic_fpu_streg_st0
  3808.         xor     [postbyte_register],1
  3809.       basic_fpu_streg_st0:
  3810.         lods    byte [esi]
  3811.         cmp     al,','
  3812.         jne     invalid_operand
  3813.         lods    byte [esi]
  3814.         call    get_size_operator
  3815.         cmp     al,10h
  3816.         jne     invalid_operand
  3817.         lods    byte [esi]
  3818.         call    convert_fpu_register
  3819.         or      al,al
  3820.         jnz     invalid_operand
  3821.         mov     [base_code],0DCh
  3822.         jmp     nomem_instruction_ready
  3823.       basic_fpu_st0:
  3824.         lods    byte [esi]
  3825.         cmp     al,','
  3826.         jne     invalid_operand
  3827.         lods    byte [esi]
  3828.         call    get_size_operator
  3829.         cmp     al,10h
  3830.         jne     invalid_operand
  3831.         lods    byte [esi]
  3832.         call    convert_fpu_register
  3833.         mov     bl,al
  3834.       basic_fpu_single_streg:
  3835.         mov     [base_code],0D8h
  3836.         jmp     nomem_instruction_ready
  3837. simple_fpu_instruction:
  3838.         mov     ah,al
  3839.         or      ah,11000000b
  3840.         mov     al,0D9h
  3841.         stos    word [edi]
  3842.         jmp     instruction_assembled
  3843. fi_instruction:
  3844.         mov     [postbyte_register],al
  3845.         lods    byte [esi]
  3846.         call    get_size_operator
  3847.         cmp     al,'['
  3848.         jne     invalid_operand
  3849.         call    get_address
  3850.         mov     al,[operand_size]
  3851.         cmp     al,2
  3852.         je      fi_mem_16bit
  3853.         cmp     al,4
  3854.         je      fi_mem_32bit
  3855.         or      al,al
  3856.         jnz     invalid_operand_size
  3857.         call    recoverable_unknown_size
  3858.       fi_mem_32bit:
  3859.         mov     [base_code],0DAh
  3860.         jmp     instruction_ready
  3861.       fi_mem_16bit:
  3862.         mov     [base_code],0DEh
  3863.         jmp     instruction_ready
  3864. fld_instruction:
  3865.         mov     [postbyte_register],al
  3866.         lods    byte [esi]
  3867.         call    get_size_operator
  3868.         cmp     al,10h
  3869.         je      fld_streg
  3870.         cmp     al,'['
  3871.         jne     invalid_operand
  3872.         call    get_address
  3873.         mov     al,[operand_size]
  3874.         cmp     al,4
  3875.         je      fld_mem_32bit
  3876.         cmp     al,8
  3877.         je      fld_mem_64bit
  3878.         cmp     al,10
  3879.         je      fld_mem_80bit
  3880.         or      al,al
  3881.         jnz     invalid_operand_size
  3882.         call    recoverable_unknown_size
  3883.       fld_mem_32bit:
  3884.         mov     [base_code],0D9h
  3885.         jmp     instruction_ready
  3886.       fld_mem_64bit:
  3887.         mov     [base_code],0DDh
  3888.         jmp     instruction_ready
  3889.       fld_mem_80bit:
  3890.         mov     al,[postbyte_register]
  3891.         cmp     al,0
  3892.         je      fld_mem_80bit_store
  3893.         dec     [postbyte_register]
  3894.         cmp     al,3
  3895.         je      fld_mem_80bit_store
  3896.         jmp     invalid_operand_size
  3897.       fld_mem_80bit_store:
  3898.         add     [postbyte_register],5
  3899.         mov     [base_code],0DBh
  3900.         jmp     instruction_ready
  3901.       fld_streg:
  3902.         lods    byte [esi]
  3903.         call    convert_fpu_register
  3904.         mov     bl,al
  3905.         cmp     [postbyte_register],2
  3906.         jae     fst_streg
  3907.         mov     [base_code],0D9h
  3908.         jmp     nomem_instruction_ready
  3909.       fst_streg:
  3910.         mov     [base_code],0DDh
  3911.         jmp     nomem_instruction_ready
  3912. fild_instruction:
  3913.         mov     [postbyte_register],al
  3914.         lods    byte [esi]
  3915.         call    get_size_operator
  3916.         cmp     al,'['
  3917.         jne     invalid_operand
  3918.         call    get_address
  3919.         mov     al,[operand_size]
  3920.         cmp     al,2
  3921.         je      fild_mem_16bit
  3922.         cmp     al,4
  3923.         je      fild_mem_32bit
  3924.         cmp     al,8
  3925.         je      fild_mem_64bit
  3926.         or      al,al
  3927.         jnz     invalid_operand_size
  3928.         call    recoverable_unknown_size
  3929.       fild_mem_32bit:
  3930.         mov     [base_code],0DBh
  3931.         jmp     instruction_ready
  3932.       fild_mem_16bit:
  3933.         mov     [base_code],0DFh
  3934.         jmp     instruction_ready
  3935.       fild_mem_64bit:
  3936.         mov     al,[postbyte_register]
  3937.         cmp     al,1
  3938.         je      fisttp_64bit_store
  3939.         jb      fild_mem_64bit_store
  3940.         dec     [postbyte_register]
  3941.         cmp     al,3
  3942.         je      fild_mem_64bit_store
  3943.         jmp     invalid_operand_size
  3944.       fild_mem_64bit_store:
  3945.         add     [postbyte_register],5
  3946.         mov     [base_code],0DFh
  3947.         jmp     instruction_ready
  3948.       fisttp_64bit_store:
  3949.         mov     [base_code],0DDh
  3950.         jmp     instruction_ready
  3951. fbld_instruction:
  3952.         mov     [postbyte_register],al
  3953.         lods    byte [esi]
  3954.         call    get_size_operator
  3955.         cmp     al,'['
  3956.         jne     invalid_operand
  3957.         call    get_address
  3958.         mov     al,[operand_size]
  3959.         or      al,al
  3960.         jz      fbld_mem_80bit
  3961.         cmp     al,10
  3962.         je      fbld_mem_80bit
  3963.         jmp     invalid_operand_size
  3964.       fbld_mem_80bit:
  3965.         mov     [base_code],0DFh
  3966.         jmp     instruction_ready
  3967. faddp_instruction:
  3968.         mov     [postbyte_register],al
  3969.         mov     [base_code],0DEh
  3970.         mov     edx,esi
  3971.         lods    byte [esi]
  3972.         call    get_size_operator
  3973.         cmp     al,10h
  3974.         je      faddp_streg
  3975.         mov     esi,edx
  3976.         mov     bl,1
  3977.         jmp     nomem_instruction_ready
  3978.       faddp_streg:
  3979.         lods    byte [esi]
  3980.         call    convert_fpu_register
  3981.         mov     bl,al
  3982.         lods    byte [esi]
  3983.         cmp     al,','
  3984.         jne     invalid_operand
  3985.         lods    byte [esi]
  3986.         call    get_size_operator
  3987.         cmp     al,10h
  3988.         jne     invalid_operand
  3989.         lods    byte [esi]
  3990.         call    convert_fpu_register
  3991.         or      al,al
  3992.         jnz     invalid_operand
  3993.         jmp     nomem_instruction_ready
  3994. fcompp_instruction:
  3995.         mov     ax,0D9DEh
  3996.         stos    word [edi]
  3997.         jmp     instruction_assembled
  3998. fucompp_instruction:
  3999.         mov     ax,0E9DAh
  4000.         stos    word [edi]
  4001.         jmp     instruction_assembled
  4002. fxch_instruction:
  4003.         mov     dx,01D9h
  4004.         jmp     fpu_single_operand
  4005. ffreep_instruction:
  4006.         mov     dx,00DFh
  4007.         jmp     fpu_single_operand
  4008. ffree_instruction:
  4009.         mov     dl,0DDh
  4010.         mov     dh,al
  4011.       fpu_single_operand:
  4012.         mov     ebx,esi
  4013.         lods    byte [esi]
  4014.         call    get_size_operator
  4015.         cmp     al,10h
  4016.         je      fpu_streg
  4017.         or      dh,dh
  4018.         jz      invalid_operand
  4019.         mov     esi,ebx
  4020.         shl     dh,3
  4021.         or      dh,11000001b
  4022.         mov     ax,dx
  4023.         stos    word [edi]
  4024.         jmp     instruction_assembled
  4025.       fpu_streg:
  4026.         lods    byte [esi]
  4027.         call    convert_fpu_register
  4028.         shl     dh,3
  4029.         or      dh,al
  4030.         or      dh,11000000b
  4031.         mov     ax,dx
  4032.         stos    word [edi]
  4033.         jmp     instruction_assembled
  4034.  
  4035. fstenv_instruction:
  4036.         mov     byte [edi],9Bh
  4037.         inc     edi
  4038. fldenv_instruction:
  4039.         mov     [base_code],0D9h
  4040.         jmp     fpu_mem
  4041. fstenv_instruction_16bit:
  4042.         mov     byte [edi],9Bh
  4043.         inc     edi
  4044. fldenv_instruction_16bit:
  4045.         call    operand_16bit
  4046.         jmp     fldenv_instruction
  4047. fstenv_instruction_32bit:
  4048.         mov     byte [edi],9Bh
  4049.         inc     edi
  4050. fldenv_instruction_32bit:
  4051.         call    operand_32bit
  4052.         jmp     fldenv_instruction
  4053. fsave_instruction_32bit:
  4054.         mov     byte [edi],9Bh
  4055.         inc     edi
  4056. fnsave_instruction_32bit:
  4057.         call    operand_32bit
  4058.         jmp     fnsave_instruction
  4059. fsave_instruction_16bit:
  4060.         mov     byte [edi],9Bh
  4061.         inc     edi
  4062. fnsave_instruction_16bit:
  4063.         call    operand_16bit
  4064.         jmp     fnsave_instruction
  4065. fsave_instruction:
  4066.         mov     byte [edi],9Bh
  4067.         inc     edi
  4068. fnsave_instruction:
  4069.         mov     [base_code],0DDh
  4070.       fpu_mem:
  4071.         mov     [postbyte_register],al
  4072.         lods    byte [esi]
  4073.         call    get_size_operator
  4074.         cmp     al,'['
  4075.         jne     invalid_operand
  4076.         call    get_address
  4077.         cmp     [operand_size],0
  4078.         jne     invalid_operand_size
  4079.         jmp     instruction_ready
  4080. fstcw_instruction:
  4081.         mov     byte [edi],9Bh
  4082.         inc     edi
  4083. fldcw_instruction:
  4084.         mov     [postbyte_register],al
  4085.         mov     [base_code],0D9h
  4086.         lods    byte [esi]
  4087.         call    get_size_operator
  4088.         cmp     al,'['
  4089.         jne     invalid_operand
  4090.         call    get_address
  4091.         mov     al,[operand_size]
  4092.         or      al,al
  4093.         jz      fldcw_mem_16bit
  4094.         cmp     al,2
  4095.         je      fldcw_mem_16bit
  4096.         jmp     invalid_operand_size
  4097.       fldcw_mem_16bit:
  4098.         jmp     instruction_ready
  4099. fstsw_instruction:
  4100.         mov     al,9Bh
  4101.         stos    byte [edi]
  4102. fnstsw_instruction:
  4103.         mov     [base_code],0DDh
  4104.         mov     [postbyte_register],7
  4105.         lods    byte [esi]
  4106.         call    get_size_operator
  4107.         cmp     al,10h
  4108.         je      fstsw_reg
  4109.         cmp     al,'['
  4110.         jne     invalid_operand
  4111.         call    get_address
  4112.         mov     al,[operand_size]
  4113.         or      al,al
  4114.         jz      fstsw_mem_16bit
  4115.         cmp     al,2
  4116.         je      fstsw_mem_16bit
  4117.         jmp     invalid_operand_size
  4118.       fstsw_mem_16bit:
  4119.         jmp     instruction_ready
  4120.       fstsw_reg:
  4121.         lods    byte [esi]
  4122.         call    convert_register
  4123.         cmp     ax,0200h
  4124.         jne     invalid_operand
  4125.         mov     ax,0E0DFh
  4126.         stos    word [edi]
  4127.         jmp     instruction_assembled
  4128. finit_instruction:
  4129.         mov     byte [edi],9Bh
  4130.         inc     edi
  4131. fninit_instruction:
  4132.         mov     ah,al
  4133.         mov     al,0DBh
  4134.         stos    word [edi]
  4135.         jmp     instruction_assembled
  4136. fcmov_instruction:
  4137.         mov     dh,0DAh
  4138.         jmp     fcomi_streg
  4139. fcomi_instruction:
  4140.         mov     dh,0DBh
  4141.         jmp     fcomi_streg
  4142. fcomip_instruction:
  4143.         mov     dh,0DFh
  4144.       fcomi_streg:
  4145.         mov     dl,al
  4146.         lods    byte [esi]
  4147.         call    get_size_operator
  4148.         cmp     al,10h
  4149.         jne     invalid_operand
  4150.         lods    byte [esi]
  4151.         call    convert_fpu_register
  4152.         mov     ah,al
  4153.         cmp     byte [esi],','
  4154.         je      fcomi_st0_streg
  4155.         add     ah,dl
  4156.         mov     al,dh
  4157.         stos    word [edi]
  4158.         jmp     instruction_assembled
  4159.       fcomi_st0_streg:
  4160.         or      ah,ah
  4161.         jnz     invalid_operand
  4162.         inc     esi
  4163.         lods    byte [esi]
  4164.         call    get_size_operator
  4165.         cmp     al,10h
  4166.         jne     invalid_operand
  4167.         lods    byte [esi]
  4168.         call    convert_fpu_register
  4169.         mov     ah,al
  4170.         add     ah,dl
  4171.         mov     al,dh
  4172.         stos    word [edi]
  4173.         jmp     instruction_assembled
  4174.  
  4175. basic_mmx_instruction:
  4176.         mov     [base_code],0Fh
  4177.         mov     [extended_code],al
  4178.       mmx_instruction:
  4179.         lods    byte [esi]
  4180.         call    get_size_operator
  4181.         cmp     al,10h
  4182.         jne     invalid_operand
  4183.         lods    byte [esi]
  4184.         call    convert_mmx_register
  4185.         call    make_mmx_prefix
  4186.         mov     [postbyte_register],al
  4187.         lods    byte [esi]
  4188.         cmp     al,','
  4189.         jne     invalid_operand
  4190.         lods    byte [esi]
  4191.         call    get_size_operator
  4192.         cmp     al,10h
  4193.         je      mmx_mmreg_mmreg
  4194.         cmp     al,'['
  4195.         jne     invalid_operand
  4196.       mmx_mmreg_mem:
  4197.         call    get_address
  4198.         jmp     instruction_ready
  4199.       mmx_mmreg_mmreg:
  4200.         lods    byte [esi]
  4201.         call    convert_mmx_register
  4202.         mov     bl,al
  4203.         jmp     nomem_instruction_ready
  4204. mmx_bit_shift_instruction:
  4205.         mov     [base_code],0Fh
  4206.         mov     [extended_code],al
  4207.         lods    byte [esi]
  4208.         call    get_size_operator
  4209.         cmp     al,10h
  4210.         jne     invalid_operand
  4211.         lods    byte [esi]
  4212.         call    convert_mmx_register
  4213.         call    make_mmx_prefix
  4214.         mov     [postbyte_register],al
  4215.         lods    byte [esi]
  4216.         cmp     al,','
  4217.         jne     invalid_operand
  4218.         mov     [operand_size],0
  4219.         lods    byte [esi]
  4220.         call    get_size_operator
  4221.         cmp     al,10h
  4222.         je      mmx_mmreg_mmreg
  4223.         cmp     al,'('
  4224.         je      mmx_ps_mmreg_imm8
  4225.         cmp     al,'['
  4226.         je      mmx_mmreg_mem
  4227.         jmp     invalid_operand
  4228.       mmx_ps_mmreg_imm8:
  4229.         call    get_byte_value
  4230.         mov     byte [value],al
  4231.         test    [operand_size],not 1
  4232.         jnz     invalid_value
  4233.         mov     bl,[extended_code]
  4234.         mov     al,bl
  4235.         shr     bl,4
  4236.         and     al,1111b
  4237.         add     al,70h
  4238.         mov     [extended_code],al
  4239.         sub     bl,0Ch
  4240.         shl     bl,1
  4241.         xchg    bl,[postbyte_register]
  4242.         call    store_nomem_instruction
  4243.         mov     al,byte [value]
  4244.         stos    byte [edi]
  4245.         jmp     instruction_assembled
  4246. pmovmskb_instruction:
  4247.         mov     [base_code],0Fh
  4248.         mov     [extended_code],al
  4249.         call    take_register
  4250.         cmp     ah,4
  4251.         je      pmovmskb_reg_size_ok
  4252.         cmp     [code_type],64
  4253.         jne     invalid_operand_size
  4254.         cmp     ah,8
  4255.         jnz     invalid_operand_size
  4256.       pmovmskb_reg_size_ok:
  4257.         mov     [postbyte_register],al
  4258.         mov     [operand_size],0
  4259.         lods    byte [esi]
  4260.         cmp     al,','
  4261.         jne     invalid_operand
  4262.         lods    byte [esi]
  4263.         call    get_size_operator
  4264.         cmp     al,10h
  4265.         jne     invalid_operand
  4266.         lods    byte [esi]
  4267.         call    convert_mmx_register
  4268.         mov     bl,al
  4269.         call    make_mmx_prefix
  4270.         cmp     [extended_code],0C5h
  4271.         je      mmx_nomem_imm8
  4272.         jmp     nomem_instruction_ready
  4273.       mmx_imm8:
  4274.         push    ebx ecx edx
  4275.         xor     cl,cl
  4276.         xchg    cl,[operand_size]
  4277.         lods    byte [esi]
  4278.         cmp     al,','
  4279.         jne     invalid_operand
  4280.         lods    byte [esi]
  4281.         call    get_size_operator
  4282.         test    ah,not 1
  4283.         jnz     invalid_operand_size
  4284.         mov     [operand_size],cl
  4285.         cmp     al,'('
  4286.         jne     invalid_operand
  4287.         call    get_byte_value
  4288.         mov     byte [value],al
  4289.         pop     edx ecx ebx
  4290.         call    store_instruction_with_imm8
  4291.         jmp     instruction_assembled
  4292.       mmx_nomem_imm8:
  4293.         call    store_nomem_instruction
  4294.         call    append_imm8
  4295.         jmp     instruction_assembled
  4296.       append_imm8:
  4297.         mov     [operand_size],0
  4298.         lods    byte [esi]
  4299.         cmp     al,','
  4300.         jne     invalid_operand
  4301.         lods    byte [esi]
  4302.         call    get_size_operator
  4303.         test    ah,not 1
  4304.         jnz     invalid_operand_size
  4305.         cmp     al,'('
  4306.         jne     invalid_operand
  4307.         call    get_byte_value
  4308.         stosb
  4309.         ret
  4310. pinsrw_instruction:
  4311.         mov     [extended_code],al
  4312.         mov     [base_code],0Fh
  4313.         lods    byte [esi]
  4314.         call    get_size_operator
  4315.         cmp     al,10h
  4316.         jne     invalid_operand
  4317.         lods    byte [esi]
  4318.         call    convert_mmx_register
  4319.         call    make_mmx_prefix
  4320.         mov     [postbyte_register],al
  4321.         mov     [operand_size],0
  4322.         lods    byte [esi]
  4323.         cmp     al,','
  4324.         jne     invalid_operand
  4325.         lods    byte [esi]
  4326.         call    get_size_operator
  4327.         cmp     al,10h
  4328.         je      pinsrw_mmreg_reg
  4329.         cmp     al,'['
  4330.         jne     invalid_operand
  4331.         call    get_address
  4332.         cmp     [operand_size],0
  4333.         je      mmx_imm8
  4334.         cmp     [operand_size],2
  4335.         jne     invalid_operand_size
  4336.         jmp     mmx_imm8
  4337.       pinsrw_mmreg_reg:
  4338.         lods    byte [esi]
  4339.         call    convert_register
  4340.         cmp     ah,4
  4341.         jne     invalid_operand_size
  4342.         mov     bl,al
  4343.         jmp     mmx_nomem_imm8
  4344. pshufw_instruction:
  4345.         mov     [mmx_size],8
  4346.         mov     [opcode_prefix],al
  4347.         jmp     pshuf_instruction
  4348. pshufd_instruction:
  4349.         mov     [mmx_size],16
  4350.         mov     [opcode_prefix],al
  4351.       pshuf_instruction:
  4352.         mov     [base_code],0Fh
  4353.         mov     [extended_code],70h
  4354.         lods    byte [esi]
  4355.         call    get_size_operator
  4356.         cmp     al,10h
  4357.         jne     invalid_operand
  4358.         lods    byte [esi]
  4359.         call    convert_mmx_register
  4360.         cmp     ah,[mmx_size]
  4361.         jne     invalid_operand_size
  4362.         mov     [postbyte_register],al
  4363.         lods    byte [esi]
  4364.         cmp     al,','
  4365.         jne     invalid_operand
  4366.         lods    byte [esi]
  4367.         call    get_size_operator
  4368.         cmp     al,10h
  4369.         je      pshuf_mmreg_mmreg
  4370.         cmp     al,'['
  4371.         jne     invalid_operand
  4372.         call    get_address
  4373.         jmp     mmx_imm8
  4374.       pshuf_mmreg_mmreg:
  4375.         lods    byte [esi]
  4376.         call    convert_mmx_register
  4377.         mov     bl,al
  4378.         jmp     mmx_nomem_imm8
  4379. movd_instruction:
  4380.         mov     [base_code],0Fh
  4381.         mov     [extended_code],7Eh
  4382.         lods    byte [esi]
  4383.         call    get_size_operator
  4384.         cmp     al,10h
  4385.         je      movd_reg
  4386.         cmp     al,'['
  4387.         jne     invalid_operand
  4388.         call    get_address
  4389.         test    [operand_size],not 4
  4390.         jnz     invalid_operand_size
  4391.         call    get_mmx_source_register
  4392.         jmp     instruction_ready
  4393.       movd_reg:
  4394.         lods    byte [esi]
  4395.         cmp     al,0B0h
  4396.         jae     movd_mmreg
  4397.         call    convert_register
  4398.         cmp     ah,4
  4399.         jne     invalid_operand_size
  4400.         mov     bl,al
  4401.         call    get_mmx_source_register
  4402.         jmp     nomem_instruction_ready
  4403.       movd_mmreg:
  4404.         mov     [extended_code],6Eh
  4405.         call    convert_mmx_register
  4406.         mov     [postbyte_register],al
  4407.         call    make_mmx_prefix
  4408.         mov     [operand_size],0
  4409.         lods    byte [esi]
  4410.         cmp     al,','
  4411.         jne     invalid_operand
  4412.         lods    byte [esi]
  4413.         call    get_size_operator
  4414.         cmp     al,10h
  4415.         je      movd_mmreg_reg
  4416.         cmp     al,'['
  4417.         jne     invalid_operand
  4418.         call    get_address
  4419.         test    [operand_size],not 4
  4420.         jnz     invalid_operand_size
  4421.         jmp     instruction_ready
  4422.       movd_mmreg_reg:
  4423.         lods    byte [esi]
  4424.         call    convert_register
  4425.         cmp     ah,4
  4426.         jne     invalid_operand_size
  4427.         mov     bl,al
  4428.         jmp     nomem_instruction_ready
  4429.       get_mmx_source_register:
  4430.         mov     [operand_size],0
  4431.         lods    byte [esi]
  4432.         cmp     al,','
  4433.         jne     invalid_operand
  4434.         lods    byte [esi]
  4435.         call    get_size_operator
  4436.         cmp     al,10h
  4437.         jne     invalid_operand
  4438.         lods    byte [esi]
  4439.         call    convert_mmx_register
  4440.         mov     [postbyte_register],al
  4441.       make_mmx_prefix:
  4442.         cmp     [operand_size],16
  4443.         jne     no_mmx_prefix
  4444.         mov     [operand_prefix],66h
  4445.       no_mmx_prefix:
  4446.         ret
  4447. movq_instruction:
  4448.         mov     [base_code],0Fh
  4449.         lods    byte [esi]
  4450.         call    get_size_operator
  4451.         cmp     al,10h
  4452.         je      movq_reg
  4453.         cmp     al,'['
  4454.         jne     invalid_operand
  4455.         call    get_address
  4456.         test    [operand_size],not 8
  4457.         jnz     invalid_operand_size
  4458.         call    get_mmx_source_register
  4459.         mov     al,7Fh
  4460.         cmp     ah,8
  4461.         je      movq_mem_ready
  4462.         mov     al,0D6h
  4463.      movq_mem_ready:
  4464.         mov     [extended_code],al
  4465.         jmp     instruction_ready
  4466.      movq_reg:
  4467.         lods    byte [esi]
  4468.         cmp     al,0B0h
  4469.         jae     movq_mmreg
  4470.         call    convert_register
  4471.         cmp     ah,8
  4472.         jne     invalid_operand_size
  4473.         mov     bl,al
  4474.         mov     [extended_code],7Eh
  4475.         call    operand_64bit
  4476.         call    get_mmx_source_register
  4477.         jmp     nomem_instruction_ready
  4478.      movq_mmreg:
  4479.         call    convert_mmx_register
  4480.         mov     [postbyte_register],al
  4481.         mov     [extended_code],6Fh
  4482.         mov     [mmx_size],ah
  4483.         cmp     ah,16
  4484.         jne     movq_mmreg_
  4485.         mov     [extended_code],7Eh
  4486.         mov     [opcode_prefix],0F3h
  4487.       movq_mmreg_:
  4488.         lods    byte [esi]
  4489.         cmp     al,','
  4490.         jne     invalid_operand
  4491.         mov     [operand_size],0
  4492.         lods    byte [esi]
  4493.         call    get_size_operator
  4494.         cmp     al,10h
  4495.         je      movq_mmreg_reg
  4496.         cmp     al,'['
  4497.         jne     invalid_operand
  4498.         call    get_address
  4499.         test    [operand_size],not 8
  4500.         jnz     invalid_operand_size
  4501.         jmp     instruction_ready
  4502.       movq_mmreg_reg:
  4503.         lods    byte [esi]
  4504.         cmp     al,0B0h
  4505.         jae     movq_mmreg_mmreg
  4506.         mov     [operand_size],0
  4507.         call    convert_register
  4508.         cmp     ah,8
  4509.         jne     invalid_operand_size
  4510.         mov     [extended_code],6Eh
  4511.         mov     [opcode_prefix],0
  4512.         mov     bl,al
  4513.         cmp     [mmx_size],16
  4514.         jne     movq_mmreg_reg_store
  4515.         mov     [opcode_prefix],66h
  4516.       movq_mmreg_reg_store:
  4517.         call    operand_64bit
  4518.         jmp     nomem_instruction_ready
  4519.       movq_mmreg_mmreg:
  4520.         call    convert_mmx_register
  4521.         cmp     ah,[mmx_size]
  4522.         jne     invalid_operand_size
  4523.         mov     bl,al
  4524.         jmp     nomem_instruction_ready
  4525. movdq_instruction:
  4526.         mov     [opcode_prefix],al
  4527.         mov     [base_code],0Fh
  4528.         mov     [extended_code],6Fh
  4529.         lods    byte [esi]
  4530.         call    get_size_operator
  4531.         cmp     al,10h
  4532.         je      movdq_mmreg
  4533.         cmp     al,'['
  4534.         jne     invalid_operand
  4535.         call    get_address
  4536.         lods    byte [esi]
  4537.         cmp     al,','
  4538.         jne     invalid_operand
  4539.         lods    byte [esi]
  4540.         call    get_size_operator
  4541.         cmp     al,10h
  4542.         jne     invalid_operand
  4543.         lods    byte [esi]
  4544.         call    convert_xmm_register
  4545.         mov     [postbyte_register],al
  4546.         mov     [extended_code],7Fh
  4547.         jmp     instruction_ready
  4548.       movdq_mmreg:
  4549.         lods    byte [esi]
  4550.         call    convert_xmm_register
  4551.         mov     [postbyte_register],al
  4552.         lods    byte [esi]
  4553.         cmp     al,','
  4554.         jne     invalid_operand
  4555.         lods    byte [esi]
  4556.         call    get_size_operator
  4557.         cmp     al,10h
  4558.         je      movdq_mmreg_mmreg
  4559.         cmp     al,'['
  4560.         jne     invalid_operand
  4561.         call    get_address
  4562.         jmp     instruction_ready
  4563.       movdq_mmreg_mmreg:
  4564.         lods    byte [esi]
  4565.         call    convert_xmm_register
  4566.         mov     bl,al
  4567.         jmp     nomem_instruction_ready
  4568. lddqu_instruction:
  4569.         lods    byte [esi]
  4570.         call    get_size_operator
  4571.         cmp     al,10h
  4572.         jne     invalid_operand
  4573.         lods    byte [esi]
  4574.         call    convert_xmm_register
  4575.         push    eax
  4576.         lods    byte [esi]
  4577.         cmp     al,','
  4578.         jne     invalid_operand
  4579.         lods    byte [esi]
  4580.         call    get_size_operator
  4581.         cmp     al,'['
  4582.         jne     invalid_operand
  4583.         call    get_address
  4584.         pop     eax
  4585.         mov     [postbyte_register],al
  4586.         mov     [opcode_prefix],0F2h
  4587.         mov     [base_code],0Fh
  4588.         mov     [extended_code],0F0h
  4589.         jmp     instruction_ready
  4590.  
  4591. movdq2q_instruction:
  4592.         mov     [opcode_prefix],0F2h
  4593.         mov     [mmx_size],8
  4594.         jmp     movq2dq_
  4595. movq2dq_instruction:
  4596.         mov     [opcode_prefix],0F3h
  4597.         mov     [mmx_size],16
  4598.       movq2dq_:
  4599.         lods    byte [esi]
  4600.         call    get_size_operator
  4601.         cmp     al,10h
  4602.         jne     invalid_operand
  4603.         lods    byte [esi]
  4604.         call    convert_mmx_register
  4605.         cmp     ah,[mmx_size]
  4606.         jne     invalid_operand_size
  4607.         mov     [postbyte_register],al
  4608.         mov     [operand_size],0
  4609.         lods    byte [esi]
  4610.         cmp     al,','
  4611.         jne     invalid_operand
  4612.         lods    byte [esi]
  4613.         call    get_size_operator
  4614.         cmp     al,10h
  4615.         jne     invalid_operand
  4616.         lods    byte [esi]
  4617.         call    convert_mmx_register
  4618.         xor     [mmx_size],8+16
  4619.         cmp     ah,[mmx_size]
  4620.         jne     invalid_operand_size
  4621.         mov     bl,al
  4622.         mov     [base_code],0Fh
  4623.         mov     [extended_code],0D6h
  4624.         jmp     nomem_instruction_ready
  4625.  
  4626. sse_ps_instruction_imm8:
  4627.         mov     [immediate_size],1
  4628. sse_ps_instruction:
  4629.         mov     [mmx_size],16
  4630.         jmp     sse_instruction
  4631. sse_pd_instruction_imm8:
  4632.         mov     [immediate_size],1
  4633. sse_pd_instruction:
  4634.         mov     [mmx_size],16
  4635.         mov     [opcode_prefix],66h
  4636.         jmp     sse_instruction
  4637. sse_ss_instruction:
  4638.         mov     [mmx_size],4
  4639.         mov     [opcode_prefix],0F3h
  4640.         jmp     sse_instruction
  4641. sse_sd_instruction:
  4642.         mov     [mmx_size],8
  4643.         mov     [opcode_prefix],0F2h
  4644.         jmp     sse_instruction
  4645. cmp_pd_instruction:
  4646.         mov     [opcode_prefix],66h
  4647. cmp_ps_instruction:
  4648.         mov     [mmx_size],16
  4649.         mov     byte [value],al
  4650.         mov     al,0C2h
  4651.         jmp     sse_instruction
  4652. cmp_ss_instruction:
  4653.         mov     [mmx_size],4
  4654.         mov     [opcode_prefix],0F3h
  4655.         jmp     cmp_sx_instruction
  4656. cmpsd_instruction:
  4657.         mov     al,0A7h
  4658.         mov     ah,[esi]
  4659.         or      ah,ah
  4660.         jz      simple_instruction_32bit
  4661.         cmp     ah,0Fh
  4662.         je      simple_instruction_32bit
  4663.         mov     al,-1
  4664. cmp_sd_instruction:
  4665.         mov     [mmx_size],8
  4666.         mov     [opcode_prefix],0F2h
  4667.       cmp_sx_instruction:
  4668.         mov     byte [value],al
  4669.         mov     al,0C2h
  4670.         jmp     sse_instruction
  4671. comiss_instruction:
  4672.         mov     [mmx_size],4
  4673.         jmp     sse_instruction
  4674. comisd_instruction:
  4675.         mov     [mmx_size],8
  4676.         mov     [opcode_prefix],66h
  4677.         jmp     sse_instruction
  4678. cvtdq2pd_instruction:
  4679.         mov     [opcode_prefix],0F3h
  4680. cvtps2pd_instruction:
  4681.         mov     [mmx_size],8
  4682.         jmp     sse_instruction
  4683. cvtpd2dq_instruction:
  4684.         mov     [mmx_size],16
  4685.         mov     [opcode_prefix],0F2h
  4686.         jmp     sse_instruction
  4687. movshdup_instruction:
  4688.         mov     [mmx_size],16
  4689.         mov     [opcode_prefix],0F3h
  4690. sse_instruction:
  4691.         mov     [base_code],0Fh
  4692.         mov     [extended_code],al
  4693.         lods    byte [esi]
  4694.         call    get_size_operator
  4695.         cmp     al,10h
  4696.         jne     invalid_operand
  4697.       sse_xmmreg:
  4698.         lods    byte [esi]
  4699.         call    convert_xmm_register
  4700.       sse_reg:
  4701.         mov     [postbyte_register],al
  4702.         mov     [operand_size],0
  4703.         lods    byte [esi]
  4704.         cmp     al,','
  4705.         jne     invalid_operand
  4706.         lods    byte [esi]
  4707.         call    get_size_operator
  4708.         cmp     al,10h
  4709.         je      sse_xmmreg_xmmreg
  4710.       sse_reg_mem:
  4711.         cmp     al,'['
  4712.         jne     invalid_operand
  4713.         call    get_address
  4714.         cmp     [operand_size],0
  4715.         je      sse_mem_size_ok
  4716.         mov     al,[mmx_size]
  4717.         cmp     [operand_size],al
  4718.         jne     invalid_operand_size
  4719.       sse_mem_size_ok:
  4720.         mov     al,[extended_code]
  4721.         mov     ah,[supplemental_code]
  4722.         cmp     al,0C2h
  4723.         je      sse_cmp_mem_ok
  4724.         cmp     ax,443Ah
  4725.         je      sse_cmp_mem_ok
  4726.         cmp     [immediate_size],1
  4727.         je      mmx_imm8
  4728.         cmp     [immediate_size],-1
  4729.         jne     sse_ok
  4730.         call    take_additional_xmm0
  4731.         mov     [immediate_size],0
  4732.       sse_ok:
  4733.         jmp     instruction_ready
  4734.       sse_cmp_mem_ok:
  4735.         cmp     byte [value],-1
  4736.         je      mmx_imm8
  4737.         call    store_instruction_with_imm8
  4738.         jmp     instruction_assembled
  4739.       sse_xmmreg_xmmreg:
  4740.         cmp     [operand_prefix],66h
  4741.         jne     sse_xmmreg_xmmreg_ok
  4742.         cmp     [extended_code],12h
  4743.         je      invalid_operand
  4744.         cmp     [extended_code],16h
  4745.         je      invalid_operand
  4746.       sse_xmmreg_xmmreg_ok:
  4747.         lods    byte [esi]
  4748.         call    convert_xmm_register
  4749.         mov     bl,al
  4750.         mov     al,[extended_code]
  4751.         mov     ah,[supplemental_code]
  4752.         cmp     al,0C2h
  4753.         je      sse_cmp_nomem_ok
  4754.         cmp     ax,443Ah
  4755.         je      sse_cmp_nomem_ok
  4756.         cmp     [immediate_size],1
  4757.         je      mmx_nomem_imm8
  4758.         cmp     [immediate_size],-1
  4759.         jne     sse_nomem_ok
  4760.         call    take_additional_xmm0
  4761.         mov     [immediate_size],0
  4762.       sse_nomem_ok:
  4763.         jmp     nomem_instruction_ready
  4764.       sse_cmp_nomem_ok:
  4765.         cmp     byte [value],-1
  4766.         je      mmx_nomem_imm8
  4767.         call    store_nomem_instruction
  4768.         mov     al,byte [value]
  4769.         stosb
  4770.         jmp     instruction_assembled
  4771.       take_additional_xmm0:
  4772.         cmp     byte [esi],','
  4773.         jne     additional_xmm0_ok
  4774.         inc     esi
  4775.         lods    byte [esi]
  4776.         cmp     al,10h
  4777.         jne     invalid_operand
  4778.         lods    byte [esi]
  4779.         call    convert_xmm_register
  4780.         test    al,al
  4781.         jnz     invalid_operand
  4782.       additional_xmm0_ok:
  4783.         ret
  4784.  
  4785. pslldq_instruction:
  4786.         mov     [postbyte_register],al
  4787.         mov     [opcode_prefix],66h
  4788.         mov     [base_code],0Fh
  4789.         mov     [extended_code],73h
  4790.         lods    byte [esi]
  4791.         call    get_size_operator
  4792.         cmp     al,10h
  4793.         jne     invalid_operand
  4794.         lods    byte [esi]
  4795.         call    convert_xmm_register
  4796.         mov     bl,al
  4797.         jmp     mmx_nomem_imm8
  4798. movpd_instruction:
  4799.         mov     [opcode_prefix],66h
  4800. movps_instruction:
  4801.         mov     [base_code],0Fh
  4802.         mov     [extended_code],al
  4803.         mov     [mmx_size],16
  4804.         jmp     sse_mov_instruction
  4805. movss_instruction:
  4806.         mov     [mmx_size],4
  4807.         mov     [opcode_prefix],0F3h
  4808.         jmp     sse_movs
  4809. movsd_instruction:
  4810.         mov     al,0A5h
  4811.         mov     ah,[esi]
  4812.         or      ah,ah
  4813.         jz      simple_instruction_32bit
  4814.         cmp     ah,0Fh
  4815.         je      simple_instruction_32bit
  4816.         mov     [mmx_size],8
  4817.         mov     [opcode_prefix],0F2h
  4818.       sse_movs:
  4819.         mov     [base_code],0Fh
  4820.         mov     [extended_code],10h
  4821.         jmp     sse_mov_instruction
  4822. sse_mov_instruction:
  4823.         lods    byte [esi]
  4824.         call    get_size_operator
  4825.         cmp     al,10h
  4826.         je      sse_xmmreg
  4827.       sse_mem:
  4828.         cmp     al,'['
  4829.         jne     invalid_operand
  4830.         inc     [extended_code]
  4831.         call    get_address
  4832.         cmp     [operand_size],0
  4833.         je      sse_mem_xmmreg
  4834.         mov     al,[mmx_size]
  4835.         cmp     [operand_size],al
  4836.         jne     invalid_operand_size
  4837.         mov     [operand_size],0
  4838.       sse_mem_xmmreg:
  4839.         lods    byte [esi]
  4840.         cmp     al,','
  4841.         jne     invalid_operand
  4842.         lods    byte [esi]
  4843.         call    get_size_operator
  4844.         cmp     al,10h
  4845.         jne     invalid_operand
  4846.         lods    byte [esi]
  4847.         call    convert_xmm_register
  4848.         mov     [postbyte_register],al
  4849.         jmp     instruction_ready
  4850. movlpd_instruction:
  4851.         mov     [opcode_prefix],66h
  4852. movlps_instruction:
  4853.         mov     [base_code],0Fh
  4854.         mov     [extended_code],al
  4855.         mov     [mmx_size],8
  4856.         lods    byte [esi]
  4857.         call    get_size_operator
  4858.         cmp     al,10h
  4859.         jne     sse_mem
  4860.         lods    byte [esi]
  4861.         call    convert_xmm_register
  4862.         mov     [postbyte_register],al
  4863.         mov     [operand_size],0
  4864.         lods    byte [esi]
  4865.         cmp     al,','
  4866.         jne     invalid_operand
  4867.         lods    byte [esi]
  4868.         call    get_size_operator
  4869.         jmp     sse_reg_mem
  4870. movhlps_instruction:
  4871.         mov     [base_code],0Fh
  4872.         mov     [extended_code],al
  4873.         mov     [mmx_size],0
  4874.         lods    byte [esi]
  4875.         call    get_size_operator
  4876.         cmp     al,10h
  4877.         jne     invalid_operand
  4878.         lods    byte [esi]
  4879.         call    convert_xmm_register
  4880.         mov     [postbyte_register],al
  4881.         lods    byte [esi]
  4882.         cmp     al,','
  4883.         jne     invalid_operand
  4884.         lods    byte [esi]
  4885.         call    get_size_operator
  4886.         cmp     al,10h
  4887.         je      sse_xmmreg_xmmreg_ok
  4888.         jmp     invalid_operand
  4889. maskmovq_instruction:
  4890.         mov     cl,8
  4891.         jmp     maskmov_instruction
  4892. maskmovdqu_instruction:
  4893.         mov     cl,16
  4894.         mov     [opcode_prefix],66h
  4895.       maskmov_instruction:
  4896.         mov     [base_code],0Fh
  4897.         mov     [extended_code],0F7h
  4898.         lods    byte [esi]
  4899.         call    get_size_operator
  4900.         cmp     al,10h
  4901.         jne     invalid_operand
  4902.         lods    byte [esi]
  4903.         call    convert_mmx_register
  4904.         cmp     ah,cl
  4905.         jne     invalid_operand_size
  4906.         mov     [postbyte_register],al
  4907.         lods    byte [esi]
  4908.         cmp     al,','
  4909.         jne     invalid_operand
  4910.         lods    byte [esi]
  4911.         call    get_size_operator
  4912.         cmp     al,10h
  4913.         jne     invalid_operand
  4914.         lods    byte [esi]
  4915.         call    convert_mmx_register
  4916.         mov     bl,al
  4917.         jmp     nomem_instruction_ready
  4918. movmskpd_instruction:
  4919.         mov     [opcode_prefix],66h
  4920. movmskps_instruction:
  4921.         mov     [base_code],0Fh
  4922.         mov     [extended_code],50h
  4923.         call    take_register
  4924.         mov     [postbyte_register],al
  4925.         cmp     ah,4
  4926.         je      movmskps_reg_ok
  4927.         cmp     ah,8
  4928.         jne     invalid_operand_size
  4929.         cmp     [code_type],64
  4930.         jne     invalid_operand
  4931.       movmskps_reg_ok:
  4932.         mov     [operand_size],0
  4933.         lods    byte [esi]
  4934.         cmp     al,','
  4935.         jne     invalid_operand
  4936.         lods    byte [esi]
  4937.         call    get_size_operator
  4938.         cmp     al,10h
  4939.         je      sse_xmmreg_xmmreg_ok
  4940.         jmp     invalid_operand
  4941.  
  4942. cvtpi2pd_instruction:
  4943.         mov     [opcode_prefix],66h
  4944. cvtpi2ps_instruction:
  4945.         mov     [base_code],0Fh
  4946.         mov     [extended_code],al
  4947.         lods    byte [esi]
  4948.         call    get_size_operator
  4949.         cmp     al,10h
  4950.         jne     invalid_operand
  4951.         lods    byte [esi]
  4952.         call    convert_xmm_register
  4953.         mov     [postbyte_register],al
  4954.         mov     [operand_size],0
  4955.         lods    byte [esi]
  4956.         cmp     al,','
  4957.         jne     invalid_operand
  4958.         lods    byte [esi]
  4959.         call    get_size_operator
  4960.         cmp     al,10h
  4961.         je      cvtpi_xmmreg_xmmreg
  4962.         cmp     al,'['
  4963.         jne     invalid_operand
  4964.         call    get_address
  4965.         cmp     [operand_size],0
  4966.         je      cvtpi_size_ok
  4967.         cmp     [operand_size],8
  4968.         jne     invalid_operand_size
  4969.       cvtpi_size_ok:
  4970.         jmp     instruction_ready
  4971.       cvtpi_xmmreg_xmmreg:
  4972.         lods    byte [esi]
  4973.         call    convert_mmx_register
  4974.         cmp     ah,8
  4975.         jne     invalid_operand_size
  4976.         mov     bl,al
  4977.         jmp     nomem_instruction_ready
  4978. cvtsi2ss_instruction:
  4979.         mov     [opcode_prefix],0F3h
  4980.         jmp     cvtsi_instruction
  4981. cvtsi2sd_instruction:
  4982.         mov     [opcode_prefix],0F2h
  4983.       cvtsi_instruction:
  4984.         mov     [base_code],0Fh
  4985.         mov     [extended_code],al
  4986.         lods    byte [esi]
  4987.         call    get_size_operator
  4988.         cmp     al,10h
  4989.         jne     invalid_operand
  4990.         lods    byte [esi]
  4991.         call    convert_xmm_register
  4992.         mov     [postbyte_register],al
  4993.       cvtsi_xmmreg:
  4994.         mov     [operand_size],0
  4995.         lods    byte [esi]
  4996.         cmp     al,','
  4997.         jne     invalid_operand
  4998.         lods    byte [esi]
  4999.         call    get_size_operator
  5000.         cmp     al,10h
  5001.         je      cvtsi_xmmreg_reg
  5002.         cmp     al,'['
  5003.         jne     invalid_operand
  5004.         call    get_address
  5005.         cmp     [operand_size],0
  5006.         je      cvtsi_size_ok
  5007.         cmp     [operand_size],4
  5008.         je      cvtsi_size_ok
  5009.         cmp     [operand_size],8
  5010.         jne     invalid_operand_size
  5011.         call    operand_64bit
  5012.       cvtsi_size_ok:
  5013.         jmp     instruction_ready
  5014.       cvtsi_xmmreg_reg:
  5015.         lods    byte [esi]
  5016.         call    convert_register
  5017.         cmp     ah,4
  5018.         je      cvtsi_xmmreg_reg_store
  5019.         cmp     ah,8
  5020.         jne     invalid_operand_size
  5021.         call    operand_64bit
  5022.       cvtsi_xmmreg_reg_store:
  5023.         mov     bl,al
  5024.         jmp     nomem_instruction_ready
  5025. cvtps2pi_instruction:
  5026.         mov     [mmx_size],8
  5027.         jmp     cvtpd_instruction
  5028. cvtpd2pi_instruction:
  5029.         mov     [opcode_prefix],66h
  5030.         mov     [mmx_size],16
  5031.       cvtpd_instruction:
  5032.         mov     [base_code],0Fh
  5033.         mov     [extended_code],al
  5034.         lods    byte [esi]
  5035.         call    get_size_operator
  5036.         cmp     al,10h
  5037.         jne     invalid_operand
  5038.         lods    byte [esi]
  5039.         call    convert_mmx_register
  5040.         cmp     ah,8
  5041.         jne     invalid_operand_size
  5042.         mov     [operand_size],0
  5043.         jmp     sse_reg
  5044. cvtss2si_instruction:
  5045.         mov     [opcode_prefix],0F3h
  5046.         mov     [mmx_size],4
  5047.         jmp     cvt2si_instruction
  5048. cvtsd2si_instruction:
  5049.         mov     [opcode_prefix],0F2h
  5050.         mov     [mmx_size],8
  5051.       cvt2si_instruction:
  5052.         mov     [extended_code],al
  5053.         mov     [base_code],0Fh
  5054.         call    take_register
  5055.         mov     [operand_size],0
  5056.         cmp     ah,4
  5057.         je      sse_reg
  5058.         cmp     ah,8
  5059.         jne     invalid_operand_size
  5060.         call    operand_64bit
  5061.         jmp     sse_reg
  5062.  
  5063. ssse3_instruction:
  5064.         mov     [base_code],0Fh
  5065.         mov     [extended_code],38h
  5066.         mov     [supplemental_code],al
  5067.         jmp     mmx_instruction
  5068. palignr_instruction:
  5069.         mov     [base_code],0Fh
  5070.         mov     [extended_code],3Ah
  5071.         mov     [supplemental_code],0Fh
  5072.         lods    byte [esi]
  5073.         call    get_size_operator
  5074.         cmp     al,10h
  5075.         jne     invalid_operand
  5076.         lods    byte [esi]
  5077.         call    convert_mmx_register
  5078.         call    make_mmx_prefix
  5079.         mov     [postbyte_register],al
  5080.         lods    byte [esi]
  5081.         cmp     al,','
  5082.         jne     invalid_operand
  5083.         lods    byte [esi]
  5084.         call    get_size_operator
  5085.         cmp     al,10h
  5086.         je      palignr_mmreg_mmreg
  5087.         cmp     al,'['
  5088.         jne     invalid_operand
  5089.         call    get_address
  5090.         jmp     mmx_imm8
  5091.       palignr_mmreg_mmreg:
  5092.         lods    byte [esi]
  5093.         call    convert_mmx_register
  5094.         mov     bl,al
  5095.         jmp     mmx_nomem_imm8
  5096. amd3dnow_instruction:
  5097.         mov     [base_code],0Fh
  5098.         mov     [extended_code],0Fh
  5099.         mov     byte [value],al
  5100.         lods    byte [esi]
  5101.         call    get_size_operator
  5102.         cmp     al,10h
  5103.         jne     invalid_operand
  5104.         lods    byte [esi]
  5105.         call    convert_mmx_register
  5106.         cmp     ah,8
  5107.         jne     invalid_operand_size
  5108.         mov     [postbyte_register],al
  5109.         lods    byte [esi]
  5110.         cmp     al,','
  5111.         jne     invalid_operand
  5112.         lods    byte [esi]
  5113.         call    get_size_operator
  5114.         cmp     al,10h
  5115.         je      amd3dnow_mmreg_mmreg
  5116.         cmp     al,'['
  5117.         jne     invalid_operand
  5118.         call    get_address
  5119.         call    store_instruction_with_imm8
  5120.         jmp     instruction_assembled
  5121.       amd3dnow_mmreg_mmreg:
  5122.         lods    byte [esi]
  5123.         call    convert_mmx_register
  5124.         cmp     ah,8
  5125.         jne     invalid_operand_size
  5126.         mov     bl,al
  5127.         call    store_nomem_instruction
  5128.         mov     al,byte [value]
  5129.         stos    byte [edi]
  5130.         jmp     instruction_assembled
  5131.  
  5132. sse4_instruction_38_xmm0:
  5133.         mov     [immediate_size],-1
  5134.         jmp     sse4_instruction_38
  5135. sse4_instruction_66_38_xmm0:
  5136.         mov     [immediate_size],-1
  5137. sse4_instruction_66_38:
  5138.         mov     [opcode_prefix],66h
  5139. sse4_instruction_38:
  5140.         mov     [mmx_size],16
  5141.         mov     [supplemental_code],al
  5142.         mov     al,38h
  5143.         jmp     sse_instruction
  5144. sse4_ss_instruction_66_3a_imm8:
  5145.         mov     [immediate_size],1
  5146.         mov     cl,4
  5147.         jmp     sse4_instruction_66_3a_setup
  5148. sse4_sd_instruction_66_3a_imm8:
  5149.         mov     [immediate_size],1
  5150.         mov     cl,8
  5151.         jmp     sse4_instruction_66_3a_setup
  5152. sse4_instruction_66_3a_imm8:
  5153.         mov     [immediate_size],1
  5154.         mov     cl,16
  5155.       sse4_instruction_66_3a_setup:
  5156.         mov     [opcode_prefix],66h
  5157.       sse4_instruction_3a_setup:
  5158.         mov     [supplemental_code],al
  5159.         mov     al,3Ah
  5160.         mov     [mmx_size],cl
  5161.         jmp     sse_instruction
  5162. sse4_instruction_3a_imm8:
  5163.         mov     [immediate_size],1
  5164.         mov     cl,16
  5165.         jmp     sse4_instruction_3a_setup
  5166. pclmulqdq_instruction:
  5167.         mov     byte [value],al
  5168.         mov     al,44h
  5169.         mov     cl,16
  5170.         jmp     sse4_instruction_66_3a_setup
  5171. extractps_instruction:
  5172.         call    setup_66_0f_3a
  5173.         lods    byte [esi]
  5174.         call    get_size_operator
  5175.         cmp     al,10h
  5176.         je      extractps_reg
  5177.         cmp     al,'['
  5178.         jne     invalid_operand
  5179.         call    get_address
  5180.         cmp     [operand_size],4
  5181.         je      extractps_size_ok
  5182.         cmp     [operand_size],0
  5183.         jne     invalid_operand_size
  5184.       extractps_size_ok:
  5185.         push    edx ebx ecx
  5186.         mov     [operand_size],0
  5187.         lods    byte [esi]
  5188.         cmp     al,','
  5189.         jne     invalid_operand
  5190.         lods    byte [esi]
  5191.         call    get_size_operator
  5192.         cmp     al,10h
  5193.         jne     invalid_operand
  5194.         lods    byte [esi]
  5195.         call    convert_xmm_register
  5196.         mov     [postbyte_register],al
  5197.         pop     ecx ebx edx
  5198.         jmp     mmx_imm8
  5199.       extractps_reg:
  5200.         lods    byte [esi]
  5201.         call    convert_register
  5202.         push    eax
  5203.         mov     [operand_size],0
  5204.         lods    byte [esi]
  5205.         cmp     al,','
  5206.         jne     invalid_operand
  5207.         lods    byte [esi]
  5208.         call    get_size_operator
  5209.         cmp     al,10h
  5210.         jne     invalid_operand
  5211.         lods    byte [esi]
  5212.         call    convert_xmm_register
  5213.         mov     [postbyte_register],al
  5214.         pop     ebx
  5215.         mov     al,bh
  5216.         cmp     al,4
  5217.         je      mmx_nomem_imm8
  5218.         cmp     al,8
  5219.         jne     invalid_operand_size
  5220.         cmp     [code_type],64
  5221.         jne     illegal_instruction
  5222.         jmp     mmx_nomem_imm8
  5223.       setup_66_0f_3a:
  5224.         mov     [extended_code],3Ah
  5225.         mov     [supplemental_code],al
  5226.         mov     [base_code],0Fh
  5227.         mov     [opcode_prefix],66h
  5228.         ret
  5229. insertps_instruction:
  5230.         call    setup_66_0f_3a
  5231.         lods    byte [esi]
  5232.         call    get_size_operator
  5233.         cmp     al,10h
  5234.         jne     invalid_operand
  5235.         lods    byte [esi]
  5236.         call    convert_xmm_register
  5237.         mov     [postbyte_register],al
  5238.         mov     [operand_size],0
  5239.         lods    byte [esi]
  5240.         cmp     al,','
  5241.         jne     invalid_operand
  5242.         lods    byte [esi]
  5243.         call    get_size_operator
  5244.         cmp     al,10h
  5245.         je      insertps_xmmreg_reg
  5246.         cmp     al,'['
  5247.         jne     invalid_operand
  5248.         call    get_address
  5249.         cmp     [operand_size],4
  5250.         je      insertps_size_ok
  5251.         cmp     [operand_size],0
  5252.         jne     invalid_operand_size
  5253.       insertps_size_ok:
  5254.         jmp     mmx_imm8
  5255.       insertps_xmmreg_reg:
  5256.         lods    byte [esi]
  5257.         call    convert_mmx_register
  5258.         mov     bl,al
  5259.         jmp     mmx_nomem_imm8
  5260. pextrq_instruction:
  5261.         mov     [mmx_size],8
  5262.         jmp     pextr_instruction
  5263. pextrd_instruction:
  5264.         mov     [mmx_size],4
  5265.         jmp     pextr_instruction
  5266. pextrw_instruction:
  5267.         mov     [mmx_size],2
  5268.         jmp     pextr_instruction
  5269. pextrb_instruction:
  5270.         mov     [mmx_size],1
  5271.       pextr_instruction:
  5272.         call    setup_66_0f_3a
  5273.         lods    byte [esi]
  5274.         call    get_size_operator
  5275.         cmp     al,10h
  5276.         je      pextr_reg
  5277.         cmp     al,'['
  5278.         jne     invalid_operand
  5279.         call    get_address
  5280.         mov     al,[mmx_size]
  5281.         cmp     al,[operand_size]
  5282.         je      pextr_size_ok
  5283.         cmp     [operand_size],0
  5284.         jne     invalid_operand_size
  5285.       pextr_size_ok:
  5286.         cmp     al,8
  5287.         jne     pextr_prefix_ok
  5288.         call    operand_64bit
  5289.       pextr_prefix_ok:
  5290.         push    edx ebx ecx
  5291.         mov     [operand_size],0
  5292.         lods    byte [esi]
  5293.         cmp     al,','
  5294.         jne     invalid_operand
  5295.         lods    byte [esi]
  5296.         call    get_size_operator
  5297.         cmp     al,10h
  5298.         jne     invalid_operand
  5299.         lods    byte [esi]
  5300.         call    convert_xmm_register
  5301.         mov     [postbyte_register],al
  5302.         pop     ecx ebx edx
  5303.         jmp     mmx_imm8
  5304.       pextr_reg:
  5305.         lods    byte [esi]
  5306.         call    convert_register
  5307.         cmp     [mmx_size],4
  5308.         ja      pextrq_reg
  5309.         cmp     ah,4
  5310.         je      pextr_reg_size_ok
  5311.         cmp     [code_type],64
  5312.         jne     pextr_invalid_size
  5313.         cmp     ah,8
  5314.         je      pextr_reg_size_ok
  5315.       pextr_invalid_size:
  5316.         jmp     invalid_operand_size
  5317.       pextrq_reg:
  5318.         cmp     ah,8
  5319.         jne     pextr_invalid_size
  5320.         call    operand_64bit
  5321.       pextr_reg_size_ok:
  5322.         mov     [operand_size],0
  5323.         push    eax
  5324.         lods    byte [esi]
  5325.         cmp     al,','
  5326.         jne     invalid_operand
  5327.         lods    byte [esi]
  5328.         call    get_size_operator
  5329.         cmp     al,10h
  5330.         jne     invalid_operand
  5331.         lods    byte [esi]
  5332.         call    convert_mmx_register
  5333.         mov     ebx,eax
  5334.         pop     eax
  5335.         mov     [postbyte_register],al
  5336.         mov     al,ah
  5337.         cmp     [mmx_size],2
  5338.         jne     pextr_reg_store
  5339.         mov     [opcode_prefix],0
  5340.         mov     [extended_code],0C5h
  5341.         call    make_mmx_prefix
  5342.         jmp     mmx_nomem_imm8
  5343.       pextr_reg_store:
  5344.         cmp     bh,16
  5345.         jne     invalid_operand_size
  5346.         xchg    bl,[postbyte_register]
  5347.         jmp     mmx_nomem_imm8
  5348. pinsrb_instruction:
  5349.         mov     [mmx_size],1
  5350.         jmp     pinsr_instruction
  5351. pinsrd_instruction:
  5352.         mov     [mmx_size],4
  5353.         jmp     pinsr_instruction
  5354. pinsrq_instruction:
  5355.         mov     [mmx_size],8
  5356.         call    operand_64bit
  5357.       pinsr_instruction:
  5358.         call    setup_66_0f_3a
  5359.         lods    byte [esi]
  5360.         call    get_size_operator
  5361.         cmp     al,10h
  5362.         jne     invalid_operand
  5363.         lods    byte [esi]
  5364.         call    convert_xmm_register
  5365.         mov     [postbyte_register],al
  5366.       pinsr_xmmreg:
  5367.         mov     [operand_size],0
  5368.         lods    byte [esi]
  5369.         cmp     al,','
  5370.         jne     invalid_operand
  5371.         lods    byte [esi]
  5372.         call    get_size_operator
  5373.         cmp     al,10h
  5374.         je      pinsr_xmmreg_reg
  5375.         cmp     al,'['
  5376.         jne     invalid_operand
  5377.         call    get_address
  5378.         cmp     [operand_size],0
  5379.         je      mmx_imm8
  5380.         mov     al,[mmx_size]
  5381.         cmp     al,[operand_size]
  5382.         je      mmx_imm8
  5383.         jmp     invalid_operand_size
  5384.       pinsr_xmmreg_reg:
  5385.         lods    byte [esi]
  5386.         call    convert_register
  5387.         mov     bl,al
  5388.         cmp     [mmx_size],8
  5389.         je      pinsrq_xmmreg_reg
  5390.         cmp     ah,4
  5391.         je      mmx_nomem_imm8
  5392.         jmp     invalid_operand_size
  5393.       pinsrq_xmmreg_reg:
  5394.         cmp     ah,8
  5395.         je      mmx_nomem_imm8
  5396.         jmp     invalid_operand_size
  5397. pmovsxbw_instruction:
  5398.         mov     [mmx_size],8
  5399.         jmp     pmovsx_instruction
  5400. pmovsxbd_instruction:
  5401.         mov     [mmx_size],4
  5402.         jmp     pmovsx_instruction
  5403. pmovsxbq_instruction:
  5404.         mov     [mmx_size],2
  5405.         jmp     pmovsx_instruction
  5406. pmovsxwd_instruction:
  5407.         mov     [mmx_size],8
  5408.         jmp     pmovsx_instruction
  5409. pmovsxwq_instruction:
  5410.         mov     [mmx_size],4
  5411.         jmp     pmovsx_instruction
  5412. pmovsxdq_instruction:
  5413.         mov     [mmx_size],8
  5414.       pmovsx_instruction:
  5415.         call    setup_66_0f_38
  5416.         lods    byte [esi]
  5417.         call    get_size_operator
  5418.         cmp     al,10h
  5419.         jne     invalid_operand
  5420.         lods    byte [esi]
  5421.         call    convert_xmm_register
  5422.         mov     [postbyte_register],al
  5423.         lods    byte [esi]
  5424.         cmp     al,','
  5425.         jne     invalid_operand
  5426.         mov     [operand_size],0
  5427.         lods    byte [esi]
  5428.         call    get_size_operator
  5429.         cmp     al,10h
  5430.         je      pmovsx_xmmreg_reg
  5431.         cmp     al,'['
  5432.         jne     invalid_operand
  5433.         call    get_address
  5434.         cmp     [operand_size],0
  5435.         je      instruction_ready
  5436.         mov     al,[mmx_size]
  5437.         cmp     al,[operand_size]
  5438.         jne     invalid_operand_size
  5439.         jmp     instruction_ready
  5440.       pmovsx_xmmreg_reg:
  5441.         lods    byte [esi]
  5442.         call    convert_xmm_register
  5443.         mov     bl,al
  5444.         jmp     nomem_instruction_ready
  5445.       setup_66_0f_38:
  5446.         mov     [extended_code],38h
  5447.         mov     [supplemental_code],al
  5448.         mov     [base_code],0Fh
  5449.         mov     [opcode_prefix],66h
  5450.         ret
  5451.  
  5452. fxsave_instruction_64bit:
  5453.         call    operand_64bit
  5454. fxsave_instruction:
  5455.         mov     [extended_code],0AEh
  5456.         mov     [base_code],0Fh
  5457.         mov     [postbyte_register],al
  5458.         lods    byte [esi]
  5459.         call    get_size_operator
  5460.         cmp     al,'['
  5461.         jne     invalid_operand
  5462.         call    get_address
  5463.         mov     ah,[operand_size]
  5464.         or      ah,ah
  5465.         jz      fxsave_size_ok
  5466.         mov     al,[postbyte_register]
  5467.         cmp     al,111b
  5468.         je      clflush_size_check
  5469.         cmp     al,10b
  5470.         jb      invalid_operand_size
  5471.         cmp     al,11b
  5472.         ja      invalid_operand_size
  5473.         cmp     ah,4
  5474.         jne     invalid_operand_size
  5475.         jmp     fxsave_size_ok
  5476.       clflush_size_check:
  5477.         cmp     ah,1
  5478.         jne     invalid_operand_size
  5479.       fxsave_size_ok:
  5480.         jmp     instruction_ready
  5481. prefetch_instruction:
  5482.         mov     [extended_code],18h
  5483.       prefetch_mem_8bit:
  5484.         mov     [base_code],0Fh
  5485.         mov     [postbyte_register],al
  5486.         lods    byte [esi]
  5487.         call    get_size_operator
  5488.         cmp     al,'['
  5489.         jne     invalid_operand
  5490.         or      ah,ah
  5491.         jz      prefetch_size_ok
  5492.         cmp     ah,1
  5493.         jne     invalid_operand_size
  5494.       prefetch_size_ok:
  5495.         call    get_address
  5496.         jmp     instruction_ready
  5497. amd_prefetch_instruction:
  5498.         mov     [extended_code],0Dh
  5499.         jmp     prefetch_mem_8bit
  5500. clflushopt_instruction:
  5501.         mov     [extended_code],0AEh
  5502.         mov     [opcode_prefix],66h
  5503.         jmp     prefetch_mem_8bit
  5504. pcommit_instruction:
  5505.         mov     byte [edi],66h
  5506.         inc     edi
  5507. fence_instruction:
  5508.         mov     bl,al
  5509.         mov     ax,0AE0Fh
  5510.         stos    word [edi]
  5511.         mov     al,bl
  5512.         stos    byte [edi]
  5513.         jmp     instruction_assembled
  5514. pause_instruction:
  5515.         mov     ax,90F3h
  5516.         stos    word [edi]
  5517.         jmp     instruction_assembled
  5518. movntq_instruction:
  5519.         mov     [mmx_size],8
  5520.         jmp     movnt_instruction
  5521. movntpd_instruction:
  5522.         mov     [opcode_prefix],66h
  5523. movntps_instruction:
  5524.         mov     [mmx_size],16
  5525.       movnt_instruction:
  5526.         mov     [extended_code],al
  5527.         mov     [base_code],0Fh
  5528.         lods    byte [esi]
  5529.         call    get_size_operator
  5530.         cmp     al,'['
  5531.         jne     invalid_operand
  5532.         call    get_address
  5533.         lods    byte [esi]
  5534.         cmp     al,','
  5535.         jne     invalid_operand
  5536.         lods    byte [esi]
  5537.         call    get_size_operator
  5538.         cmp     al,10h
  5539.         jne     invalid_operand
  5540.         lods    byte [esi]
  5541.         call    convert_mmx_register
  5542.         cmp     ah,[mmx_size]
  5543.         jne     invalid_operand_size
  5544.         mov     [postbyte_register],al
  5545.         jmp     instruction_ready
  5546.  
  5547. movntsd_instruction:
  5548.         mov     [opcode_prefix],0F2h
  5549.         mov     [mmx_size],8
  5550.         jmp     movnts_instruction
  5551. movntss_instruction:
  5552.         mov     [opcode_prefix],0F3h
  5553.         mov     [mmx_size],4
  5554.       movnts_instruction:
  5555.         mov     [extended_code],al
  5556.         mov     [base_code],0Fh
  5557.         lods    byte [esi]
  5558.         call    get_size_operator
  5559.         cmp     al,'['
  5560.         jne     invalid_operand
  5561.         call    get_address
  5562.         mov     al,[operand_size]
  5563.         cmp     al,[mmx_size]
  5564.         je      movnts_size_ok
  5565.         test    al,al
  5566.         jnz     invalid_operand_size
  5567.       movnts_size_ok:
  5568.         lods    byte [esi]
  5569.         cmp     al,','
  5570.         jne     invalid_operand
  5571.         mov     [operand_size],0
  5572.         lods    byte [esi]
  5573.         call    get_size_operator
  5574.         cmp     al,10h
  5575.         jne     invalid_operand
  5576.         lods    byte [esi]
  5577.         call    convert_xmm_register
  5578.         mov     [postbyte_register],al
  5579.         jmp     instruction_ready
  5580.  
  5581. movnti_instruction:
  5582.         mov     [base_code],0Fh
  5583.         mov     [extended_code],al
  5584.         lods    byte [esi]
  5585.         call    get_size_operator
  5586.         cmp     al,'['
  5587.         jne     invalid_operand
  5588.         call    get_address
  5589.         lods    byte [esi]
  5590.         cmp     al,','
  5591.         jne     invalid_operand
  5592.         call    take_register
  5593.         cmp     ah,4
  5594.         je      movnti_store
  5595.         cmp     ah,8
  5596.         jne     invalid_operand_size
  5597.         call    operand_64bit
  5598.       movnti_store:
  5599.         mov     [postbyte_register],al
  5600.         jmp     instruction_ready
  5601. monitor_instruction:
  5602.         mov     [postbyte_register],al
  5603.         cmp     byte [esi],0
  5604.         je      monitor_instruction_store
  5605.         cmp     byte [esi],0Fh
  5606.         je      monitor_instruction_store
  5607.         call    take_register
  5608.         cmp     ax,0400h
  5609.         jne     invalid_operand
  5610.         lods    byte [esi]
  5611.         cmp     al,','
  5612.         jne     invalid_operand
  5613.         call    take_register
  5614.         cmp     ax,0401h
  5615.         jne     invalid_operand
  5616.         cmp     [postbyte_register],0C8h
  5617.         jne     monitor_instruction_store
  5618.         lods    byte [esi]
  5619.         cmp     al,','
  5620.         jne     invalid_operand
  5621.         call    take_register
  5622.         cmp     ax,0402h
  5623.         jne     invalid_operand
  5624.       monitor_instruction_store:
  5625.         mov     ax,010Fh
  5626.         stos    word [edi]
  5627.         mov     al,[postbyte_register]
  5628.         stos    byte [edi]
  5629.         jmp     instruction_assembled
  5630. movntdqa_instruction:
  5631.         call    setup_66_0f_38
  5632.         lods    byte [esi]
  5633.         call    get_size_operator
  5634.         cmp     al,10h
  5635.         jne     invalid_operand
  5636.         lods    byte [esi]
  5637.         call    convert_xmm_register
  5638.         mov     [postbyte_register],al
  5639.         lods    byte [esi]
  5640.         cmp     al,','
  5641.         jne     invalid_operand
  5642.         lods    byte [esi]
  5643.         call    get_size_operator
  5644.         cmp     al,'['
  5645.         jne     invalid_operand
  5646.         call    get_address
  5647.         jmp     instruction_ready
  5648.  
  5649. extrq_instruction:
  5650.         mov     [opcode_prefix],66h
  5651.         mov     [base_code],0Fh
  5652.         mov     [extended_code],78h
  5653.         lods    byte [esi]
  5654.         call    get_size_operator
  5655.         cmp     al,10h
  5656.         jne     invalid_operand
  5657.         lods    byte [esi]
  5658.         call    convert_xmm_register
  5659.         mov     [postbyte_register],al
  5660.         mov     [operand_size],0
  5661.         lods    byte [esi]
  5662.         cmp     al,','
  5663.         jne     invalid_operand
  5664.         lods    byte [esi]
  5665.         call    get_size_operator
  5666.         cmp     al,10h
  5667.         je      extrq_xmmreg_xmmreg
  5668.         test    ah,not 1
  5669.         jnz     invalid_operand_size
  5670.         cmp     al,'('
  5671.         jne     invalid_operand
  5672.         xor     bl,bl
  5673.         xchg    bl,[postbyte_register]
  5674.         call    store_nomem_instruction
  5675.         call    get_byte_value
  5676.         stosb
  5677.         call    append_imm8
  5678.         jmp     instruction_assembled
  5679.       extrq_xmmreg_xmmreg:
  5680.         inc     [extended_code]
  5681.         lods    byte [esi]
  5682.         call    convert_xmm_register
  5683.         mov     bl,al
  5684.         jmp     nomem_instruction_ready
  5685. insertq_instruction:
  5686.         mov     [opcode_prefix],0F2h
  5687.         mov     [base_code],0Fh
  5688.         mov     [extended_code],78h
  5689.         lods    byte [esi]
  5690.         call    get_size_operator
  5691.         cmp     al,10h
  5692.         jne     invalid_operand
  5693.         lods    byte [esi]
  5694.         call    convert_xmm_register
  5695.         mov     [postbyte_register],al
  5696.         mov     [operand_size],0
  5697.         lods    byte [esi]
  5698.         cmp     al,','
  5699.         jne     invalid_operand
  5700.         lods    byte [esi]
  5701.         call    get_size_operator
  5702.         cmp     al,10h
  5703.         jne     invalid_operand
  5704.         lods    byte [esi]
  5705.         call    convert_xmm_register
  5706.         mov     bl,al
  5707.         cmp     byte [esi],','
  5708.         je      insertq_with_imm
  5709.         inc     [extended_code]
  5710.         jmp     nomem_instruction_ready
  5711.       insertq_with_imm:
  5712.         call    store_nomem_instruction
  5713.         call    append_imm8
  5714.         call    append_imm8
  5715.         jmp     instruction_assembled
  5716.  
  5717. crc32_instruction:
  5718.         mov     [opcode_prefix],0F2h
  5719.         mov     [base_code],0Fh
  5720.         mov     [extended_code],38h
  5721.         mov     [supplemental_code],0F0h
  5722.         call    take_register
  5723.         mov     [postbyte_register],al
  5724.         cmp     ah,4
  5725.         je      crc32_reg_size_ok
  5726.         cmp     ah,8
  5727.         jne     invalid_operand
  5728.         cmp     [code_type],64
  5729.         jne     illegal_instruction
  5730.       crc32_reg_size_ok:
  5731.         lods    byte [esi]
  5732.         cmp     al,','
  5733.         jne     invalid_operand
  5734.         mov     [operand_size],0
  5735.         lods    byte [esi]
  5736.         call    get_size_operator
  5737.         cmp     al,10h
  5738.         je      crc32_reg_reg
  5739.         cmp     al,'['
  5740.         jne     invalid_operand
  5741.         call    get_address
  5742.         mov     al,[operand_size]
  5743.         test    al,al
  5744.         jz      crc32_unknown_size
  5745.         cmp     al,1
  5746.         je      crc32_reg_mem_store
  5747.         inc     [supplemental_code]
  5748.         call    operand_autodetect
  5749.       crc32_reg_mem_store:
  5750.         jmp     instruction_ready
  5751.       crc32_unknown_size:
  5752.         call    recoverable_unknown_size
  5753.         jmp     crc32_reg_mem_store
  5754.       crc32_reg_reg:
  5755.         lods    byte [esi]
  5756.         call    convert_register
  5757.         mov     bl,al
  5758.         mov     al,ah
  5759.         cmp     al,1
  5760.         je      crc32_reg_reg_store
  5761.         inc     [supplemental_code]
  5762.         call    operand_autodetect
  5763.       crc32_reg_reg_store:
  5764.         jmp     nomem_instruction_ready
  5765. popcnt_instruction:
  5766.         mov     [opcode_prefix],0F3h
  5767.         jmp     bs_instruction
  5768. movbe_instruction:
  5769.         mov     [supplemental_code],al
  5770.         mov     [extended_code],38h
  5771.         mov     [base_code],0Fh
  5772.         lods    byte [esi]
  5773.         call    get_size_operator
  5774.         cmp     al,'['
  5775.         je      movbe_mem
  5776.         cmp     al,10h
  5777.         jne     invalid_operand
  5778.         lods    byte [esi]
  5779.         call    convert_register
  5780.         mov     [postbyte_register],al
  5781.         lods    byte [esi]
  5782.         cmp     al,','
  5783.         jne     invalid_operand
  5784.         lods    byte [esi]
  5785.         call    get_size_operator
  5786.         cmp     al,'['
  5787.         jne     invalid_argument
  5788.         call    get_address
  5789.         mov     al,[operand_size]
  5790.         call    operand_autodetect
  5791.         jmp     instruction_ready
  5792.       movbe_mem:
  5793.         inc     [supplemental_code]
  5794.         call    get_address
  5795.         push    edx ebx ecx
  5796.         lods    byte [esi]
  5797.         cmp     al,','
  5798.         jne     invalid_operand
  5799.         call    take_register
  5800.         mov     [postbyte_register],al
  5801.         pop     ecx ebx edx
  5802.         mov     al,[operand_size]
  5803.         call    operand_autodetect
  5804.         jmp     instruction_ready
  5805. adx_instruction:
  5806.         mov     [base_code],0Fh
  5807.         mov     [extended_code],38h
  5808.         mov     [supplemental_code],0F6h
  5809.         mov     [operand_prefix],al
  5810.         call    get_reg_mem
  5811.         jc      adx_reg_reg
  5812.         mov     al,[operand_size]
  5813.         cmp     al,4
  5814.         je      instruction_ready
  5815.         cmp     al,8
  5816.         jne     invalid_operand_size
  5817.         call    operand_64bit
  5818.         jmp     instruction_ready
  5819.       adx_reg_reg:
  5820.         cmp     ah,4
  5821.         je      nomem_instruction_ready
  5822.         cmp     ah,8
  5823.         jne     invalid_operand_size
  5824.         call    operand_64bit
  5825.         jmp     nomem_instruction_ready
  5826.  
  5827. vmclear_instruction:
  5828.         mov     [opcode_prefix],66h
  5829.         jmp     vmx_instruction
  5830. vmxon_instruction:
  5831.         mov     [opcode_prefix],0F3h
  5832. vmx_instruction:
  5833.         mov     [postbyte_register],al
  5834.         mov     [extended_code],0C7h
  5835.         lods    byte [esi]
  5836.         call    get_size_operator
  5837.         cmp     al,'['
  5838.         jne     invalid_operand
  5839.         call    get_address
  5840.         mov     al,[operand_size]
  5841.         or      al,al
  5842.         jz      vmx_size_ok
  5843.         cmp     al,8
  5844.         jne     invalid_operand_size
  5845.       vmx_size_ok:
  5846.         mov     [base_code],0Fh
  5847.         jmp     instruction_ready
  5848. vmread_instruction:
  5849.         mov     [extended_code],78h
  5850.         lods    byte [esi]
  5851.         call    get_size_operator
  5852.         cmp     al,10h
  5853.         je      vmread_nomem
  5854.         cmp     al,'['
  5855.         jne     invalid_operand
  5856.         call    get_address
  5857.         lods    byte [esi]
  5858.         cmp     al,','
  5859.         jne     invalid_operand
  5860.         call    take_register
  5861.         mov     [postbyte_register],al
  5862.         call    vmread_check_size
  5863.         jmp     vmx_size_ok
  5864.       vmread_nomem:
  5865.         lods    byte [esi]
  5866.         call    convert_register
  5867.         push    eax
  5868.         call    vmread_check_size
  5869.         lods    byte [esi]
  5870.         cmp     al,','
  5871.         jne     invalid_operand
  5872.         call    take_register
  5873.         mov     [postbyte_register],al
  5874.         call    vmread_check_size
  5875.         pop     ebx
  5876.         mov     [base_code],0Fh
  5877.         jmp     nomem_instruction_ready
  5878.       vmread_check_size:
  5879.         cmp     [code_type],64
  5880.         je      vmread_long
  5881.         cmp     [operand_size],4
  5882.         jne     invalid_operand_size
  5883.         ret
  5884.       vmread_long:
  5885.         cmp     [operand_size],8
  5886.         jne     invalid_operand_size
  5887.         ret
  5888. vmwrite_instruction:
  5889.         mov     [extended_code],79h
  5890.         call    take_register
  5891.         mov     [postbyte_register],al
  5892.         lods    byte [esi]
  5893.         cmp     al,','
  5894.         jne     invalid_operand
  5895.         lods    byte [esi]
  5896.         call    get_size_operator
  5897.         cmp     al,10h
  5898.         je      vmwrite_nomem
  5899.         cmp     al,'['
  5900.         jne     invalid_operand
  5901.         call    get_address
  5902.         call    vmread_check_size
  5903.         jmp     vmx_size_ok
  5904.       vmwrite_nomem:
  5905.         lods    byte [esi]
  5906.         call    convert_register
  5907.         mov     bl,al
  5908.         mov     [base_code],0Fh
  5909.         jmp     nomem_instruction_ready
  5910. vmx_inv_instruction:
  5911.         call    setup_66_0f_38
  5912.         call    take_register
  5913.         mov     [postbyte_register],al
  5914.         call    vmread_check_size
  5915.         mov     [operand_size],0
  5916.         lods    byte [esi]
  5917.         cmp     al,','
  5918.         jne     invalid_operand
  5919.         lods    byte [esi]
  5920.         call    get_size_operator
  5921.         cmp     al,'['
  5922.         jne     invalid_operand
  5923.         call    get_address
  5924.         mov     al,[operand_size]
  5925.         or      al,al
  5926.         jz      vmx_size_ok
  5927.         cmp     al,16
  5928.         jne     invalid_operand_size
  5929.         jmp     vmx_size_ok
  5930. simple_svm_instruction:
  5931.         push    eax
  5932.         mov     [base_code],0Fh
  5933.         mov     [extended_code],1
  5934.         call    take_register
  5935.         or      al,al
  5936.         jnz     invalid_operand
  5937.       simple_svm_detect_size:
  5938.         cmp     ah,2
  5939.         je      simple_svm_16bit
  5940.         cmp     ah,4
  5941.         je      simple_svm_32bit
  5942.         cmp     [code_type],64
  5943.         jne     invalid_operand_size
  5944.         jmp     simple_svm_store
  5945.       simple_svm_16bit:
  5946.         cmp     [code_type],16
  5947.         je      simple_svm_store
  5948.         cmp     [code_type],64
  5949.         je      invalid_operand_size
  5950.         jmp     prefixed_svm_store
  5951.       simple_svm_32bit:
  5952.         cmp     [code_type],32
  5953.         je      simple_svm_store
  5954.       prefixed_svm_store:
  5955.         mov     al,67h
  5956.         stos    byte [edi]
  5957.       simple_svm_store:
  5958.         call    store_classic_instruction_code
  5959.         pop     eax
  5960.         stos    byte [edi]
  5961.         jmp     instruction_assembled
  5962. skinit_instruction:
  5963.         call    take_register
  5964.         cmp     ax,0400h
  5965.         jne     invalid_operand
  5966.         mov     al,0DEh
  5967.         jmp     simple_instruction_0f_01
  5968. invlpga_instruction:
  5969.         push    eax
  5970.         mov     [base_code],0Fh
  5971.         mov     [extended_code],1
  5972.         call    take_register
  5973.         or      al,al
  5974.         jnz     invalid_operand
  5975.         mov     bl,ah
  5976.         mov     [operand_size],0
  5977.         lods    byte [esi]
  5978.         cmp     al,','
  5979.         jne     invalid_operand
  5980.         call    take_register
  5981.         cmp     ax,0401h
  5982.         jne     invalid_operand
  5983.         mov     ah,bl
  5984.         jmp     simple_svm_detect_size
  5985.  
  5986. rdrand_instruction:
  5987.         mov     [base_code],0Fh
  5988.         mov     [extended_code],0C7h
  5989.         mov     [postbyte_register],al
  5990.         call    take_register
  5991.         mov     bl,al
  5992.         mov     al,ah
  5993.         call    operand_autodetect
  5994.         jmp     nomem_instruction_ready
  5995. rdfsbase_instruction:
  5996.         cmp     [code_type],64
  5997.         jne     illegal_instruction
  5998.         mov     [opcode_prefix],0F3h
  5999.         mov     [base_code],0Fh
  6000.         mov     [extended_code],0AEh
  6001.         mov     [postbyte_register],al
  6002.         call    take_register
  6003.         mov     bl,al
  6004.         mov     al,ah
  6005.         cmp     ah,2
  6006.         je      invalid_operand_size
  6007.         call    operand_autodetect
  6008.         jmp     nomem_instruction_ready
  6009.  
  6010. xabort_instruction:
  6011.         lods    byte [esi]
  6012.         call    get_size_operator
  6013.         cmp     ah,1
  6014.         ja      invalid_operand_size
  6015.         cmp     al,'('
  6016.         jne     invalid_operand
  6017.         call    get_byte_value
  6018.         mov     dl,al
  6019.         mov     ax,0F8C6h
  6020.         stos    word [edi]
  6021.         mov     al,dl
  6022.         stos    byte [edi]
  6023.         jmp     instruction_assembled
  6024. xbegin_instruction:
  6025.         lods    byte [esi]
  6026.         cmp     al,'('
  6027.         jne     invalid_operand
  6028.         mov     al,[code_type]
  6029.         cmp     al,64
  6030.         je      xbegin_64bit
  6031.         cmp     al,32
  6032.         je      xbegin_32bit
  6033.       xbegin_16bit:
  6034.         call    get_address_word_value
  6035.         add     edi,4
  6036.         mov     ebp,[addressing_space]
  6037.         call    calculate_relative_offset
  6038.         sub     edi,4
  6039.         shl     eax,16
  6040.         mov     ax,0F8C7h
  6041.         stos    dword [edi]
  6042.         jmp     instruction_assembled
  6043.       xbegin_32bit:
  6044.         call    get_address_dword_value
  6045.         jmp     xbegin_address_ok
  6046.       xbegin_64bit:
  6047.         call    get_address_qword_value
  6048.       xbegin_address_ok:
  6049.         add     edi,5
  6050.         mov     ebp,[addressing_space]
  6051.         call    calculate_relative_offset
  6052.         sub     edi,5
  6053.         mov     edx,eax
  6054.         cwde
  6055.         cmp     eax,edx
  6056.         jne     xbegin_rel32
  6057.         mov     al,66h
  6058.         stos    byte [edi]
  6059.         mov     eax,edx
  6060.         shl     eax,16
  6061.         mov     ax,0F8C7h
  6062.         stos    dword [edi]
  6063.         jmp     instruction_assembled
  6064.       xbegin_rel32:
  6065.         sub     edx,1
  6066.         jno     xbegin_rel32_ok
  6067.         cmp     [code_type],64
  6068.         je      jump_out_of_range
  6069.       xbegin_rel32_ok:
  6070.         mov     ax,0F8C7h
  6071.         stos    word [edi]
  6072.         mov     eax,edx
  6073.         stos    dword [edi]
  6074.         jmp     instruction_assembled
  6075.  
  6076. bndcl_instruction:
  6077.         mov     ah,0F3h
  6078.         jmp     bndc_instruction
  6079. bndcu_instruction:
  6080.         mov     ah,0F2h
  6081.       bndc_instruction:
  6082.         mov     [opcode_prefix],ah
  6083.         mov     [base_code],0Fh
  6084.         mov     [extended_code],al
  6085.         call    take_bnd_register
  6086.         mov     [postbyte_register],al
  6087.         call    get_bnd_size
  6088.         mov     [operand_size],al
  6089.         lods    byte [esi]
  6090.         cmp     al,','
  6091.         jne     invalid_operand
  6092.         lods    byte [esi]
  6093.         call    get_size_operator
  6094.         cmp     al,'['
  6095.         je      bndc_mem
  6096.         cmp     al,10h
  6097.         jne     invalid_operand
  6098.         lods    byte [esi]
  6099.         call    convert_register
  6100.         mov     bl,al
  6101.         jmp     nomem_instruction_ready
  6102.       bndc_mem:
  6103.         call    get_address_of_required_size
  6104.         jmp     instruction_ready
  6105. bndmov_instruction:
  6106.         mov     [opcode_prefix],66h
  6107.         mov     [base_code],0Fh
  6108.         mov     [extended_code],al
  6109.         call    get_bnd_size
  6110.         shl     al,1
  6111.         mov     [operand_size],al
  6112.         lods    byte [esi]
  6113.         cmp     al,14h
  6114.         je      bndmov_reg
  6115.         call    get_size_operator
  6116.         cmp     al,'['
  6117.         jne     invalid_operand
  6118.         inc     [extended_code]
  6119.         call    get_address_of_required_size
  6120.         lods    byte [esi]
  6121.         cmp     al,','
  6122.         jne     invalid_operand
  6123.         call    take_bnd_register
  6124.         mov     [postbyte_register],al
  6125.         jmp     instruction_ready
  6126.        bndmov_reg:
  6127.         lods    byte [esi]
  6128.         call    convert_bnd_register
  6129.         mov     [postbyte_register],al
  6130.         lods    byte [esi]
  6131.         cmp     al,','
  6132.         jne     invalid_operand
  6133.         lods    byte [esi]
  6134.         cmp     al,14h
  6135.         je      bndmov_reg_reg
  6136.         call    get_size_operator
  6137.         cmp     al,'['
  6138.         jne     invalid_operand
  6139.         call    get_address_of_required_size
  6140.         jmp     instruction_ready
  6141.       bndmov_reg_reg:
  6142.         lods    byte [esi]
  6143.         call    convert_bnd_register
  6144.         mov     bl,al
  6145.         jmp     nomem_instruction_ready
  6146.     take_bnd_register:
  6147.         lods    byte [esi]
  6148.         cmp     al,14h
  6149.         jne     invalid_operand
  6150.         lods    byte [esi]
  6151.     convert_bnd_register:
  6152.         mov     ah,al
  6153.         shr     ah,4
  6154.         cmp     ah,6
  6155.         jne     invalid_operand
  6156.         and     al,1111b
  6157.         ret
  6158. bndmk_instruction:
  6159.         mov     [opcode_prefix],0F3h
  6160.         mov     [base_code],0Fh
  6161.         mov     [extended_code],al
  6162.         call    take_bnd_register
  6163.         mov     [postbyte_register],al
  6164.         lods    byte [esi]
  6165.         cmp     al,','
  6166.         jne     invalid_operand
  6167.         lods    byte [esi]
  6168.         call    get_size_operator
  6169.         cmp     al,'['
  6170.         jne     invalid_operand
  6171.         call    get_bnd_size
  6172.         call    get_address_prefixes
  6173.         call    get_address_component
  6174.         cmp     byte [esi-1],']'
  6175.         je      bndmk_ready
  6176.         lods    byte [esi]
  6177.         cmp     al,','
  6178.         jne     invalid_operand
  6179.         lods    byte [esi]
  6180.         cmp     al,'('
  6181.         jne     invalid_operand
  6182.         or      dl,bl
  6183.         or      dl,[address_sign]
  6184.         or      edx,[address_high]
  6185.         jnz     invalid_address
  6186.         mov     [address_register],bh
  6187.         call    get_address_component
  6188.         lods    byte [esi]
  6189.         cmp     al,']'
  6190.         jne     invalid_operand
  6191.         or      bh,bh
  6192.         jz      bndmk_selected_base
  6193.         cmp     bl,bh
  6194.         je      bndmk_to_index
  6195.         or      bl,bl
  6196.         jnz     invalid_address
  6197.         mov     bl,bh
  6198.       bndmk_to_index:
  6199.         inc     cl
  6200.       bndmk_selected_base:
  6201.         mov     bh,[address_register]
  6202.       bndmk_ready:
  6203.         or      bx,bx
  6204.         jz      instruction_ready
  6205.         cmp     [address_size_declared],0
  6206.         jne     instruction_ready
  6207.         and     ch,not 0Fh
  6208.         jmp     instruction_ready
  6209.     get_bnd_size:
  6210.         mov     al,4
  6211.         cmp     [code_type],64
  6212.         jne     bnd_size_ok
  6213.         add     al,4
  6214.       bnd_size_ok:
  6215.         mov     [address_size],al
  6216.         ret
  6217.     get_address_component:
  6218.         mov     [free_address_range],0
  6219.         call    calculate_address
  6220.         mov     [address_high],edx
  6221.         mov     edx,eax
  6222.         or      bx,bx
  6223.         jz      address_component_ok
  6224.         mov     al,bl
  6225.         or      al,bh
  6226.         shr     al,4
  6227.         cmp     al,[address_size]
  6228.         jne     invalid_address
  6229.       address_component_ok:
  6230.         ret
  6231. bndldx_instruction:
  6232.         mov     [base_code],0Fh
  6233.         mov     [extended_code],al
  6234.         call    take_bnd_register
  6235.         mov     [postbyte_register],al
  6236.         lods    byte [esi]
  6237.         cmp     al,','
  6238.         jne     invalid_operand
  6239.         call    take_bnd_mib
  6240.         jmp     bndmk_ready
  6241. bndstx_instruction:
  6242.         mov     [base_code],0Fh
  6243.         mov     [extended_code],al
  6244.         call    take_bnd_mib
  6245.         lods    byte [esi]
  6246.         cmp     al,','
  6247.         jne     invalid_operand
  6248.         call    take_bnd_register
  6249.         mov     [postbyte_register],al
  6250.         jmp     bndmk_ready
  6251.     take_bnd_mib:
  6252.         lods    byte [esi]
  6253.         cmp     al,'['
  6254.         jne     invalid_operand
  6255.         call    get_bnd_size
  6256.         call    get_address_prefixes
  6257.         call    get_address_component
  6258.         cmp     byte [esi-1],']'
  6259.         je      bnd_mib_ok
  6260.         lods    byte [esi]
  6261.         cmp     al,','
  6262.         jne     invalid_operand
  6263.         lods    byte [esi]
  6264.         cmp     al,'('
  6265.         jne     invalid_operand
  6266.         mov     al,[address_sign]
  6267.         push    eax ebx ecx edx [address_symbol]
  6268.         call    get_address_component
  6269.         lods    byte [esi]
  6270.         cmp     al,']'
  6271.         jne     invalid_operand
  6272.         or      dl,bl
  6273.         or      dl,[address_sign]
  6274.         or      edx,[address_high]
  6275.         jnz     invalid_address
  6276.         mov     [address_register],bh
  6277.         pop     [address_symbol] edx ecx ebx eax
  6278.         mov     [address_sign],al
  6279.         or      bl,bl
  6280.         jz      mib_place_index
  6281.         or      bh,bh
  6282.         jnz     invalid_address
  6283.         cmp     cl,1
  6284.         jne     invalid_address
  6285.         mov     bh,bl
  6286.       mib_place_index:
  6287.         mov     bl,[address_register]
  6288.         xor     cl,cl
  6289.         or      al,al
  6290.         jz      bnd_mib_ok
  6291.         inc     cl
  6292.       bnd_mib_ok:
  6293.         ret
  6294.  
  6295. take_register:
  6296.         lods    byte [esi]
  6297.         call    get_size_operator
  6298.         cmp     al,10h
  6299.         jne     invalid_operand
  6300.         lods    byte [esi]
  6301. convert_register:
  6302.         mov     ah,al
  6303.         shr     ah,4
  6304.         and     al,0Fh
  6305.         cmp     ah,8
  6306.         je      match_register_size
  6307.         cmp     ah,4
  6308.         ja      invalid_operand
  6309.         cmp     ah,1
  6310.         ja      match_register_size
  6311.         cmp     al,4
  6312.         jb      match_register_size
  6313.         or      ah,ah
  6314.         jz      high_byte_register
  6315.         or      [rex_prefix],40h
  6316.       match_register_size:
  6317.         cmp     ah,[operand_size]
  6318.         je      register_size_ok
  6319.         cmp     [operand_size],0
  6320.         jne     operand_sizes_do_not_match
  6321.         mov     [operand_size],ah
  6322.       register_size_ok:
  6323.         ret
  6324.       high_byte_register:
  6325.         mov     ah,1
  6326.         or      [rex_prefix],10h
  6327.         jmp     match_register_size
  6328. convert_fpu_register:
  6329.         mov     ah,al
  6330.         shr     ah,4
  6331.         and     al,111b
  6332.         cmp     ah,10
  6333.         jne     invalid_operand
  6334.         jmp     match_register_size
  6335. convert_mmx_register:
  6336.         mov     ah,al
  6337.         shr     ah,4
  6338.         cmp     ah,0Ch
  6339.         je      xmm_register
  6340.         ja      invalid_operand
  6341.         and     al,111b
  6342.         cmp     ah,0Bh
  6343.         jne     invalid_operand
  6344.         mov     ah,8
  6345.         jmp     match_register_size
  6346.       xmm_register:
  6347.         and     al,0Fh
  6348.         mov     ah,16
  6349.         cmp     al,8
  6350.         jb      match_register_size
  6351.         cmp     [code_type],64
  6352.         jne     invalid_operand
  6353.         jmp     match_register_size
  6354. convert_xmm_register:
  6355.         mov     ah,al
  6356.         shr     ah,4
  6357.         cmp     ah,0Ch
  6358.         je      xmm_register
  6359.         jmp     invalid_operand
  6360. get_size_operator:
  6361.         xor     ah,ah
  6362.         cmp     al,11h
  6363.         jne     no_size_operator
  6364.         mov     [size_declared],1
  6365.         lods    word [esi]
  6366.         xchg    al,ah
  6367.         or      [operand_flags],1
  6368.         cmp     ah,[operand_size]
  6369.         je      size_operator_ok
  6370.         cmp     [operand_size],0
  6371.         jne     operand_sizes_do_not_match
  6372.         mov     [operand_size],ah
  6373.       size_operator_ok:
  6374.         ret
  6375.       no_size_operator:
  6376.         mov     [size_declared],0
  6377.         cmp     al,'['
  6378.         jne     size_operator_ok
  6379.         and     [operand_flags],not 1
  6380.         ret
  6381. get_jump_operator:
  6382.         mov     [jump_type],0
  6383.         cmp     al,12h
  6384.         jne     jump_operator_ok
  6385.         lods    word [esi]
  6386.         mov     [jump_type],al
  6387.         mov     al,ah
  6388.       jump_operator_ok:
  6389.         ret
  6390. get_address:
  6391.         and     [address_size],0
  6392.     get_address_of_required_size:
  6393.         call    get_address_prefixes
  6394.         and     [free_address_range],0
  6395.         call    calculate_address
  6396.         cmp     byte [esi-1],']'
  6397.         jne     invalid_address
  6398.         mov     [address_high],edx
  6399.         mov     edx,eax
  6400.         cmp     [address_size_declared],0
  6401.         jne     address_ok
  6402.         or      bx,bx
  6403.         jnz     clear_address_size
  6404.         cmp     [code_type],64
  6405.         jne     address_ok
  6406.       calculate_relative_address:
  6407.         mov     edx,[address_symbol]
  6408.         mov     [symbol_identifier],edx
  6409.         mov     edx,[address_high]
  6410.         mov     ebp,[addressing_space]
  6411.         call    calculate_relative_offset
  6412.         mov     [address_high],edx
  6413.         cdq
  6414.         cmp     edx,[address_high]
  6415.         je      address_high_ok
  6416.         call    recoverable_overflow
  6417.       address_high_ok:
  6418.         mov     edx,eax
  6419.         ror     ecx,16
  6420.         mov     cl,[value_type]
  6421.         rol     ecx,16
  6422.         mov     bx,9900h
  6423.       clear_address_size:
  6424.         and     ch,not 0Fh
  6425.       address_ok:
  6426.         ret
  6427. get_address_prefixes:
  6428.         and     [segment_register],0
  6429.         and     [address_size_declared],0
  6430.         mov     al,[code_type]
  6431.         shr     al,3
  6432.         mov     [value_size],al
  6433.         mov     al,[esi]
  6434.         and     al,11110000b
  6435.         cmp     al,60h
  6436.         jne     get_address_size_prefix
  6437.         lods    byte [esi]
  6438.         sub     al,60h
  6439.         mov     [segment_register],al
  6440.         mov     al,[esi]
  6441.         and     al,11110000b
  6442.       get_address_size_prefix:
  6443.         cmp     al,70h
  6444.         jne     address_size_prefix_ok
  6445.         lods    byte [esi]
  6446.         sub     al,70h
  6447.         cmp     al,2
  6448.         jb      invalid_address_size
  6449.         cmp     al,8
  6450.         ja      invalid_address_size
  6451.         mov     [value_size],al
  6452.         or      [address_size_declared],1
  6453.         or      [address_size],al
  6454.         cmp     al,[address_size]
  6455.         jne     invalid_address_size
  6456.       address_size_prefix_ok:
  6457.         ret
  6458. operand_16bit:
  6459.         cmp     [code_type],16
  6460.         je      size_prefix_ok
  6461.         mov     [operand_prefix],66h
  6462.         ret
  6463. operand_32bit:
  6464.         cmp     [code_type],16
  6465.         jne     size_prefix_ok
  6466.         mov     [operand_prefix],66h
  6467.       size_prefix_ok:
  6468.         ret
  6469. operand_64bit:
  6470.         cmp     [code_type],64
  6471.         jne     illegal_instruction
  6472.         or      [rex_prefix],48h
  6473.         ret
  6474. operand_autodetect:
  6475.         cmp     al,2
  6476.         je      operand_16bit
  6477.         cmp     al,4
  6478.         je      operand_32bit
  6479.         cmp     al,8
  6480.         je      operand_64bit
  6481.         jmp     invalid_operand_size
  6482. store_segment_prefix_if_necessary:
  6483.         mov     al,[segment_register]
  6484.         or      al,al
  6485.         jz      segment_prefix_ok
  6486.         cmp     al,4
  6487.         ja      segment_prefix_386
  6488.         cmp     [code_type],64
  6489.         je      segment_prefix_ok
  6490.         cmp     al,3
  6491.         je      ss_prefix
  6492.         jb      segment_prefix_86
  6493.         cmp     bl,25h
  6494.         je      segment_prefix_86
  6495.         cmp     bh,25h
  6496.         je      segment_prefix_86
  6497.         cmp     bh,45h
  6498.         je      segment_prefix_86
  6499.         cmp     bh,44h
  6500.         je      segment_prefix_86
  6501.         ret
  6502.       ss_prefix:
  6503.         cmp     bl,25h
  6504.         je      segment_prefix_ok
  6505.         cmp     bh,25h
  6506.         je      segment_prefix_ok
  6507.         cmp     bh,45h
  6508.         je      segment_prefix_ok
  6509.         cmp     bh,44h
  6510.         je      segment_prefix_ok
  6511.         jmp     segment_prefix_86
  6512. store_segment_prefix:
  6513.         mov     al,[segment_register]
  6514.         or      al,al
  6515.         jz      segment_prefix_ok
  6516.         cmp     al,5
  6517.         jae     segment_prefix_386
  6518.       segment_prefix_86:
  6519.         dec     al
  6520.         shl     al,3
  6521.         add     al,26h
  6522.         stos    byte [edi]
  6523.         jmp     segment_prefix_ok
  6524.       segment_prefix_386:
  6525.         add     al,64h-5
  6526.         stos    byte [edi]
  6527.       segment_prefix_ok:
  6528.         ret
  6529. store_instruction_code:
  6530.         cmp     [vex_required],0
  6531.         jne     store_vex_instruction_code
  6532. store_classic_instruction_code:
  6533.         mov     al,[operand_prefix]
  6534.         or      al,al
  6535.         jz      operand_prefix_ok
  6536.         stos    byte [edi]
  6537.       operand_prefix_ok:
  6538.         mov     al,[opcode_prefix]
  6539.         or      al,al
  6540.         jz      opcode_prefix_ok
  6541.         stos    byte [edi]
  6542.       opcode_prefix_ok:
  6543.         mov     al,[rex_prefix]
  6544.         test    al,40h
  6545.         jz      rex_prefix_ok
  6546.         cmp     [code_type],64
  6547.         jne     invalid_operand
  6548.         test    al,0B0h
  6549.         jnz     disallowed_combination_of_registers
  6550.         stos    byte [edi]
  6551.       rex_prefix_ok:
  6552.         mov     al,[base_code]
  6553.         stos    byte [edi]
  6554.         cmp     al,0Fh
  6555.         jne     instruction_code_ok
  6556.       store_extended_code:
  6557.         mov     al,[extended_code]
  6558.         stos    byte [edi]
  6559.         cmp     al,38h
  6560.         je      store_supplemental_code
  6561.         cmp     al,3Ah
  6562.         je      store_supplemental_code
  6563.       instruction_code_ok:
  6564.         ret
  6565.       store_supplemental_code:
  6566.         mov     al,[supplemental_code]
  6567.         stos    byte [edi]
  6568.         ret
  6569. store_nomem_instruction:
  6570.         test    [postbyte_register],10000b
  6571.         jz      nomem_reg_high_code_ok
  6572.         or      [vex_required],10h
  6573.         and     [postbyte_register],1111b
  6574.       nomem_reg_high_code_ok:
  6575.         test    [postbyte_register],1000b
  6576.         jz      nomem_reg_code_ok
  6577.         or      [rex_prefix],44h
  6578.         and     [postbyte_register],111b
  6579.       nomem_reg_code_ok:
  6580.         test    bl,10000b
  6581.         jz      nomem_rm_high_code_ok
  6582.         or      [rex_prefix],42h
  6583.         or      [vex_required],8
  6584.         and     bl,1111b
  6585.       nomem_rm_high_code_ok:
  6586.         test    bl,1000b
  6587.         jz      nomem_rm_code_ok
  6588.         or      [rex_prefix],41h
  6589.         and     bl,111b
  6590.       nomem_rm_code_ok:
  6591.         and     [displacement_compression],0
  6592.         call    store_instruction_code
  6593.         mov     al,[postbyte_register]
  6594.         shl     al,3
  6595.         or      al,bl
  6596.         or      al,11000000b
  6597.         stos    byte [edi]
  6598.         ret
  6599. store_instruction:
  6600.         mov     [current_offset],edi
  6601.         and     [displacement_compression],0
  6602.         test    [postbyte_register],10000b
  6603.         jz      reg_high_code_ok
  6604.         or      [vex_required],10h
  6605.         and     [postbyte_register],1111b
  6606.       reg_high_code_ok:
  6607.         test    [postbyte_register],1000b
  6608.         jz      reg_code_ok
  6609.         or      [rex_prefix],44h
  6610.         and     [postbyte_register],111b
  6611.       reg_code_ok:
  6612.         cmp     [code_type],64
  6613.         jne     address_value_ok
  6614.         xor     eax,eax
  6615.         bt      edx,31
  6616.         sbb     eax,[address_high]
  6617.         jz      address_value_ok
  6618.         cmp     [address_high],0
  6619.         jne     address_value_out_of_range
  6620.         test    ch,44h
  6621.         jnz     address_value_ok
  6622.         test    bx,8080h
  6623.         jz      address_value_ok
  6624.       address_value_out_of_range:
  6625.         call    recoverable_overflow
  6626.       address_value_ok:
  6627.         call    store_segment_prefix_if_necessary
  6628.         test    [vex_required],4
  6629.         jnz     address_vsib
  6630.         or      bx,bx
  6631.         jz      address_immediate
  6632.         cmp     bx,9800h
  6633.         je      address_rip_based
  6634.         cmp     bx,9400h
  6635.         je      address_eip_based
  6636.         cmp     bx,9900h
  6637.         je      address_relative
  6638.         mov     al,bl
  6639.         or      al,bh
  6640.         and     al,11110000b
  6641.         cmp     al,80h
  6642.         je      postbyte_64bit
  6643.         cmp     al,40h
  6644.         je      postbyte_32bit
  6645.         cmp     al,20h
  6646.         jne     invalid_address
  6647.         cmp     [code_type],64
  6648.         je      invalid_address_size
  6649.         call    address_16bit_prefix
  6650.         test    ch,22h
  6651.         setz    [displacement_compression]
  6652.         call    store_instruction_code
  6653.         cmp     bl,bh
  6654.         jbe     determine_16bit_address
  6655.         xchg    bl,bh
  6656.       determine_16bit_address:
  6657.         cmp     bx,2600h
  6658.         je      address_si
  6659.         cmp     bx,2700h
  6660.         je      address_di
  6661.         cmp     bx,2300h
  6662.         je      address_bx
  6663.         cmp     bx,2500h
  6664.         je      address_bp
  6665.         cmp     bx,2625h
  6666.         je      address_bp_si
  6667.         cmp     bx,2725h
  6668.         je      address_bp_di
  6669.         cmp     bx,2723h
  6670.         je      address_bx_di
  6671.         cmp     bx,2623h
  6672.         jne     invalid_address
  6673.       address_bx_si:
  6674.         xor     al,al
  6675.         jmp     postbyte_16bit
  6676.       address_bx_di:
  6677.         mov     al,1
  6678.         jmp     postbyte_16bit
  6679.       address_bp_si:
  6680.         mov     al,10b
  6681.         jmp     postbyte_16bit
  6682.       address_bp_di:
  6683.         mov     al,11b
  6684.         jmp     postbyte_16bit
  6685.       address_si:
  6686.         mov     al,100b
  6687.         jmp     postbyte_16bit
  6688.       address_di:
  6689.         mov     al,101b
  6690.         jmp     postbyte_16bit
  6691.       address_bx:
  6692.         mov     al,111b
  6693.         jmp     postbyte_16bit
  6694.       address_bp:
  6695.         mov     al,110b
  6696.       postbyte_16bit:
  6697.         test    ch,22h
  6698.         jnz     address_16bit_value
  6699.         or      ch,ch
  6700.         jnz     address_sizes_do_not_agree
  6701.         cmp     edx,10000h
  6702.         jge     value_out_of_range
  6703.         cmp     edx,-8000h
  6704.         jl      value_out_of_range
  6705.         or      dx,dx
  6706.         jz      address
  6707.         cmp     [displacement_compression],2
  6708.         ja      address_8bit_value
  6709.         je      address_16bit_value
  6710.         cmp     dx,80h
  6711.         jb      address_8bit_value
  6712.         cmp     dx,-80h
  6713.         jae     address_8bit_value
  6714.       address_16bit_value:
  6715.         or      al,10000000b
  6716.         mov     cl,[postbyte_register]
  6717.         shl     cl,3
  6718.         or      al,cl
  6719.         stos    byte [edi]
  6720.         mov     eax,edx
  6721.         stos    word [edi]
  6722.         ret
  6723.       address_8bit_value:
  6724.         or      al,01000000b
  6725.         mov     cl,[postbyte_register]
  6726.         shl     cl,3
  6727.         or      al,cl
  6728.         stos    byte [edi]
  6729.         mov     al,dl
  6730.         stos    byte [edi]
  6731.         ret
  6732.       address:
  6733.         cmp     al,110b
  6734.         je      address_8bit_value
  6735.         mov     cl,[postbyte_register]
  6736.         shl     cl,3
  6737.         or      al,cl
  6738.         stos    byte [edi]
  6739.         ret
  6740.       address_vsib:
  6741.         mov     al,bl
  6742.         shr     al,4
  6743.         test    al,1
  6744.         jz      vsib_high_code_ok
  6745.         or      [vex_register],10000b
  6746.         or      [vex_required],8
  6747.         xor     al,1
  6748.       vsib_high_code_ok:
  6749.         cmp     al,6
  6750.         je      vsib_index_ok
  6751.         cmp     al,0Ch
  6752.         jb      invalid_address
  6753.       vsib_index_ok:
  6754.         mov     al,bh
  6755.         shr     al,4
  6756.         cmp     al,4
  6757.         je      postbyte_32bit
  6758.         cmp     [code_type],64
  6759.         je      address_prefix_ok
  6760.         test    al,al
  6761.         jnz     invalid_address
  6762.       postbyte_32bit:
  6763.         call    address_32bit_prefix
  6764.         jmp     address_prefix_ok
  6765.       postbyte_64bit:
  6766.         cmp     [code_type],64
  6767.         jne     invalid_address_size
  6768.       address_prefix_ok:
  6769.         cmp     bl,44h
  6770.         je      invalid_address
  6771.         cmp     bl,84h
  6772.         je      invalid_address
  6773.         test    bh,1000b
  6774.         jz      base_code_ok
  6775.         or      [rex_prefix],41h
  6776.       base_code_ok:
  6777.         test    bl,1000b
  6778.         jz      index_code_ok
  6779.         or      [rex_prefix],42h
  6780.       index_code_ok:
  6781.         test    ch,44h or 88h
  6782.         setz    [displacement_compression]
  6783.         call    store_instruction_code
  6784.         or      cl,cl
  6785.         jz      only_base_register
  6786.       base_and_index:
  6787.         mov     al,100b
  6788.         xor     ah,ah
  6789.         cmp     cl,1
  6790.         je      scale_ok
  6791.         cmp     cl,2
  6792.         je      scale_1
  6793.         cmp     cl,4
  6794.         je      scale_2
  6795.         or      ah,11000000b
  6796.         jmp     scale_ok
  6797.       scale_2:
  6798.         or      ah,10000000b
  6799.         jmp     scale_ok
  6800.       scale_1:
  6801.         or      ah,01000000b
  6802.       scale_ok:
  6803.         or      bh,bh
  6804.         jz      only_index_register
  6805.         and     bl,111b
  6806.         shl     bl,3
  6807.         or      ah,bl
  6808.         and     bh,111b
  6809.         or      ah,bh
  6810.       sib_ready:
  6811.         test    ch,44h or 88h
  6812.         jnz     sib_address_32bit_value
  6813.         or      ch,ch
  6814.         jnz     address_sizes_do_not_agree
  6815.         cmp     bh,5
  6816.         je      address_value
  6817.         or      edx,edx
  6818.         jz      sib_address
  6819.       address_value:
  6820.         cmp     [displacement_compression],2
  6821.         ja      sib_address_8bit_value
  6822.         je      sib_address_32bit_value
  6823.         cmp     edx,80h
  6824.         jb      sib_address_8bit_value
  6825.         cmp     edx,-80h
  6826.         jnb     sib_address_8bit_value
  6827.       sib_address_32bit_value:
  6828.         or      al,10000000b
  6829.         mov     cl,[postbyte_register]
  6830.         shl     cl,3
  6831.         or      al,cl
  6832.         stos    word [edi]
  6833.         jmp     store_address_32bit_value
  6834.       sib_address_8bit_value:
  6835.         or      al,01000000b
  6836.         mov     cl,[postbyte_register]
  6837.         shl     cl,3
  6838.         or      al,cl
  6839.         stos    word [edi]
  6840.         mov     al,dl
  6841.         stos    byte [edi]
  6842.         ret
  6843.       sib_address:
  6844.         mov     cl,[postbyte_register]
  6845.         shl     cl,3
  6846.         or      al,cl
  6847.         stos    word [edi]
  6848.         ret
  6849.       only_index_register:
  6850.         or      ah,101b
  6851.         and     bl,111b
  6852.         shl     bl,3
  6853.         or      ah,bl
  6854.         mov     cl,[postbyte_register]
  6855.         shl     cl,3
  6856.         or      al,cl
  6857.         stos    word [edi]
  6858.         test    ch,44h or 88h
  6859.         jnz     store_address_32bit_value
  6860.         or      ch,ch
  6861.         jnz     invalid_address_size
  6862.         cmp     [displacement_compression],2
  6863.         jbe     store_address_32bit_value
  6864.         mov     edx,[uncompressed_displacement]
  6865.         jmp     store_address_32bit_value
  6866.       zero_index_register:
  6867.         mov     bl,4
  6868.         mov     cl,1
  6869.         jmp     base_and_index
  6870.       only_base_register:
  6871.         mov     al,bh
  6872.         and     al,111b
  6873.         cmp     al,4
  6874.         je      zero_index_register
  6875.         test    ch,44h or 88h
  6876.         jnz     simple_address_32bit_value
  6877.         or      ch,ch
  6878.         jnz     address_sizes_do_not_agree
  6879.         or      edx,edx
  6880.         jz      simple_address
  6881.         cmp     [displacement_compression],2
  6882.         ja      simple_address_8bit_value
  6883.         je      simple_address_32bit_value
  6884.         cmp     edx,80h
  6885.         jb      simple_address_8bit_value
  6886.         cmp     edx,-80h
  6887.         jnb     simple_address_8bit_value
  6888.       simple_address_32bit_value:
  6889.         or      al,10000000b
  6890.         mov     cl,[postbyte_register]
  6891.         shl     cl,3
  6892.         or      al,cl
  6893.         stos    byte [edi]
  6894.         jmp     store_address_32bit_value
  6895.       simple_address_8bit_value:
  6896.         or      al,01000000b
  6897.         mov     cl,[postbyte_register]
  6898.         shl     cl,3
  6899.         or      al,cl
  6900.         stos    byte [edi]
  6901.         mov     al,dl
  6902.         stos    byte [edi]
  6903.         ret
  6904.       simple_address:
  6905.         cmp     al,5
  6906.         je      simple_address_8bit_value
  6907.         mov     cl,[postbyte_register]
  6908.         shl     cl,3
  6909.         or      al,cl
  6910.         stos    byte [edi]
  6911.         ret
  6912.       address_immediate:
  6913.         cmp     [code_type],64
  6914.         je      address_immediate_sib
  6915.         test    ch,44h or 88h
  6916.         jnz     address_immediate_32bit
  6917.         test    ch,22h
  6918.         jnz     address_immediate_16bit
  6919.         or      ch,ch
  6920.         jnz     invalid_address_size
  6921.         cmp     [code_type],16
  6922.         je      addressing_16bit
  6923.       address_immediate_32bit:
  6924.         call    address_32bit_prefix
  6925.         call    store_instruction_code
  6926.       store_immediate_address:
  6927.         mov     al,101b
  6928.         mov     cl,[postbyte_register]
  6929.         shl     cl,3
  6930.         or      al,cl
  6931.         stos    byte [edi]
  6932.       store_address_32bit_value:
  6933.         test    ch,0F0h
  6934.         jz      address_32bit_relocation_ok
  6935.         mov     eax,ecx
  6936.         shr     eax,16
  6937.         cmp     al,4
  6938.         jne     address_32bit_relocation
  6939.         mov     al,2
  6940.       address_32bit_relocation:
  6941.         xchg    [value_type],al
  6942.         mov     ebx,[address_symbol]
  6943.         xchg    ebx,[symbol_identifier]
  6944.         call    mark_relocation
  6945.         mov     [value_type],al
  6946.         mov     [symbol_identifier],ebx
  6947.       address_32bit_relocation_ok:
  6948.         mov     eax,edx
  6949.         stos    dword [edi]
  6950.         ret
  6951.       store_address_64bit_value:
  6952.         test    ch,0F0h
  6953.         jz      address_64bit_relocation_ok
  6954.         mov     eax,ecx
  6955.         shr     eax,16
  6956.         xchg    [value_type],al
  6957.         mov     ebx,[address_symbol]
  6958.         xchg    ebx,[symbol_identifier]
  6959.         call    mark_relocation
  6960.         mov     [value_type],al
  6961.         mov     [symbol_identifier],ebx
  6962.       address_64bit_relocation_ok:
  6963.         mov     eax,edx
  6964.         stos    dword [edi]
  6965.         mov     eax,[address_high]
  6966.         stos    dword [edi]
  6967.         ret
  6968.       address_immediate_sib:
  6969.         test    ch,44h
  6970.         jnz     address_immediate_sib_32bit
  6971.         test    ch,not 88h
  6972.         jnz     invalid_address_size
  6973.       address_immediate_sib_store:
  6974.         call    store_instruction_code
  6975.         mov     al,100b
  6976.         mov     ah,100101b
  6977.         mov     cl,[postbyte_register]
  6978.         shl     cl,3
  6979.         or      al,cl
  6980.         stos    word [edi]
  6981.         jmp     store_address_32bit_value
  6982.       address_immediate_sib_32bit:
  6983.         test    ecx,0FF0000h
  6984.         jnz     address_immediate_sib_nosignextend
  6985.         test    edx,80000000h
  6986.         jz      address_immediate_sib_store
  6987.       address_immediate_sib_nosignextend:
  6988.         call    address_32bit_prefix
  6989.         jmp     address_immediate_sib_store
  6990.       address_eip_based:
  6991.         mov     al,67h
  6992.         stos    byte [edi]
  6993.       address_rip_based:
  6994.         cmp     [code_type],64
  6995.         jne     invalid_address
  6996.         call    store_instruction_code
  6997.         jmp     store_immediate_address
  6998.       address_relative:
  6999.         call    store_instruction_code
  7000.         movzx   eax,[immediate_size]
  7001.         add     eax,edi
  7002.         sub     eax,[current_offset]
  7003.         add     eax,5
  7004.         sub     edx,eax
  7005.         jno     @f
  7006.         call    recoverable_overflow
  7007.       @@:
  7008.         mov     al,101b
  7009.         mov     cl,[postbyte_register]
  7010.         shl     cl,3
  7011.         or      al,cl
  7012.         stos    byte [edi]
  7013.         shr     ecx,16
  7014.         xchg    [value_type],cl
  7015.         mov     ebx,[address_symbol]
  7016.         xchg    ebx,[symbol_identifier]
  7017.         mov     eax,edx
  7018.         call    mark_relocation
  7019.         mov     [value_type],cl
  7020.         mov     [symbol_identifier],ebx
  7021.         stos    dword [edi]
  7022.         ret
  7023.       addressing_16bit:
  7024.         cmp     edx,10000h
  7025.         jge     address_immediate_32bit
  7026.         cmp     edx,-8000h
  7027.         jl      address_immediate_32bit
  7028.         movzx   edx,dx
  7029.       address_immediate_16bit:
  7030.         call    address_16bit_prefix
  7031.         call    store_instruction_code
  7032.         mov     al,110b
  7033.         mov     cl,[postbyte_register]
  7034.         shl     cl,3
  7035.         or      al,cl
  7036.         stos    byte [edi]
  7037.         mov     eax,edx
  7038.         stos    word [edi]
  7039.         cmp     edx,10000h
  7040.         jge     value_out_of_range
  7041.         cmp     edx,-8000h
  7042.         jl      value_out_of_range
  7043.         ret
  7044.       address_16bit_prefix:
  7045.         cmp     [code_type],16
  7046.         je      instruction_prefix_ok
  7047.         mov     al,67h
  7048.         stos    byte [edi]
  7049.         ret
  7050.       address_32bit_prefix:
  7051.         cmp     [code_type],32
  7052.         je      instruction_prefix_ok
  7053.         mov     al,67h
  7054.         stos    byte [edi]
  7055.       instruction_prefix_ok:
  7056.         ret
  7057. store_instruction_with_imm8:
  7058.         mov     [immediate_size],1
  7059.         call    store_instruction
  7060.         mov     al,byte [value]
  7061.         stos    byte [edi]
  7062.         ret
  7063. store_instruction_with_imm16:
  7064.         mov     [immediate_size],2
  7065.         call    store_instruction
  7066.         mov     ax,word [value]
  7067.         call    mark_relocation
  7068.         stos    word [edi]
  7069.         ret
  7070. store_instruction_with_imm32:
  7071.         mov     [immediate_size],4
  7072.         call    store_instruction
  7073.         mov     eax,dword [value]
  7074.         call    mark_relocation
  7075.         stos    dword [edi]
  7076.         ret
  7077.