50 likes | 143 Views
Learn bit shifting in ARM assembly with ASR, LSL, LSR, ROR, RRX. Understand how to isolate and set bits with essential instructions.
E N D
Objective The objective of this lab is to introduce the students to bit manipulations using the ARM assembly instruction set. ENSE 352 Lab 4
Bit Shifting • ASR, LSL, LSR, ROR, and RRX • arithmetic shift right • logical shift left • logical shift right • rotate right • rotate right with extend Flags affected N, Z, R
Examples Bit Shifting MOV R0,#1 LSL R0, R0, #3 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0
Isolating Bits • Very important for embedded programming. • Often referred to as masking. • Affect only the bit you are interested in. • Utilize the AND and ORR instructions. Ex. Want to determine the state of bit 1 in R0. AND R2, R0, #0x2 Result X X X X X X X X R0 0 0 0 0 0 0 1 0 This bit is isolated and All other bits cleared. R2 0 0 0 0 0 0 X 0
Isolating Bits • Setting a bit without affecting the other bits • Use the ORR instruction. Ex. We want to set bit 1 in R0. ORR R0, R0, #0x2 Result X X X X X X X X R0 0 0 0 0 0 0 1 0 This bit is set to one now. R0 X X X X X X 1 X