CMPX/CMPSX Z flag issue
ozpropdev
Posts: 2,792
Chip
I started a seperate thread for this issue highlighted by garri on another thread.
As garryi points out the Z flag is not being set and returns the previous Z state.
Here's another test snippet.
I started a seperate thread for this issue highlighted by garri on another thread.
As garryi points out the Z flag is not being set and returns the previous Z state.
Here's another test snippet.
dat org or dirb, ##$ffff mov outb,#0 setcz #%01 wc,wz 'set z flag = 1 (z) cmpx a,b wz,wc setbz outb,#0 'led0 on setcz #%00 wc,wz 'set z flag = 0 (nz) cmpx a,b wz,wc setbz outb,#1 'led1 off, should be on me jmp #me a long 3 b long 3
Comments
ADDX
ADDSX
SUBX
SUBSX
CMPX
CMPSX
In the instructions above, the X means 'extended'. These instructions use the carry as an input and they also AND the old Z flag with what would have been the new Z flag in the non-X instruction versions. These are useful for multi-long additions, subtractions, and comparisons, where you'd like both C and Z to be valid at the end of the operation.
Here is an example where two 64-bit values are compared:
I see now how I got my wires crossed there.
Using the P1 manal as a reference I read the following. The description of the result led me to believe it operated the same as CMP as the wording is the same.
It's probably at this point in the manual it should mention the Old Z is ANDed with the New Z and not on the next page.
I hear the echo of one of my old lecturer's now "READ the manual!"
<:(
Based on my new found knowledge from the P1 docs, does this give you the result you expect.
Note the CMPX line is preceeded by a SETCZ instruction and the CMPX instruction has it's fields reversed as the comparison is D field aginst S field +C.
where D, S, and CZ are initial values, and R and RCZ are the result values.
So, maybe docs are wrong or instruction is wrong?
I suspected it might be a doc hiccup. In the context of the example, it looked like the P2 CMPX differed from the P1 and my forum searches missed the link to @Seairth's great work.
But since it's much easier to change docs than silicon, I thought it would be prudent to ask