![]() |
jne without cmp
I am little bit curious about the compare and jump instructions. First the cmp instruction; I read about this one on wikibooks.org which says: "cmp performs a subtraction between the two operands and sets the flags". What flags do they mean? Is it a register? Which one, if that is the case?
And so the jump instruction. For example if I use the jne instruction; where does it look for the value that is "not equal"? It must be the flags that cmp sets. But where is the flags stored? Thanks for answears! /Klarre |
Yes, there is a flag register where this stuff is stored.
|
I found some documents about how the flags on the processor works. So now I pretty much understands how it works.
|
Think of it like this: if you want 'jne', what isn't equal to what? You have to set up some equality test somewhere and store the result somewhere. In assembly language this is in the nuts and bolts part of the processor. Many instructions include the states of the flag register as part of the conditions for their execution. Some that you might think should do so, do not. This can bite you in the butt. In the 8080, incrementing a register and adding 1 to a register were the same operation, and set the zero flag according to the result. The Z80, which was SUPPOSED to be perfectly downward-compatible with the 8080 missed a beat. Adding 1 to a register set the zero flag appropriately; incrementing the register didn't touch the flag.
|
| All times are GMT -5. The time now is 4:41 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC