实验4 [bx]与loop的使用

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

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

实验4 [bx]与loop的使用_第1张图片

结论:bx用来索引地址,ax不能用来索引地址。

你可能感兴趣的:(汇编语言(王爽)第三版学习)