现在的位置: 首页 > 综合 > 正文

汇编语言编写的输出三个数的最大和最小(原创)

2013年01月02日 ⁄ 综合 ⁄ 共 822字 ⁄ 字号 评论关闭

;AX store the big number
;cx store the small number
datarea segment
 x dw 50H
 y dw 59H
 z dw 51H
 a1 db 'the big number:'
 b1 db 'the samll number:'
datarea ends
prognam segment
main proc far
 assume cs:prognam,ds:datarea
start:
 push ds
 sub ax,ax
 push ax
 mov ax,datarea
 mov ds,ax
 mov bx,0
 mov ax,x[bx]
 cmp ax,y[bx]
 jb above ;x<y
 mov cx,y[bx]
a: cmp ax,z[bx]    ;x>y
 jb  above1  ;y<z
 jae  below
above: mov ax,y[bx]
 mov cx,x[bx]
 jmp a
above1: mov ax,z[bx]
 jmp  printit 
below:  cmp cx,z[bx]
 jb printit
 mov cx,z[bx]
  

printit: 
  
   
   mov bx,ax  
   mov di,cx
   
   mov si,0h
   mov cx,15
   mov ah,02
 l1:
   mov dl,a1[si]
   int 21h
   inc si
   loop l1
   mov ax,bx
   mov dl,al
   mov ah,2
   int 21h
   
   mov dl,0Dh  ;回车
   int 21h
   mov dl,0Ah  ;换行
   int 21h
   
   mov si,0h
   mov cx,17
   mov ah,02
 l2:
   mov dl,b1[si]
   int 21h
   inc si
   loop l2
   
   mov cx,di
   mov dl,cl
   mov ah,2
   int 21h
 ret
main endp
prognam ends
  end start

 

 

抱歉!评论已关闭.