Hack Forums
[Assembly] Setting Two Bits High In Register - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5)
+---- Thread: [Assembly] Setting Two Bits High In Register (/showthread.php?tid=4462524)



Setting Two Bits High In Register - _spun - Sep 25, 2014

I'm working with Raspberry Pi for a class project and very new to assembly, so I'm pretty much retarded at it right now.

So I'm trying to enable output to two GPIO pins. I can set one no problem. But I have a fundamental misunderstanding of how assembly handles things

for example
Code
move r1, #1
lsl r1, #12
str r1,[r0,#4]
That code maps to GPIO 14. I also want to set the bit to GPIO 15 and can't seem to get it right. I thought I could just perform another lsl but that shifts over all the data.

So basically I also need to set bit 15 to 1 in r1.
I'm confused.


* - K4Fr - Sep 26, 2014

Use a bitwise OR to set bits. orr r1, #0x8000 will set bit #15 in r1. Leaving the other bits intact.