tokumaru wrote:
unregistered wrote:
My sister said that I should try adding 80 to 6 and see what that does.
Your sister probably doesn't know much 6502 and is just guessing.
She reminded me that you can add a negative number to a positive one and it will be like subtracting it.
tokumaru wrote:
Do you really want to program a game based on guesses? You need to know what you're doing in order to make good software. Adding $80 or subtracting $80 will have the same result if you keep using 8 bits, because 128 and -128 are the same in hex in this case.
The result you're getting is not wrong, just ambiguous, and this might be causing you trouble. Like I said, if you want to get rid of this ambiguity, you'll need to use 16-bit math.
OOOOOOOH ok... this is math on a cpu. Then I understand now that it works kind of differently... Ill reread your first reply again.
edit:Ahhhhh yes!!!
tokumaru wrote:
unregistered wrote:
Ok, the accumulator has #$06 in it...
the carry is set
and it subtracts #$80
THEN it says the answer is #$86...
That's correct: 6 - 128 = -122 ($86, 8-bit, signed)
Quote:
Is that because it subtracted the negative 80 and that changes it to an add?

You can think of it this way, yes, but no matter how you look at it, the answer is correct:
6 - 128 = -122 ($86, 8 bit, signed)
6 - (-128) = 134 ($86, 8 bit, unsigned)
Quote:
edit: If that's so then is it possible to subtract 80? Maybe im missing something...

I'm not sure what your goal is, but maybe 8 bits aren't enough in this case? If you used 16 bits, the result wouldn't be so ambiguous. You see, when you use only 8 bits, 128 and -128 are the same in hex ($80), bit when you use 16 bits, they're very different: 128 = $0080, -128 = $FF80. So if you did $0006 - $0080 you'd get $FF86, which can't be mistaken for $0086.
That's what my 255 is for. Of course $ff86!!!!
YES THANK YOU SO MUCH TOKUMARU!!!!
