Jump to content
IGNORED

Quick Question: Does 7800basic have bit shift operators?


M12

Recommended Posts

Sort of. If you multiply or divide by a power of 2, then it gets optimized into left or right shifting, respectively.

 

e.g.
 ; num1=num1*4" gets turned into this 6502 assembly...
 LDA num1
 ASL
 ASL
 STA num1

This is great for 8-bit values, but if you want to shift a 16-bit value (or more) you'll need to break out the assembly, since the multiply technique doesn't shift in any carry bits.

 

 rem 7800basic code with inline assembly...
 asm
 ;shift 16-bit value left one place
 ASL myvaluelo ; shifts all bits left one position. 0 is shifted into bit 0 and the original bit 7 is shifted into the Carry. 
 ROL myvaluehi ; shifts all bits left one position. The Carry is shifted into bit 0 and the original bit 7 is shifted into the Carry. 
end
 rem we're back to 7800basic code
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...