I'm trying to compare two 4-byte words: one at a fixed location (lba) and one at a variable location pointed to by [Y:A]. All I need to know is whether one is greater than the other; equality is nice to have since I can delete another routine. Both variables are unsigned values.
The need to increment and test Y demolishes any previously calculated flags, which is a shame, but I think this ought to work (I may have the C flag upside down). There's a lot of flags being pushed and pulled...
My assembler makes yours a byte longer than Leepivonka's, BDD, but it's more understandable to me and I think it might provide more functionality - not sure about that yet.
NeoDOS32 v0.0276
Free cluster count: 0001E5EC
Next free cluster: 0000007D
Press any key to boot:
Test 32-bit compare
lba is < tmpq1 Z = 0 S = 1 C = 0
lba is = tmpq1 Z = 1 S = 0 C = 1
lba is > tmpq1 Z = 0 S = 0 C = 1
finished test - any key
This means I can replace an existing equality test as well.
NeoDOS32 v0.0276
Free cluster count: 0001E5EC
Next free cluster: 0000007D
Press any key to boot:
Test 32-bit compare
lba is < tmpq1 Z = 0 S = 1 C = 0
lba is = tmpq1 Z = 1 S = 0 C = 1
lba is > tmpq1 Z = 0 S = 0 C = 1
finished test - any key
This means I can replace an existing equality test as well.
What are the S = 1 and S = 0 referring to?
Quote:
Okay for me to use the code in the FAT32 stuff?
Are you asking for permission to use my routine? Of course you may.
My assembler makes yours a byte longer than Leepivonka's, BDD, but it's more understandable to me and I think it might provide more functionality - not sure about that yet.
Having “slept on it,” as well having consumed sufficient quantities of coffee , I came up with a slightly shorter rendition:
The flags tested were zero, sign, and carry. Just included for completeness since it's the inverse of the carry. The canonical name is probably 'N' in 6502 land.
Thanks for the permission. Credit in the source code!
The new code is interesting, but it's handy to have the equality test as well.
Neil
edit: wait, what does the last routine return for equality? Z set?
The flags tested were zero, sign, and carry. Just included for completeness since it's the inverse of the carry. The canonical name is probably 'N' in 6502 land.
Yes, canonical for the negative bit in SR is ‘n’.
In a binary comparison context, the state of n is not only irrelevant, it may/could/might/probably-will be treacherous. In comparisons, c and z are your friends; n is a sNake in the grass , since it reflects the internal sign effect caused by the subtraction that CMP, CPX and CPY carry out. It is possible with certain values to produce a comparison in which carry is clear (register_value < memory_value) and the internal subtraction does not result in a carry into the sign bit.
Quote:
Thanks for the permission. Credit in the source code!
Yer welcome.
Quote:
The new code is interesting, but it's handy to have the equality test as well...edit: wait, what does the last routine return for equality? Z set?
Same results as the previous routine, as described in the comments.