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 00:30, silasjob09
Jenny wants to look at row 345 and compare it to row 17. what can she do if she wanted to easily adjust to see both at once?
Answers: 3
image
Computers and Technology, 22.06.2019 00:40, mcfancei
Reading characters and strings from the keyboard: consider the following c++ program 1. #include 2. #include 3. using namespace std; 4. mystring1 5. 6. int main() 7. { 8. 9. string mystring1, mystring2; mychar1 10. 11. 12. char mychar1, mychar2; 13. 14. cout< < "enter a string: "; mychar2 15. 16. cin> > mystring1; // 17. cin. get(mychar1); 18. cin> > mychar2; 19. getline(cin, mystring2); mystring2 20. 21. 22. cout<
Answers: 1
image
Computers and Technology, 22.06.2019 22:30, MoneyMike42
Alex’s family members live in different parts of the world. they would like to discuss the wedding plans of one of their distant relatives. however, alex wants all the family members to talk to each other simultaneously so that they can make decisions quickly. which mode of internet communication should they use? a. blog b. email c. wiki d. message board e. instant messaging
Answers: 2
image
Computers and Technology, 23.06.2019 04:31, hargunk329
Q13 what function does a security certificate perform? a. creates user accounts b. scrambles data c. identifies users d. creates password policies e. provides file access
Answers: 1
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
History, 01.02.2020 12:44
Konu
Mathematics, 01.02.2020 12:44