三个数之和
求三个数之和。DATA SEGMENT
BUF DW 1234H,2345H,3456H
SUM DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START: mov ax, DATA;数据首地址
mov dx, ax
mov si, offset BUF
mov di, offset SUM
call SUM1
mov ah, 4ch
int 21h
SUM1 proc
mov cl, 3
xor ax, ax
mov ax, [si]
NEXT: add si, 2
add ax,[si]
loop NEXT
mov [di], ax
mov al,byte ptr[di+1];取高字节,为转换为ASCII准备
call dip
mov al,byte ptr[di];取低字节
call dip
ret
SUM1 ENDP
dip proc
mov bl,al ;保存al的数据
and al, 0f0h ;取高4位
mov cl, 04h
shr al, cl
cmp al, 09 ;高四位与9比较
ja aa1
add al,30h ;小于10的加30h
jmp bb1 ;无条件跳转到bb
aa1: add al,37h ;大于10,为十六进制,加37h
bb1: mov dl, al ;显示高字节
mov ah, 02h
int 21h
mov al, bl
and al,0fh ;读取低字节
cmp al, 09h
ja aa2
add al, 30h
jmp bb2
aa2: add al, 37h
bb2: mov dl,al
mov ah,02h
int 21h
ret
dip endp
CODE ENDS
END START
这段程序反汇编时为什么 只执行到mov [di], ax呢,输出结果也是错的,错在哪里?