Re: Clever ways to hide a compare
- From: "Keyser Soze" <spamtrap@xxxxxxxxxx>
- Date: Tue, 27 Sep 2005 18:09:48 +0000 (UTC)
"jonathon" <spamtrap@xxxxxxxxxx> wrote in message
news:1127782507.845470.77920@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> Jim Leonard wrote:
>> I was wading through an old game the other day and found a section of
>> code that grabbed two values and XOR'd them, then kept track of the
>> zero flag through a series of convaluted steps designed to obscure what
>> he was doing. (When you XOR two identical bytes, the result is zero.)
>
> Now that's the stuff I'm interested in. What kind of stuff was he
> using to obscure, and did he just save the status register flags and
> then reload them later?
>
Examples to compare AX with DX on an x86:
1)
CMP AX,DX ; zero set, carry clear on equal
2)
XOR AX,DX ; zero set on equal, carry not changed
3)
STC
NOT AX
ADC AX,DX ; zero and carry set on equal
4)
XCH AH,DH
XOR AL,DL
SUB DH,AH
OR AL,DH ; zero set, carry clear on equal
5)
STC
DEC DX
NEG AX
ADC AX,DX ; zero and carry set on equal
It all depends on just how baroque you want to get. :)
.
- Follow-Ups:
- Re: Clever ways to hide a compare
- From: wolfgang kern
- Re: Clever ways to hide a compare
- References:
- Clever ways to hide a compare
- From: jonathon
- Re: Clever ways to hide a compare
- From: Jim Leonard
- Re: Clever ways to hide a compare
- From: jonathon
- Clever ways to hide a compare
- Prev by Date: Re: Clever ways to hide a compare
- Next by Date: Re: Clever ways to hide a compare
- Previous by thread: Re: Clever ways to hide a compare
- Next by thread: Re: Clever ways to hide a compare
- Index(es):
Relevant Pages
|