注册 登录
编程论坛 汇编论坛

求助!这个程序怎么编呀~急~

jian582001 发布于 2006-04-24 16:40, 620 次点击
要求
1.运行程序显示字符串:
Are you a boy?
please input a char(Y/y/N/n)!
2.说明:用户键入一个 字符,情况有5种
(1)若为大写Y则显示:I am a boy!(返回DOS)
(2)若为小写y显示:I am a boy!(返回DOS)
(3)若为大写N则显示:No,I am not boy,I am girl.(返回DOS)
(4)若为小写n显示:No,I am not boy,I am girl.(返回DOS)
(5)若不是以上4种情况则显示:Input error repeat
Input
3.提示 (1)用DOS功能调用9号,1号,功能
(2)用比较条件转移指令
2 回复
#2
jsjzhou2006-04-25 18:17

data segment
msg0 db 'Are you a boy?',13,10,'please input a char(Y/y/N/n)!$'
msg1 db 13,10,'I am a boy!$'
msg2 db 13,10,'No I am a gial$'
msgerror db 13,10,'Input error repeat$'
data ends


code segment
main proc far
assume cs:code,ds:data
begin:
mov ax,data
mov ds,ax


mov ah,09H
lea dx,msg0
int 21H

mov ah,01H
int 21H

mov ah,09H


cmp al,'Y'
jnz s1

lea dx,msg1
int 21H
jmp exit
s1:
cmp al,'y'
jnz s2
lea dx,msg1
int 21H
jmp exit
s2:
cmp al,'N'
jnz s3
lea dx,msg2
int 21H
jmp exit
s3:
cmp al,'n'
jnz error
lea dx,msg2
int 21H
jmp exit

error:
lea dx,msgerror
int 21H
jmp begin


exit:
mov ah,4cH
int 21H
main endp
code ends
end begin


masm 5.0调试通过

#3
jian5820012006-04-28 17:52
多谢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1