使用 int 21h 输出函数时 AL 和 DL 或 AX 和 DX 之间的关系? [英] Relationship between AL and DL or AX and DX when using int 21h output functions?

查看:42
本文介绍了使用 int 21h 输出函数时 AL 和 DL 或 AX 和 DX 之间的关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是好奇 al 和 dl 的关系,因为当我输入一个字符然后打印另一个字符后打印它时,al 的值突然改变了.这是下面的示例代码.谢谢!

I'm just curious with the relationship of al and dl because when I input a character and later I'll print it after printing a certain another character, the value of al suddenly changed. Here's the sample code below. Thanks!

cseg segment para 'code'
assume cs:cseg; ds:cseg; ss:cseg; es:cseg
org 100h
start: jmp begin

begin:  
mov ax, 03h
int 10h

mov ah, 01h
int 21h

mov ah, 02h
mov dl, '&'
int 21h

mov ah, 02h
mov dl, al
int 21h

int 20h
cseg ends
end start

输出应该是这样的:

(char)&(char)

但是出现的是:

(char)&&

推荐答案

你的问题是中断服务 21h 的函数 02h 在 AL 中返回最后打印字符的 ASCII 码.

Your problem is that function 02h of interrupt service 21h returns in AL the ASCII code of the last printed character.

在您的情况下,当您请求 INT 21h 的服务 02h 打印&"时,寄存器 AL 将被 ASCII 代码&"覆盖.

In your case, when you request service 02h of INT 21h to print '&', register AL will be overwritten with ASCII code '&'.

如果您打算之后使用该值,您应该在调用 INT 21h 的服务 02h 之前将 AL 的内容备份到另一个寄存器(例如 mov cl, al).

You should backup the content of AL to another register (e.g. mov cl, al) before calling service 02h of INT 21h if your intent is to use that value afterwards.

查看参考以了解有关您正在使用的服务的更多信息.

Check this reference for more info on the service you are using.

这篇关于使用 int 21h 输出函数时 AL 和 DL 或 AX 和 DX 之间的关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆