Assembly: using a branched structure size comparison of the number three

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_43269048/article/details/102769432

Topics requirements:
given three signed number, write a more equal relationship procedure:
(1) If this number is not equal to three, then the display 0;
(2) If there are equal numbers of two of these three numbers, 1 is displayed;
(3) if these are equal number of three, two display;
answer:

DATAS SEGMENT
    ;此处输入数据段代码  
    num1 = 1
    num2 = 0
    num3 = -2
    result db 'aThe result is:','0','$'
DATAS ENDS

STACKS SEGMENT
    ;此处输入堆栈段代码
STACKS ENDS

CODES SEGMENT
    ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
    MOV AX,DATAS
    MOV DS,AX
    mov al,num1
    mov ah,num2
    mov bl,num3
    cmp  al,ah
    je r1
    cmp ah,bl
    je r2
    cmp al,bl
    je r3
    mov result[0],'0'
    jmp done
  r1:cmp ah,bl
  	je r11
  	mov result[0],'1'
  	jmp done
  r2:mov result[0],'1'
  	jmp done
  r3:mov result[0],'1'
  	jmp done
 r11:mov result[0],'2'
 	jmp done
 done: mov dx,offset result
    MOV AH,09h
    INT 21H
     MOV AH,4CH
    INT 21H
CODES ENDS
END START

Analytical ideas: first draw process flow chart, in accordance with a control program flow jumps to

Guess you like

Origin blog.csdn.net/qq_43269048/article/details/102769432
Recommended