试编写程序,要求从键盘输入3个16进制数,并根据对3个数的比较显示信息

1.试编写程序,要求从键盘输入3个16进制数,并根据对3个数的比较显示如下信息:

 (1)如果3个数都不相等则显示0; (2)如果3个数中有2个数相等则显示2; (3)如果3个数都相等则显示3。

data segment
array dw 3 dup(?)
data  ends

code  segment
main  proc far
 assume cs:code,ds:data
start:
push ds
sub  ax,ax
push ax
mov  ax,data
mov  ds,ax
mov  cx,3
lea  si,array
begin:
 push cx
 mov  cl,4
 mov  di,4
 mov  dl, ' '
 mov  ah,02
 int  21h
 mov  dx,0
input:
mov  ah,01
int  21h
and  al,0fh
shl  dx,cl
or  dl,al
dec  di
jne  input
mov  [si],dx
add  si,2
pop  cx
loop  begin
comp:
 lea  si,array
 mov  dl,0
 mov  ax,[si]
 mov  bx,[si+2]
 cmp  ax,bx
 jne  next1
 add  dl,2
next1:
 cmp  [si+4],ax
 jne  next2
 add  dx,2
next2:
 cmp  [si+4],bx
 jne  num
 add  dl,2
num:
 cmp  dx,3
 jl  disp
 mov  dl,3
disp:
 mov  ah,2
 add  dl,30h
 int  21h
 ret
main  endp
code ends
  end  start

posted on 2009-04-15 15:39  fatkun  阅读(1597)  评论(0编辑  收藏  举报

导航