相加

汇编语言 – 两个多位数相加的运算

CRLF MACRO
     MOV DL,0DH
     MOV AH,02H
     INT 21H
     MOV DL,0AH
     MOV AH,02H
     INT 21H
ENDM 
DATA     SEGMENT
DATA1    DB       33H,39H,31H,37H,39H,30H
DATA2    DB       36H,35H,30H,38H,39H,30H
DATA     ENDS
STACK    SEGMENT 
STA      DB       20  DUP('?')
TOP      EQU      20
STACK    ENDS
CODE     SEGMENT
  ASSUME CS:CODE,DS:DATA,SS:STACK,ES:DATA
START:   MOV AX,DATA
         MOV DS,AX
         MOV AX,STACK
         MOV SS,AX 
         MOV AX,TOP
         MOV SP,AX
         MOV SI,OFFSET DATA2
         MOV BX,05
         CALL DISPL
         CRLF 
         MOV SI,OFFSET DATA1
         MOV BX,05
         CALL DISPL
         CRLF
         MOV DI,OFFSET DATA2
         CALL ADDA
         MOV BX,06
         CALL DISPL
         CRLF
         MOV AX,4C00H
         INT 21H
DISPL    PROC NEAR
DSI:     MOV  AH,02
         MOV  DL,[SI+BX-1]
         INT  21H
         DEC  BX
         JNZ  DSI
         RET
DISPL    ENDP 
ADDA     PROC NEAR
         MOV DX,SI
         MOV BP,DI
         MOV BX,05
AD1:     SUB BYTE PTR[SI+BX-1],30H
         SUB BYTE PTR[DI+BX-1],30H
         DEC BX
         JNZ AD1
         MOV SI,DX
         MOV DI,BP
         MOV CX,06
         CLC
AD2:     MOV AL,[SI]
         MOV BL,[DI]
         ADC AL,BL
         AAA
         MOV [SI],AL
         INC SI
         INC DI
         LOOP AD2
         MOV SI,DX
         MOV DI,BP
         MOV BX,06
AD3:     ADD BYTE PTR[SI+BX-1],30H 
         ADD BYTE PTR[DI+BX-1],30H 
         DEC BX
         JNZ AD3
         RET
ADDA     ENDP
CODE     ENDS
         END START

EM8086软件仿真结果

相加_第1张图片

你可能感兴趣的:(微机原理-汇编语言)