Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

- Use the code provided in startercode.s and put your code in the spot that says Your code here. - DONOT use r0 and r1

- Use the code provided in startercode.s and put your code in the spot that says Your code here. - DONOT use r0 and r1 for your code because that part is used in starter code.

Q1. Move #6 into r3 and perform the following operations on it: 1. Logical Shift Left, thrice 2. Add one to it 3. Now Rotate Right 4 times

Q2. Move #7 into r3 and perform the following operations on it: 1. Logical Shift Right, thrice 2. Comment your answer after that

Q3. Load a value from a variable using .data directive into r3. [make sure not to use R0 and R1 to load and access the data]. Logical Shift it Right twice.

Q4. Load a value from a variable using .data directive into r2. [make sure not to use R0 and R1 to load and access the data]. Create the following mask into r3: - To check if 6th, 17th and 30th bits are 1

Here is the code for startercode.s (in ARMv7)

// Constants

.equ UART_BASE, 0xff201000 // UART base address

.equ MASK, 0x0F

.equ DIGIT, 0x30

.equ LETTER, 0x37

.org 0x1000 // Start at memory location 1000

.text // Code Section

.global _start

_start:

/////////////////////////////////////// ///////////Your Code Here ///////////// ///////////////////////////////////////

// Print R3 to UART as ASCII

LDR R0, =UART_BASE

MOV R1,#8

// Print the register contents as ASCII characters

// Assumes value to print is in R3, UART address in R0

// Uses R1 for counter and R2 for temporary value

// R0 and R3 are preserved

TOP:

ROR R3,#28 // Rotate next four bits to LSB

MOV R2,R3 // Copy to R2 for masking

AND R2,R2,#MASK // Keep last 4 bits only

CMP R2,#9 // Compare last 4 bits to 9

ADDLE R2,R2,#DIGIT // add ASCII coding for 0 to 9

ADDGT R2,R2,#LETTER // add ASCII coding for A to F

STR R2,[R0] // Copy ASCII byte to UART

SUB R1,#1 // Move to next byte

CMP r1,#0 // Compare the countdown value to 0

BGT TOP // Branch to TOP if greater than 0

_stop:

B _stop

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions