
    gi              	           S SK Jr  S SKJrJrJr  S SKJr  S SKJ	r	J
r
  S SKJr  S\4S jrS\4S	 jrS
\S\
S\S\S   4S jrg)    )Literal)ASMInstructionEffectiveAddressOperand)Register)RegisterSizeInstructionEncodingFormat)	Tracebackeffective_addressc                     [        U R                  [        5      (       a   U R                  R                  R                  $ g N)
isinstancebaser   valuesize)r   s    4/mnt/public/Repos/urclelf/./x86/encoding/getregrm.py#get_effective_address_register_sizer      s3    #(((33 %%++000 4    operandc                     [        U R                  [        5      (       a   U R                  R                  R                  $ [        U R                  [        5      (       a  [        U R                  5      $ g r   )r   r   r   r   r   r   )r   s    r   get_operand_register_sizer      sM    '--**}}""'''	GMM#3	4	427==AAr   instructionencodingdirection_bitbits)    @   c                    / n[        UR                  5       GH-  u  pV[        U[        5      (       d  M  U R                  U   n[        UR
                  [        5      (       a  [        U5      UR                  :w  aZ  US:X  a  [        U5      S:X  a  UR                  S:X  d5  [        R                  " SU SUR                   S[        U5       S35      s  $ UR                  UR
                  5        M  [        UR
                  [        5      (       a  UR                  UR
                  5        GM  [        R                  " S5      s  $    U(       d  g [        U5      S:X  a  S US	   pS US	   4$ [        U5      S
:X  a  U(       a
  US	   US   pO US   US	   pO[        R                  " S5      $ [        U[        5      (       a  [        R                  " S5      $ [        U	[        5      (       aN  U	R                  (       a:  U	R                  R
                  R                  S:w  a  [        R                  " S5      $ X4$ UR
                  R                  U	R
                  R                  :w  a  [        R                  " SU SU	 S35      $ X4$ )Nr   r   z(Invalid register size for operand index z: expected z bits, found .z@Expected register or memory operand, found an immediate instead.   r      z,There are too many register/memory operands.z&r/m field can only contain a register.z*Only 32 bit memory is currently supported.z	Register z and z are not the same size.)	enumeratepermitted_operandsr   r   operandsr   r   r   r   r
   newappendr   lenr   )
r   r   r   r   r$   indexoperand_formatr   regrms
             r   get_regrm_operandsr,      sb   68%.x/J/J%K!E.,77%..u5gmmX6609^=P=PPZ^bdZd  jC  DK  jL  PR  jR  We  Wj  Wj  np  Wp(}}/WX]W^^ijxj}j}i~  L  Mf  gn  Mo  Lp  pq  .r   s  sOOGMM2/?@@OOGMM2$==+kmm &L x=AXa[(1+&&]a#A;R#A;R ==#OQQc+,,==!IJJb*++ww77==%%+$==+UWW
 w yy~~. }}yU2$>U%VWWwr   N)typingr   x86.asmr   r   r   x86.registerr   x86.encoding.encodingsr   r	   errorr
   r   r   boolr,    r   r   <module>r4      sb     = = ! J 1;K 1w 0N 0>W 0hl 0t{  }C  uD 0r   