+Random Terrain Posted May 31, 2008 Share Posted May 31, 2008 (edited) Is there some already built-in bitwise magic to slide bits from one variable to another? For example, could a group of bits slide off the right side of a variable and into the left side of another variable? Thanks. Edited May 31, 2008 by Random Terrain Quote Link to comment Share on other sites More sharing options...
kenfused Posted May 31, 2008 Share Posted May 31, 2008 (edited) Is there some already built-in bitwise magic to slide bits from one variable to another? For example, could a group of bits slide off the right side of a variable and into the left side of another variable? Thanks. In ASM it would be asl RightVar rol LeftVar Edited May 31, 2008 by kenfused 1 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted May 31, 2008 Author Share Posted May 31, 2008 Is there some already built-in bitwise magic to slide bits from one variable to another? For example, could a group of bits slide off the right side of a variable and into the left side of another variable? Thanks. In ASM it would be asl RightVar rol LeftVar Thanks. I was looking at the following page and I thought those just rotated the bits within a variable instead of passing them on to the next variable: http://www.atariarchives.org/2bml/chapter_10.php I must have read it wrong. Thanks for the help. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted May 31, 2008 Author Share Posted May 31, 2008 In ASM it would be asl RightVar rol LeftVar I couldn't get that to work quite right, so I played around with your example and this seems to do what I want: asm ROR LeftVar ROL RightVar end Thanks for getting me on the right track. This is much easier than what I tried to do in BASIC and it takes up less space too. Quote Link to comment Share on other sites More sharing options...
kenfused Posted May 31, 2008 Share Posted May 31, 2008 asm ROR LeftVar ROL RightVar end Thanks for getting me on the right track. This is much easier than what I tried to do in BASIC and it takes up less space too. That would shift LeftVar right. The left most bit would depend on code before it. Then it would shift RightVar to the the left. The rightmost bit would be what was in the right bit of LeftVar. ASL shifts bits to the left shifting in a 0 at the rightmost bit. The leftmost bit that gets shifted out goes into the carry flag. ROL is the same as ASL except instead of shifting in a 0 at the right most bit it shifts in the carry flag. So if you have two bytes to shift left you would use ASL byte1 ROL byte2 This would be the same as CLC ROL byte1 ROL byte2 LSR and ROR are similar but going to the right. LSR byte2 ROR byte1 Just remember to do them in the byte order things are flowing. 1 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted May 31, 2008 Author Share Posted May 31, 2008 Maybe it works differently with playfield variables or something: ror_rol_example.bin Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.