ense 352 lab 4

5
ENSE 352 Lab 4 Objective The objective of this lab is to introduce the students to bit manipulations using

Upload: uta-price

Post on 31-Dec-2015

20 views

Category:

Documents


0 download

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 Presentation

TRANSCRIPT

Page 1: ENSE 352 Lab 4

ENSE 352 Lab 4

Objective

The objective of this lab is to introduce the students to bit manipulations using the ARM assembly instruction set.

Page 2: 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

Page 3: ENSE 352 Lab 4

MOV R0,#1

LSL R0, R0, #3

Examples Bit Shifting

10000000

00010000

Page 4: ENSE 352 Lab 4

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.

Page 5: ENSE 352 Lab 4

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.