Write a program in ARM assembly using ARMSim# to perform the following tasks: 1.
ID: 3740991 • Letter: W
Question
Write a program in ARM assembly using ARMSim# to perform the following tasks:
1. Open a file named "integers.dat" and keep track of the following information:
a. The first integer value is (i)
b. The ith integer value is (j)
c. Count the total number of integers in the file
d. Count the number of integers that are less than j
e. Count how many even numbers are less than j
f. And how many odd numbers are less than j
i.e.
Output the six pieces of information to the console (stdout), For example, if "integers.dat" contains the integers "4 -447 10 198 0 569 -34 986 547 4" I would expect the following result as an output:
a. Integer (i) = 4
b. Integer (j) = 198
c. Total integers = 10
d. Integers < (j) = 6
e. Even < (j) = 5
f. Odd < (j) = 1
Explanation / Answer
a. first integer value
b. ith integer value
RLoop:
ldr r0,=InFileHandle @ load input file handle
ldr r0,[r0]
swi SWI_RdInt @ read the integer into R0
bcs EofReached @ Check Carry-Bit (C): if= 1 then EOF reached
@ print the integer to Stdout
mov r1,r0 @ R1 = integer to print
mov R0,#Stdout @ target is Stdout
swi SWI_PrInt
mov R0,#Stdout @ print new line
ldr r1, =NL
swi SWI_PrStr
bal RLoop @ keep reading till end of file
c. count total number of integers
d. integers less than j
e. even numbers less than j
f. odd numbers less than j
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.