| |
Mace
Registered: May 2002 Posts: 1799 |
How is carry affected by compare?
Somewhere I read that the carry is affected by the result of a compare.
It's not in the Prog.Ref.Guide, other than a flag in the register table.
How does this work?
|
|
... 27 posts hidden. Click here to view all posts.... |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Quote: according to my link this should work:
cmp #$00
beq +
clc
+
(If the C flag is 1, then A (unsigned) >= NUM (unsigned) and BCS will branch)
cmp #$01
>=1 => C=1
<1 => C=0
|
| |
Mace
Registered: May 2002 Posts: 1799 |
\o/
I love hardcore coding like this :-D |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
Quote: cmp #$01
>=1 => C=1
<1 => C=0
you win. I had the idea that one cmp may be enough, but too tired to think it trough :P :) |
| |
Mace
Registered: May 2002 Posts: 1799 |
This is now on Codebase64.
The route is CPU (6502/6510) >> General Stuff >> Changing Registers. |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
uhh, rather remove that.. and add a link to the 6502.org tutorials... checking when A is zero is generally done with the Z bit anyway. It will just confuse newcomers. |
| |
Mace
Registered: May 2002 Posts: 1799 |
Better extend the tut on Codebase, because I found the 6502.org explanation rather confusing.
It's not wrong what I wrote on Codebase, so why remove it? |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Quote: Better extend the tut on Codebase, because I found the 6502.org explanation rather confusing.
It's not wrong what I wrote on Codebase, so why remove it?
@Mace: Indeed confusing. Personally I use the more simple explanation they have on: http://www.6502.org/tutorials/compare_instructions.html
Check the table labeled "Use of Branch Instructions with Compare". That is really all you need, promise.
|
| |
yago
Registered: May 2002 Posts: 333 |
The Part about "CMP is exactly like SBC" is also wrong
|
| |
Mace
Registered: May 2002 Posts: 1799 |
@Yago: it's Wiki, anyone can change it ;-)
I removed the page. |
| |
GT Account closed
Registered: Sep 2008 Posts: 308 |
CMP is:
sec
sbc
I use this method alot in 16-bits checks:
lda freq_low
cmp freq_low2
lda freq_high
sbc freq_high2
bcs/bcc whatever
|
Previous - 1 | 2 | 3 | 4 - Next |