您的位置:首页 > 运维架构

实验4 [bx]与loop的使用

2017-04-21 22:57 337 查看
做这个实验时我认为小菜一碟,认为很快就会搞定,但是等我编好程序,编译连接的时候出现了问题,我摸不着头脑,不知道问题出现在哪里,下面时出现问题的程序:

assume cs:codesg
codesg segment
mov ax,20h
mov ds,ax

mov bx,0
mov ax,0
mov cx,64

s:mov [ax],bl;attention, ax can not be index
inc ax
inc bx
loop s

mov ax,4c00H
int 21H
codesg ends
end


出现的编译问题:



其中显示mov [ax],bl出现错误,这到底是怎么回事,我看了半天,没有语法错误。于是找度娘打听情况,网上有人说是因为bx一般用来索引地址,而ax一般用来存储中间变量,于是我改了一下寄存器的使用,用bx来索引内存地址,编译后未出错。

assume cs:codesg
codesg segment
mov ax,20h
mov ds,ax

mov bx,0
mov ax,0
mov cx,64

s:mov [bx],al;attention, ax can not be index
inc ax
inc bx
loop s

mov ax,4c00H
int 21H
codesg ends
end




结论:bx用来索引地址,ax不能用来索引地址。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  汇编语言 AX BX 索引