It is currently Wed Dec 12, 2018 11:22 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Nov 17, 2018 3:31 am 
Offline

Joined: Tue Oct 16, 2018 5:46 am
Posts: 26
Hey guys and gals!

Is there any way on the 6502 that you can check if all bits in the accumulator are set to 1 in a specific order in just one operation?
I thought AND would do the trick but I can only check if ANY of the bits are set that way.

This branches with AND:

Code:
lda #%1000
and #%1100
bne :+


I would like it to branch only if BOTH bit 2 and 3 in a are set, as in %1100, %1110 or %1101. Is there any way I can do this or do I have to AND each bit separately?

Cheers!


Top
 Profile  
 
PostPosted: Sat Nov 17, 2018 3:50 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3722
Location: Mountain View, CA
Code:
and #%1100     ; We only care about bits 2 and 3
cmp #%1100     ; Are bits 2 and 3 set to 1?
beq YesTheyAre


Top
 Profile  
 
PostPosted: Sat Nov 17, 2018 3:55 am 
Offline

Joined: Tue Oct 16, 2018 5:46 am
Posts: 26
Thank you! :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group