subject

I am having trouble of getting the coding working because I have four errors and I have hard getting the sum and odd even working I have got the odd number sun working. But now it won’t bring out my even number sum and keeps asking for a number.
My loop asks for the number, I then mov eax to the ebx and clear for division. If it is even I jump it out of loop and do addition for the even sum in that exit loop. I loop back to L1 from there and have it finish adding the odd numbers which will come out properly. After that it just endlessly asks me to enter a number.
instruction:
Lab 7A - Summing Numbers
Ask the user for the amount of numbers they would like to input. Construct a counted loop that will run the number of times the user specified. Inside the loop input numbers from the keyboard and sum all of the odd and even numbers. Use two DWORD variables to hold the odd and even sums. Create a DWORD variable called divisor and store 2 in it. This will be used to divide the number input.
Do not use .IF and .ELSE constructs
Your program should look like the following:
How many number do you want to input?
5
Enter a number
1
Enter a number
2
Enter a number
3
Enter a number
4
Enter a number
5
The sum of the even numbers is 6
The sum of the odd numbers is 9
Press any key to close this window . . .
Something to consider:
When you read a number from the keyboard. You need to store it to another register before calling the div instruction. Remember, the div instruction will modify both the eax and the edx register. If you store the value read into the ebx for instance you can simply add it to the even or odd sum depending on the result of the division.
my code
INCLUDE asmlib. inc
.data
sum DWORD 0
evenCount DWORD 0
oddCount DWORD 0
divisor DWORD 2
msg BYTE "How many numbers do you want to input?",0
prompt BYTE "Enter a number ", 0
outpEven BYTE "The sum offset the even numbers is ", 0
outpOdd BYTE "The sum of the odd numbers is",0
.code
main PROC
mov edx, OFFSET msg ;prime the loop
call writeLine ;getting the first
call readInt ;number
mov ecx, eax
mov edx, OFFSET prompt
L1:
call writeLine
call readInt
mov edx, eax ;store eax
mov edx, 0 ;clear for the division
div divisor ;divide by 2
cmp edx, 0
jne EVEN
inc evenCount
add sum, eax
mov edx, OFFSET prompt
call writeString
call writeInt
LOOP L1
EVEN:
inc evenCount,0
jle ODD
mov eax, sum
mov edx, OFFSET outpEven
call writeString
call writeInt
endl
LOOP L1
jmp EXIOUT
ODD:
mov edx, OFFSET outpOdd
call writeLine
EXIOUT:
exit
main ENDP
END main

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 07:00, chuchi24
Robots with telescoping arms are sometimes used to perform tasks (e. g., welding or placing screws) where access may be difficult for other robotic types. during a test run, a robot arm is programmed to extend according to the relationship r = 3 + 0.5cos(4θ) and the arm rotates according to the relationship θ=−π4t2+πt , where r is in feet, θ is in radians, and t is in seconds. use a computer program to plot the path of tip a in x and y coordinates for 0 ≤ t ≤ 4s.
Answers: 2
image
Computers and Technology, 22.06.2019 18:00, crimhill
When is it appropriate to use an absolute reference
Answers: 1
image
Computers and Technology, 22.06.2019 21:00, depression4eternity
The average cost of one year at a private college in 2012-2013 is $43,289. the average grant aid received by a student at a private college in 2012-2013 is $15,680.   what is the average student contribution for one year at a private college in 2012-2013?
Answers: 3
image
Computers and Technology, 23.06.2019 12:00, muncyemily
From excel to powerpoint, you can copy and paste a. cell ranges and charts, one at a time. b. cell ranges and charts, simultaneously. c. charts only. d. cell ranges only.
Answers: 3
You know the right answer?
I am having trouble of getting the coding working because I have four errors and I have hard getting...

Questions in other subjects:

Konu
Mathematics, 27.09.2019 06:30
Konu
Mathematics, 27.09.2019 06:30
Konu
Mathematics, 27.09.2019 06:30