8-Bit Register on Pentium 4
From: Bryan Parkoff (spamtrap_at_crayne.org)
Date: 03/19/05
- Previous message: Slor : "Re: port 32-bit to AMD64"
- Next in thread: Chewy509: "Re: 8-Bit Register on Pentium 4"
- Reply: Chewy509: "Re: 8-Bit Register on Pentium 4"
- Reply: Andreas Kaiser : "Re: 8-Bit Register on Pentium 4"
- Maybe reply: Sprunk, Stephen: "Re: 8-Bit Register on Pentium 4"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: Slor : "Re: port 32-bit to AMD64"
- Next in thread: Chewy509: "Re: 8-Bit Register on Pentium 4"
- Reply: Chewy509: "Re: 8-Bit Register on Pentium 4"
- Reply: Andreas Kaiser : "Re: 8-Bit Register on Pentium 4"
- Maybe reply: Sprunk, Stephen: "Re: 8-Bit Register on Pentium 4"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|