Jump to content
IGNORED

subtraction problem


antron

Recommended Posts

I don't understand...why not just use CMP?

 

lda wchman_L 

cmp #<MAN4_L 

beq reset

 

 

...and you'll save a byte+2 cycles

 

Perhaps because the algorithm is something like this ...

 


lda wchman_L

sec

sbc #<MAN4_L

beq reset



asl

tay

lda Location,y

.

.

blah

 

You never know. ;)

Link to comment
Share on other sites

  • 2 weeks later...
in my case he is right' date=' thanks.

 

but i don't understand why my original two cases gave different behavior.

 

how could they leave the carry in different states?[/quote']

if #

 

This is because after a sbc the carry is cleared if the subtraction needed a borrow (i.e., if the result is negative, assuming unsigned numbers) and the carry will be set if the subtraction didn't need a borrow.

 

In other words,

 

If A > B, then A - B will leave the carry set, but B - A will clear the carry.

 

See here: http://www.6502.org/tutorials/6502opcodes.htm#SBC

and here:http://www.geocities.com/oneelkruns/asm1step.html

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...