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.
Declare an integer list with .data directive, less than or equal to 32 elements. This list should contain both negative and positive elements.
A. In register r4, create marker for the list [similar to how we did in class for even and odd integers], such that if integer is negative, then corresponding bit in r4 is set to 1, and 0 otherwise. For example, if array is: Array: .word -15, 15, 1, 2, -1, -2, -13, -14, -99, 12, 13, 1, 2, -1, -2, -3 endArray:
R4 = 1000 1111 1000 0111 0000 0000 0000 0000
Output bitwise representation of r4 in Uart.
B. For every -1 in the list, toggle the value in r4 from 1 to 0, and change that value in the array from -1 to 1. Also change all 1s to -1s in the array and toggle the corresponding value in r4. Output the new array in the Uart, followed by bitwise representation of r4.
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started