ARM on a raspberry pi 1. Create a assembly program that branches based off the value of three different variables. ## Details Task 1: I highly suggest reading the book and doing the practice before doing this. Name your file cp5.s. You need to initally start with the three variables. * the variables should be called max, t1, t2. * Set the values to whatever you would like. * max tells us the cut off for a value * if t1 or t2 greater than max we branch to a function that adds 2 to the register r0. * if t1 or t2 less than the max we branch to a function that adds 1 to the register r0. Your main should, 1. load the addresses of the variables into a register. 2. Load the values within the variables. 3. Compare the variables and branch to the functions that do something to r0. 4. Finally your program should return 2,3, or 4 depending on the values of t1 and t2. You will also need to create a makefile to build your assembly code as well. ## Gradding Task 1: I will first run your makefile. Your makfile should create files specified in the chapter. (1 point) I will run your code useing this command `./cp5 ; echo $?`. The output should be 2,3, or 4. (2 points) When I run `make clean` the files created by your make should be deleted. (1 point) Loading memory from variables will be worth 2 points. Do a comparison that branches to a new funtion depending on the comparison. (2 points) Return a correct value based on the values of the variables.
.data
.align 4
t1:
.word 0
.align 4
t2:
.word 0
.align 4
max:
.word 0
.align 4
.global main
main:
ldr r1, addr_of_t1
mov r3, #5
str r3, [r1]
ldr r2, addr_of_t2
mov r3, #8
str r3, [r2]
ldr r4, addr_of_max
mov r3, #10
str r3, [r4]
ldr r1, addr_of_t1
ldr r1, [r1]
ldr r2, addr_of_t2
ldr r2, [r2]
ldr r4, addr_of_max
ldr r4, [r4]
cmp r1, r4
blt r1_lower
cmp r2, r4
blt r2_lower
mov r0, #1
r1_lower:
mov r0, #2
b end
r2_lower:
mov r0, #2
b end
addr_of_t1: .word t1
addr_of_t2: .word t2
addr_of_max: .word max
Get Answers For Free
Most questions answered within 1 hours.