Computers and Technology

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

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 04:30, Lilabbychichi
Ryan is working on the layout of her web page. she needs to figure out where her header, navigation bar, text, and images should go. what technique can her?
Answers: 1
image
Computers and Technology, 22.06.2019 17:30, jonquil201
Where would you click to edit the chart data?
Answers: 1
image
Computers and Technology, 22.06.2019 17:30, babyface1686
How do you make a lenny face? plz, brailiest to who can answer first.
Answers: 1
image
Computers and Technology, 24.06.2019 12:40, kanga06
Match the feature to the network architecture. expensive to set up useful for a small organization easy to track files has a central server inexpensive to set up difficult to track files useful for a large organization does not have a central server client- server network peer-to-peer network
Answers: 3
Do you know the correct 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
Engineering, 26.01.2021 06:30
Konu
Mathematics, 26.01.2021 06:30
Konu
Social Studies, 26.01.2021 06:30