60 403
Assignments Done
98,2%
Successfully Done
In April 2018

Answer to Question #15687 in Other Programming & Computer Science for mitch

Question #15687
Odd and even number program in assembly language?

the numbers are from 0-9 and the program should determine if it's odd or even, else if the input is not a number, it should be an invalid input.

assembly language using debug.exe in ms dos only.

please help
Expert's answer
model small
.stack 200H
.data
msg1 DB 10,13,' Number is odd.$'
msg2 DB 10,13,' Number is even.$'
msg3 DB 10,13,'Enter the no:$'
newline DB 10,13,'$'
sum DW 0
count DW ?
num DW ?
.code
print MACRO msg
PUSH AX
PUSH DX
MOV AH,09H
MOV DX,offset msg
INT 21H
POP DX
POP AX
ENDM
.startup
print newline
print msg3
CALL readnumtoAX
MOV BL,02
DIV BL
CMP AH,00
JE even1
print newline
print msg1
JMP last
even1:
print newline
print msg2
last:
.exit
readnumtoAX PROC NEAR
PUSH BX
PUSH CX
MOV CX,10
MOV BX,00
back:
MOV AH,01H
INT 21H
CMP AL,'0'
JB skip
CMP AL,'9'
JA skip
SUB AL,'0'
PUSH AX
MOV AX,BX
MUL CX
MOV BX,AX
POP AX
MOV AH,00
ADD BX,AX
JMP back
skip:
MOV AX,BX
POP CX
POP BX
RET
readnumto AX ENDP
END

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions