程序运行效果:
Please enter the number:7
odd number
Do you want to try again?(y/n)y
Please enter the number:6
even number
Do you want to try again?(y/n)n
data
segment
message1 db 'Please enter the number:','$'
message2 db 13,10,'odd number','$'
message3 db 13,10,'even number','$'
message4 db 13,10,'Do you want to try again?(y/n)','$'
buf DB 9,?,8 dup ('0')
data
ends
code
segment
assume
cs:code,ds:data
start:
mov
ax,data
mov
ds,ax
flag3:
lea dx,message1
mov ah,9
int 21h
MOV dx,offset buf
MOV ah,0ah
int 21h
mov cl,[buf+1]
mov ch,0
lea si,[buf+1]
add si,cx
mov ch,[si]
sub ch,30h
rcr ch,1
jnb flag1
lea dx,message2
mov ah,9
int 21h
jmp flag2
flag1:
lea dx,message3
mov ah,9
int 21h
flag2:
lea dx,message4
mov ah,9
int 21h
mov ah,1
int 21h
cmp al,'y'
jnz exit
mov dl,13
mov ah,2
int 21h
mov dl,10
int 21h
jmp flag3
exit:
mov
ah,4ch
int
21h
code
ends
end
start
[
本帖最后由 zhulei1978 于 2007-11-23 15:08 编辑 ]