rcises 1 Write a subroutine that can create a time delay that is a multiple of I
ID: 3741054 • Letter: R
Question
rcises 1 Write a subroutine that can create a time delay that is a multiple of I ms. The multiple is passed in register r16, assuming that the CPU clock is 16 MHz. E5.2 Write a subroutine that can create a time delay that is a multiple of 10 ms. The multiple is passed in rl6, assuming that the CPU clock is 16 MHz. E5.3 Write a subroutine that can divide a 16-bit signed integer into another 16-bit signed int- eger. The dividend and divisor are passed in registers r16-r17 and r18-T19, respectively. The quotient and remainder are returned in r24-125 and r22-123, respectively. E5.4 Write a subroutine that can divide a 32-bit unsigned integer into another 32-bit unsigned integer. The dividend is passed in registers r16-r19, and the divisor is passed in the stack. The quotient is returned in registers r22-125, and the remainder is returned in registers r16-119. E5.5 Write a subroutine that can divide a 32-bit signed integer into another 32-bit signed int- eger. The dividend is passed in registers r16-r19, and the divisor is passed in the stack. The quotient is returned in registers r22-125, and the remainder is returned in registers r16-r19. E5.6 Write a subroutine to find the number of elements in an array that are a multiple of 5. The pointer to the array is passed in r30-r31, whereas the array count is passed in r16. The array has no more than 255 16-bit unsigned integers. The subroutine returns the result in register r22. E5.7 Write a subroutine to find the greatest common divisor of two 16-bit unsigned integers. Two integers are passed in registers r16-r17 and rl8-r19, respectively. The god is returned in har hae the following prop-Explanation / Answer
sample(int*):
str fp, [sp, #-4]!
add fp, sp, #0
sub sp, sp, #20
str r0, [fp, #-16]
mov r3, #0
str r3, [fp, #-8]
.L4:
ldr r3, [fp, #-8]
cmp r3, #4
bgt .L2
ldr r3, [fp, #-8]
mov r3, r3, asl #2
ldr r2, [fp, #-16]
add r3, r2, r3
ldr r1, [r3]
ldr r3, .L6
smull r2, r3, r1, r3
mov r2, r3, asr #1
mov r3, r1, asr #31
rsb r2, r3, r2
mov r3, r2
mov r3, r3, asl #2
add r3, r3, r2
rsb r2, r3, r1
cmp r2, #0
bne .L3
ldr r3, [fp, #-12]
add r3, r3, #1
str r3, [fp, #-12]
.L3:
ldr r3, [fp, #-8]
add r3, r3, #1
str r3, [fp, #-8]
b .L4
.L2:
ldr r3, [fp, #-12]
mov r0, r3
sub sp, fp, #0
ldr fp, [sp], #4
bx lr
.L6:
.word 1717986919
.LC0:
.ascii "enter array elements"
.LC1:
.ascii "%d"
main:
stmfd sp!, {fp, lr}
add fp, sp, #4
sub sp, sp, #48
ldr r0, .L12
bl printf
mov r3, #0
str r3, [fp, #-8]
.L10:
ldr r3, [fp, #-8]
cmp r3, #4
bgt .L9
sub r2, fp, #52
ldr r3, [fp, #-8]
mov r3, r3, asl #2
add r3, r2, r3
mov r1, r3
ldr r0, .L12+4
bl scanf
ldr r3, [fp, #-8]
add r3, r3, #1
str r3, [fp, #-8]
b .L10
.L9:
sub r3, fp, #52
add r3, r3, #20
mov r0, r3
bl sample(int*)
str r0, [fp, #-12]
ldr r1, [fp, #-12]
ldr r0, .L12+4
bl printf
mov r3, #0
mov r0, r3
sub sp, fp, #4
ldmfd sp!, {fp, lr}
bx lr
.L12:
.word .LC0
.word .LC1
output:
enter array elements5 10 15 20 25
5
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.