中间变量
M_CRLF MACRO ;回车MOV DL, 0AH
MOV AH,02H
INT 21H
MOV DL, 0DH
MOV AH,02H
INT 21H
ENDM
ws macro z
local aa3 ,bb3 ,aa4 ,bb4
mov dx, cx
mov al, z ; 这里将Z的值赋给了AL,对z
;的值作变化 ,AL没有做改变
and z, 0f0h
mov cl, 04h
shr z, cl
mov cx, dx
cmp z, 09h
ja aa3
add z, 30h
jmp bb3
aa3: add z, 37h
bb3: mov dl, z
mov ah, 02h
int 21h
and al,0fh ; 这里取AL的低字节即要取Z的
;低字节 cmp al,09h
ja aa4
add al, 30h
jmp bb4
aa4: add al, 37h
bb4: mov dl, al
mov ah,02h
int 21h
endm
sum macro x, y
add x, y
ws x
M_CRLF
endm
DATA segment
buf1 db 11h,12h,13h,14h,15h,16h,17h,18h,19h
buf2 db 21h,22h,23h,24h,25h,26h,27h,28h,29h
DATA ends
code segment
assume cs:code , ds:DATA
start: mov ax, DATA
mov ds, ax
mov es, ax
mov si, offset buf1
mov di ,offset buf2
mov cx, 09h
done: mov al, [si]
mov bl, [di]
inc si
inc di
sum al, bl
loop done
mov ah, 4ch
int 21h
code ends
end start
为什么结果会是这样的:
33
33
33
33
33
33
33
44
44
而将这两句改为
MOV BL, Z
MOV AL, BL 结果正确了,为什么不可以对AL 直接取字节,要用一个中间变量呢?