.model small
.stack
.data
_a db 0h
_b db 0h
_c db 0h
tag db ?
string1 db 255
db 0
db 255 dup(0)
string2 db 255
db 0
db 255 dup(0)
string3 db 255
db 0
db 255 dup(0)
Prompta db 'please input a :',0dh,0ah,'$'
Promptb db 'please input b :',0dh,0ah,'$'
Promptc db 'please input c :',0dh,0ah,'$'
Newline db 0dh, 0ah, "$" ;回车换行
.code
ALdisp proc
push ax
push cx
push dx
push ax
mov dl,al
mov cl,4
shr dl,cl
or dl,30h
cmp dl,39h
jbe aldisp1
add dl,7
aldisp1:mov ah, 2
int 21h
pop dx
and dl,0fh
or dl,30h
cmp dl,39h
jbe aldisp2
add dl,7
aldisp2: mov ah,2
int 21h
pop dx
pop cx
pop ax
ret
ALdisp endp
.startup
;输入a
mov dx,offset Prompta
mov ah,09h
int 21h
mov ax, seg string1 ;取数据段存入ds中
mov ds, ax
mov dx,offset string1
mov ah, 0ah
int 21h
lea dx, Newline ;输出回车换行
mov ah, 9h
int 21h
;输入b
mov dx,offset Promptb
mov ah,09h
int 21h
mov ax, seg string2 ;取数据段存入ds中
mov ds, ax
mov dx,offset string2
mov ah, 0ah
int 21h
lea dx, Newline ;输出回车换行
mov ah, 9h
int 21h
;输入c
mov dx,offset Promptc
mov ah,09h
int 21h
mov ax, seg string3 ;取数据段存入ds中
mov ds, ax
mov dx,offset string3
mov ah, 0ah
int 21h
lea dx, Newline ;输出回车换行
mov ah, 9h
int 21h
not_use macro
mov ax,offset string3+2h
push ax
mov cl,string3+1h
mov ch,0
push cx
call GetC
endm
;求a
mov bx,offset string1+2h
mov cl,string1+1h
mov ch,0
again:mov al,[bx]
sub al,30h
cmp cx,2
ja next2
cmp cx,1
ja next1
add _a,al
jmp done
next2:mov dl,64h
mul dl
add _a,al
jmp done
next1:mov dl,0ah
mul dl
add _a,al
done: inc bx
loop again
;求b
mov bx,offset string2+2h
mov cl,string2+1h
mov ch,0
againb:mov al,[bx]
sub al,30h
cmp cx,2
ja next2b
cmp cx,1
ja next1b
add _b,al
jmp doneb
next2b:mov dl,64h
mul dl
add _b,al
jmp doneb
next1b:mov dl,0ah
mul dl
add _b,al
doneb: inc bx
loop againb
;求c
mov bx,offset string3+2h
mov cl,string3+1h
mov ch,0
againc:mov al,[bx]
sub al,30h
cmp cx,2
ja next2c
cmp cx,1
ja next1c
add _c,al
jmp donec
next2c:mov dl,64h
mul dl
add _c,al
jmp donec
next1c:mov dl,0ah
mul dl
add _c,al
donec: inc bx
loop againc
;求是否有根
mov al,_b
imul al
mov bx,ax
mov al,_a
imul _c
mov cx,4
imul cx
cmp bx,ax
jge yes
mov tag,'N'
jmp donew
yes: mov tag,'Y'
donew:mov ah,02h
mov dl,tag
int 21h
.exit 0
end