Re: Clever ways to hide a compare



"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. :)

.



Relevant Pages

  • Re: perfect powers !!
    ... measure zero" set. ... measure zero set is countable. ... I and J such that E intersect I and E intersect J ... "Understanding Godel isn't about following his formal proof. ...
    (sci.math)
  • Re: Pattern to the primes
    ... So the zero set for this function is ... Again, I understand that it can't be the pattern, because my training ... essentially "random" distribution of prime numbers. ...
    (sci.math)
  • Re: perfect powers !!
    ... Dave L. Renfro wrote: ... measure zero" set. ... measure zero set is countable. ...
    (sci.math)
  • Re: Measure Theory, Paul R. Halmos, Sec. 31, Question 9. Help...
    ... \nuis the number of vertical lines with non-countable intersection ... Prove that the zero set of f has countable intersection ... Let E be the zero set of f. ... everywhere on H except for a countable subset. ...
    (sci.math)
  • Re: anti-aliasing
    ... The adc will take a bunch of samples, ... So maybe I can fuzz up the sample rate so that it can't alias against ... Since you know it's a sine wave you could find out where it crosses zero, or some other DC level if the data indicates it's all above or below zero. ...
    (sci.electronics.design)