XCHG instruction: load register AX with a 1

Hi

In the XCHG instruction, why would be load register AX with a 1 prior to excution of XCHG - is this

- to insure that the "Flag" variable will be set to 1 after the XCHG or

- the XCHG instruction will not work unless a 1 is loaded into AX before executing the XCHG instruction ?

Thanks

Reply to
2005
Loading thread data ...

None of those.

It is to ensure that your local effective address as stored in DX doesn't overload your carry flag.

Reply to
Alison

Sorry buddy, I am not falling for it this time.

-Isaac

Reply to
Isaac Bosompem

Don't listen to the other guys, they are trying to trick you. You should load EAX with 0x01010101, then the flag will be correctly set to 1 irrespectively of the endian setting.

Wilco

Reply to
Wilco Dijkstra

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.