Possible to change flags without math op?
- From: Jim Leonard <mobygamer@xxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 11 Jul 2012 12:21:05 -0700 (PDT)
I'm writing a piece of code for real-mode 16-bit x86 that needs to
process a sequence of bytes and do something with their values based
on whether or not they are 00, FF, or neither. Jumping based on the
zero flag and/or sign flag was my first idea, but MOV and LODS don't
alter flags. Loading to CX and using JCXZ works for zero values, but
not signed (FF) values. So my next thought was to just ensure that a
target register is empty, so that a math op will alter the flags for
....but I'm optimizing for speed (this is in a loop) and it irks me to
have to zero the register. Is the above the fastest way to do what I
want, or am I missing something obvious?
(For those who enjoy optimizing the core problem itself instead of
assembly, the goal is to load bytes in sequence and add their values
to a target register. The rules:
1. If a loaded value is 0, STOP reading.
2. If a loaded value is FF, add to target register and keep reading.
3. If a loaded value is not FF, add to target register and STOP
There is probably a way to combine rules #1 and #3 such that they use
the same branch or something, but so far I'm not seeing it.)
- Prev by Date: Re: Starting Assembly
- Next by Date: Re: Possible to change flags without math op?
- Previous by thread: Re: Starting Assembly
- Next by thread: Re: Possible to change flags without math op?