Jump to content
  • 0
Sign in to follow this  
JohnGill

doing something dumb in assembly...

Question

... as usual!

Hi all,

I've got a piece of code that moves the "vera cursor" to the left four cells on screen:

    dec $9f20
    dec $9f20
    dec $9f20
    dec $9f20
    dec $9f20
    dec $9f20
    dec $9f20
    dec $9f20

8 decs, tile byte and attribute byte x4. This works and is fine and does exactly what I expect it to. However, I then thought I'd be clever (HA!) and make a tidier bit of code, like this:

version 2:

    lda $9f20
    clc
    sbc #8
    sta $9f20

Except this doesn't work. When I substitute version 2 for version 1 into my program, it screws up the cursor positioning on screen and I can't for the life of me see what the difference is between the above two bits of code. How could they possibly give two different answers?

Thanks In Advance!

John

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0
2 minutes ago, SlithyMatt said:

You need to use SEC before SBC, not CLC

*facepalm*

thanks so much. thought it would be something dumb!

  • Like 2

Share this post


Link to post
Share on other sites
  • 0
1 minute ago, JohnGill said:

*facepalm*

thanks so much. thought it would be something dumb!

No problem! It's a common beginner mistake because it's so counter-intuitive. But, MOS had their reasons, I suppose.

  • Like 1

Share this post


Link to post
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.

Guest
Answer this question...

×   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.

Sign in to follow this  

×
×
  • Create New...

Important Information

Please review our Terms of Use