| ??? 09/15/07 09:35 Modified: 09/15/07 09:48 Read: times |
#144642 - Re: Tried your method Responding to: ???'s previous message |
Hi Chico,
You've got some of it. At the end of the code you are leaving the compensation out. I'm not in the position to find out what consequences that has exactly, but I think it will make it hard to do fine adjustments with your pots. Second, and this ties in with your question about inc a after cpl a, your complement calculation is not quite right. Think of this: 2 = 00000010b 1 = 00000001b 0 = 00000000b -1 = 11111111b -2 = 11111110b If you want to complement -2 for instance, and you use cpl, this happens: 11111110b (-2) -> cpl -> 00000001b (1) So if you use cpl on -2, you don't get 2, but 1. That's because cpl is designed as a binary operation, it isn't designed to work as a 2's complement negation. If you add one to the result (which is the same as inc), you get what you want. cpl will work correctly without inc for 1's complement. Anyway, I strongly suggest you make such background stuff your own by looking it up on wikipedia or such. The bottom line is that you shouldn't assume how instructions work, you should make sure you know by looking them up in the instruction set overview. Hans |



