Question: - 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.

Q5. 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 write 1 into 8th bit

Q6. 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]. Toggle the 8th bit of r3.

Q7. 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]. Toggle 8th, 19th and 25th bit of r3.

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!