8-Bit Register on Pentium 4

From: Bryan Parkoff (spamtrap_at_crayne.org)
Date: 03/19/05

  • Next message: Chewy509: "Re: 8-Bit Register on Pentium 4"
    Date: Sat, 19 Mar 2005 06:05:23 +0000 (UTC)
    
    

        I wrote a short routine which it uses only 8-Bit register because I
    desire to avoid "AND reg32, 0FFH". I believe that optimization is not an
    issue, but it is important to make smaller or few instructions. It is what
    I need to use all of them so I satisfy what my routine runs correctly.
        The fact is that I break one 16-Bits into two 8-Bits. The low 8-Bits
    can be one of 256 hexidecimal. The high 8-Bits can only increments by
    adding $01 if the sign flag is reset, otherwise it can only decrements by
    subtracting $01 if the sign flag is set unless it attempts to wrap low byte
    back to $00 or $FF.
        I feel that I don't need 32-Bit register before "AND reg32, 0FFH"
    because I want to assure machine code bytes to be very smaller using 8-Bits
    register. It should be little faster using 8-Bit register rather than
    32-Bit register because 8-Bit is only fewer than 32-Bit. It won't take too
    much space in memory and hard drive.
        I did review Pentium 4 Optimization manual which it says 8-Bit register
    and 32-Bit register have the same uops than 16-Bit register, but AH, BH, CH,
    and DH registers should always be avoided.
        Please look at my code below. It gives you an idea what it looks
    better. I think that second example is better than first example. Please
    make any correction if I am wrong. Please advise.

    First example: 11 instructions
      MOV AL, BYTE PTR [Low_Byte]
      MOV AH, BYTE PTR [High_Byte]
      MOV CL, BYTE PTR [_Offset]
      ADD AL, CL
      ADC AH, 0H
      MOV CH, 07FH
      CMP CH, CL
      SBB CH, CH
      ADD AH, CH
      MOV BYTE PTR [Low_Byte], AL
      MOV BYTE PTR [High_Byte], AH

    Second example: 9 instructions
      MOV AL, BYTE PTR [_Offset]
      ADD BYTE PTR [Low_Byte], AL
      MOV CL, BYTE PTR [High_Byte]
      ADC CL, 0H
      MOV DL, 07FH
      CMP DL, AL
      SBB AL, AL
      ADD CL, AL
      MOV BYTE PTR [High_Byte], CL

    Bryan Parkoff


  • Next message: Chewy509: "Re: 8-Bit Register on Pentium 4"

    Relevant Pages

    • Re: Cost of calling a standard library function
      ... >> Thank you for a very thorough and nice explanation Beth! ... and then edi four instructions in a row. ... your code keeps reading the memory through esi register 4 times in a row. ... mov eax D@SourceRect ...
      (alt.lang.asm)
    • Re: ml64, PROC and parameters
      ... It does not use them, but, the stack space could be used for temporary ... You should push on the stack only the non-parameter register. ... The first 4 parameters are in registers rcx, rdx, r8, r9. ... mov,rcx ...
      (microsoft.public.development.device.drivers)
    • Re: ml64, PROC and parameters
      ... _test_nested creates 98h bytes of stack space for the sake of the exercise. ... You should push on the stack only the non-parameter register. ... The first 4 parameters are in registers rcx, rdx, r8, r9. ... mov,rcx ...
      (microsoft.public.development.device.drivers)
    • Re: Calculating checksums...
      ... MOV BYTE PTR, ... No information that a register or which register is decremented and ... dbeq.l r2,label (decrement & branch equal) ...
      (alt.lang.asm)
    • Re: 8-Bit Register on Pentium 4
      ... MOV AH, BYTE PTR ... Intel's instructions such as CBW instruction, MOVZX instruction, and/or ... can only modify in the memory rather than register. ...
      (comp.lang.asm.x86)