Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ARMSim#191 .data fileName: .asciz integers.dat message: .asciz %d %d %d %d %d .text .global _start _start: ;Initialize loop counter and other variables mov r0,

ARMSim#191

.data fileName: .asciz "integers.dat" message: .asciz "%d %d %d %d %d " .text .global _start _start: ;Initialize loop counter and other variables mov r0, #0 ; loop counter mov r1, #0 ; first integer value mov r3, #0 ; lowest integer value mov r4, #0 ; count of i mov r5, #0 ; count of integers less than i mov r6, #0 ; total count of integers ;Open file "integers.dat" mov r0, #5 ; System call number to open ldr r1, =fileName ; load filename into r1 mov r2, #0 ; open in read-only mode swi 0x66 ; execute system call to open file cmp r0, #0 ; check if file was successfully opened blt file_error ; if file descriptor is negative, there was an error opening the file loop: ; Read integer values from the file one by one ldr r2, [r0] ; read integer value from file add r6, r6, #1 ; increment total count of integers cmp r1, #0 beq first ; if this is the first integer value, set r1 to the value ; Check if the current integer is less than the lowest integer value cmp r2, r3 blt lowest ; if current value is less than lowest, set r3 to the value ; Check if the current integer is equal to the first integer value cmp r2, r1 beq count ; if current value is equal to the first integer value, increment count of i b next ; go to next iteration first: mov r1, r2 ; set first integer value to the current value b loop ; go to next iteration lowest: mov r3, r2 ; set lowest integer value to the current value add r5, r5, #1 ; increment count of integers less than i b next ; go to next iteration count: add r4, r4, #1 ; increment count of i b next ; go to next iteration next: add r0, r0, #4 ; move to next integer value in the file b loop ; go to next iteration output: ; Output the five pieces of information to the console mov r0, #1 ; System calls number to write mov r1, r1 ; first integer value mov r2, r4 ; count of i mov r3, r5 ; count of integers less than i mov r4, r3 ; integer with the lowest value mov r5, r6 ; total count mov r7, #4 ; System calls numbers to write to standard output ldr r0, =message ; message to be written to standard output swi 0x6b ; executes to write message to standard output exit: ; Exit the program swi 0x68 ; closes file mov r7, #1 ; number for exit mov r0, #0 ; exit with return code 0 swi 0x11 ; exits file_error

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago