汇编语言:三个数比较大小,输出最小的那个数。

DATAS SEGMENT;此处输入数据段代码 
X DW 89
Y DW -78
Z DW 98
W DB 100,10
FLAG DW 0
DATAS ENDS

STACKS SEGMENT;此处输入堆栈段代码
   DW 100 DUP(?)
STACKS ENDS

CODES SEGMENT
    ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
   	    MOV AX,DATAS
   		MOV DS,AX;此处输入代码段代码
    	MOV AX,X
    	MOV BX,Y
    	CMP AX,BX
    	JL  XIAOYU1    ;低于跳转到
    	XCHG AX,BX
XIAOYU1:MOV BX,Z
   		CMP AX,BX
   		JL XIAOYU2
   		XCHG AX,BX
XIAOYU2:CMP AX,0
         JG XIAOYU3  ;大于转移
         MOV CX,0
         SUB CX,AX
         MOV AL,'-'
         MOV DL,AL
         MOV AH,02H
         INT 21H
         MOV AX,CX
XIAOYU3: DIV W
         PUSH AX
         CMP AL,0
         JZ AA
         MOV BX,1
   		 MOV FLAG,BX
   		 ADD AL,30H
   		 MOV DL,AL
      	 MOV AH,02H
  		 INT 21H
AA:      POP AX
   		 MOV AL,AH
  		 MOV AH,0
  		 DIV W+1
  		 CMP FLAG,1
  		 JZ cc
  		 CMP AL,0
  		 JZ BB
CC:		 PUSH AX
   		 ADD AL,30H
  		 MOV DL,AL
   		 MOV AH,02H
   		 INT 21H
   
BB:		 POP AX
         ADD AH,30H
         MOV DL,AH
  		 MOV AH,02H
  		 INT 21H
       
    
    MOV AH,4CH
    INT 21H
CODES ENDS
    END START

你可能感兴趣的:(汇编语言)