汇编语言输出单个字符时避免不了用int 21h的2号功能输出,2号功能使用很简单,只需要将ah赋值为2,并且将要输出的值放入dl中即可。并没有涉及到al的问题,但是我发现每次使用完一次2号功能后,al的值会变为dl的值。
看代码
data SEGMENT
VAR DW ?
data ENDS
code SEGMENT
ASSUME CS:CODE,DS:DATA
start:
mov al,30h
;这里输出一下4
mov dl,34h
mov ah,02h
int 21h
xor dl,dl
mov dl,al
mov ah,02h
int 21h
code ENDS
END start
输出结果
如果int 21h并没有对al造成影响那么应输出40才对
当我删掉中间那一个int 21h之后
data SEGMENT
VAR DW ?
data ENDS
code SEGMENT
ASSUME CS:CODE,DS:DATA
start:
mov al,30h
mov dl,34h
mov ah,02h
;int 21h
xor dl,dl
mov dl,al
mov ah,02h
int 21h
code ENDS
END start
输出结果: