By: EduardoS (no.delete@this.spam.com), February 27, 2013 11:07 pm
Room: Moderated Discussions
Michael S (already5chosen.delete@this.yahoo.com) on February 27, 2013 4:24 pm wrote:
> I say 12 rather than 14, because I don't think that negative/non-negative conditions are really fundamental.
The sign flag helps some times and is essentially free.
> Now, do we really need 4 flag bits in order to implement 12 (or even all 14) fundamental
> conditions? No, we don't. Up to 64 conditions, including all 14 defined in x86/ARM?SPARC,
> can be easyly derived from just 7 distinct states = 3 bits.
> For example, like those:
> 0 - unsigned_less && signed_less. Implied non-overflow && negative
> 1 - unsigned_less && signed_greater && non-overflow. Implied non-negative
> 2 - unsigned_less && signed_greater && overflow. Implied negative
> 3 - unsigned_greater && signed_less && non-overflow. Implied negative
> 4 - unsigned_greater && signed_less && overflow. Implied non-negative
> 5 - unsigned_greater && signed_greater. Implied non-overflow && non-negative
> 6 - equal. Implied non-overflow && non-negative
Encoding in three bits have the same "advantage" of killing the sign flag at the expense of more complex (and time consuming) flag calculation, but the sign flag is free, so no real gain, also... 3 bitsT allow up to 8 resulting states, but there are 9, no?
mov eax, 1
add eax, 1
Non-Zero
Non-Negative
Non-Carry
Non-Overflow
mov eax, 0
add eax, 0
Zero
Non-Negative
Non-Carry
Non-Overflow
mov eax, -1
add eax, 2
Non-Zero
Non-Negative
Carry
Non-Overflow
mov eax, -1
add eax, 1
Zero
Non-Negative
Carry
Non-Overflow
mov eax, 80000000h
add eax, 80000000h
Zero
Non-Negative
Carry
Overflow
mov eax, 80000001h
add eax, 80000000h
Non-Zero
Non-Negative
Carry
Overflow
mov eax, -2
add eax, 1
Non-Zero
Negative
Non-Carry
Non-Overflow
mov eax, 70000000h
add eax, 70000000h
Non-Zero
Negative
Non-Carry
Overflow
mov eax, -1
add eax, -1
Non-Zero
Negative
Carry
Non-Overflow
> I say 12 rather than 14, because I don't think that negative/non-negative conditions are really fundamental.
The sign flag helps some times and is essentially free.
> Now, do we really need 4 flag bits in order to implement 12 (or even all 14) fundamental
> conditions? No, we don't. Up to 64 conditions, including all 14 defined in x86/ARM?SPARC,
> can be easyly derived from just 7 distinct states = 3 bits.
> For example, like those:
> 0 - unsigned_less && signed_less. Implied non-overflow && negative
> 1 - unsigned_less && signed_greater && non-overflow. Implied non-negative
> 2 - unsigned_less && signed_greater && overflow. Implied negative
> 3 - unsigned_greater && signed_less && non-overflow. Implied negative
> 4 - unsigned_greater && signed_less && overflow. Implied non-negative
> 5 - unsigned_greater && signed_greater. Implied non-overflow && non-negative
> 6 - equal. Implied non-overflow && non-negative
Encoding in three bits have the same "advantage" of killing the sign flag at the expense of more complex (and time consuming) flag calculation, but the sign flag is free, so no real gain, also... 3 bitsT allow up to 8 resulting states, but there are 9, no?
mov eax, 1
add eax, 1
Non-Zero
Non-Negative
Non-Carry
Non-Overflow
mov eax, 0
add eax, 0
Zero
Non-Negative
Non-Carry
Non-Overflow
mov eax, -1
add eax, 2
Non-Zero
Non-Negative
Carry
Non-Overflow
mov eax, -1
add eax, 1
Zero
Non-Negative
Carry
Non-Overflow
mov eax, 80000000h
add eax, 80000000h
Zero
Non-Negative
Carry
Overflow
mov eax, 80000001h
add eax, 80000000h
Non-Zero
Non-Negative
Carry
Overflow
mov eax, -2
add eax, 1
Non-Zero
Negative
Non-Carry
Non-Overflow
mov eax, 70000000h
add eax, 70000000h
Non-Zero
Negative
Non-Carry
Overflow
mov eax, -1
add eax, -1
Non-Zero
Negative
Carry
Non-Overflow