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

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 02:50
Define a class named movie. include private fields for the title,year, and name of the director. include three public functions withprototypes void movie: : settitle(cstring); , voidmovie: : setyear(int); , void movie: : setdirector(string); . includeanother function that displays all the information about a movie.write a main() function that declares a movie object namedmyfavoritemovie. set and display the object's fields.this is what i have but know its wrong since it will notcompile: #include#includeusing namespace std; //class declarationclass movie{private: string movietitle ; string movieyear; string directorname; public: void settitle(string title); void setyear(string year); void setdirector(string director); void displayinfo(); }; //class implementationvoid movie: : settitle(string title){ movietitle = title; cout< < "what is the title of themovie? "< > temp; myfavoritemovie.settitle(temp); cout< < "enter movie year"< > temp; myfavoritemovie.setyear(temp); cout< < "enter director'sname"< > temp; myfavoritemovie.setdirector(temp); //display all the data myfavoritemovie.displayinfo(); system("pause"); return 0; this code is not entirely mine someone on cramster edited my firstcode but then i try manipulating the new code and i still get acompile error message : \documents\visual studio 2008\projects\movie\movie\movie.cpp(46) : error c2679: binary '< < ' : no operator found which takes aright-hand operand of type 'std: : string' (or there is no acceptableconversion)c: \program files (x86)\microsoft visual studio9.0\vc\include\ostream(653): could be'std: : basic_ostream< _elem,_traits> & std: : operator< < > (std: : basic_ostream< _elem,_traits> & ,const char *)w
Answers: 1
question
Computers and Technology, 23.06.2019 08:00
The managing director of a company sends a christmas greeting to all his employees through the company email. which type of network does he use? he uses an .
Answers: 3
question
Computers and Technology, 24.06.2019 13:00
Append and make table queries are called queries. select complex simple action i think action
Answers: 1
question
Computers and Technology, 24.06.2019 17:30
What is the next step if your volume does not work on computer
Answers: 2
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
Questions on the website: 13722367