Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .global main
- .align 4
- .section .rodata
- prompt: .asciz "Enter four integer values\n"
- input_str: .asciz "You entered %d %d %d $d\n"
- smallest_value_str: .asciz "The smallest value is %d\n"
- largest_value_str: .asciz "The largest value is %d\n"
- sum_str: .asciz "The sum of all values is: %d\n"
- average_str: .asciz "THe average of all four values is: %d\n"
- format: .string "%d"
- .align 4
- .data
- a: .word 1
- b: .word 1
- c: .word 1
- d: .word 1
- .align 4
- .text
- main: push {lr}
- ldr r0, =prompt //output prompt message
- bl printf
- // Inputting numbers
- ldr r0, =format
- ldr r1, =a
- bl scanf
- mov r5, r1
- ldr r0, =format
- ldr r1, =b
- bl scanf
- mov r6, r1
- ldr r0, =format
- ldr r1, =b
- bl scanf
- mov r7, r1
- ldr r0, =format
- ldr r1, =c
- bl scanf
- mov r8. r1
- // print message for entered numbers
- ldr r0, =input_str
- mov r1, r5
- mov r2, r6
- mov r3, r7
- mov r4, r8
- // Finding the smallest value
- mov r9, r5
- cmp r9, r6
- bgt first_small
- b second_small
- first_small:
- mov r9, r6
- second_small:
- cmp r9. r7
- bgt third_small
- b fourth_small
- third_small:
- mov r9. r7
- fourth_small:
- cmp r9, r8
- bgt fifth_small
- b smallest_output
- fifth_small:
- mov r9, r8
- smallest_output:
- ldr r0, =smallest_value_str
- mov r1, r9
- bl printf
- // Finding the largest value
- mov r10, r5
- cmp r10, r6
- blt first_large
- b second_large
- first_large:
- mov r10, r6
- second_large:
- cmp r10, r7
- blt third_large
- b fourth_large
- third_large:
- mov r10, r7
- fourth_large:
- cmp r10, r8
- blt fifth_large
- b largest_output
- fifth_large:
- mov r10, r8
- largest_output:
- ldr r0, =largest_value_str
- mov r1, r10
- bl printf
- // Finding the sum of all values
- mov r11, r5
- add r11, r11, r6
- add r11, r11, r7
- add r11, r11, r8
- ldr r0, =sum_str
- mov r1, r11
- bl printf
- // Finding the average of all values
- ldr r12, [r11]
- lsl r12, r12, #2
- ldr r0, =average_str
- mov r1, r12
- bl printf
- mov r0, #0
- pop {pc}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement