ense 352 lab 4
DESCRIPTION
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 - PowerPoint PPT PresentationTRANSCRIPT
ENSE 352 Lab 4
Objective
The objective of this lab is to introduce the students to bit manipulations using the ARM assembly instruction set.
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
MOV R0,#1
LSL R0, R0, #3
Examples Bit Shifting
10000000
00010000
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 determinethe state of bit 1 in R0.
AND R2, R0, #0x2
Result
XXXXXXXX
01000000
R0
R20X000000
This bit is isolated andAll other bits cleared.
Isolating Bits
• Setting a bit without affecting the other bits• Use the ORR instruction.
Ex. We want to set bit 1in R0.
ORR R0, R0, #0x2
Result
XXXXXXXX
01000000
R0
R0X1XXXXXX
This bit is set to one now.