首页 > 解决方案 > 为什么我不能使用寄存器访问 as86 中的内存

问题描述

这些天我正在阅读 Linux 0.11 的源代码。当我尝试修改它并在屏幕上打印一些硬件属性时,出现以下错误as86

make BootImage
as86 -0 -a -o boot/setup.o boot/setup.s
00056 0050           A1         0000                mov ax, [bx]
***** register used as identifier................................^

00056 0050           A1         0000                mov ax, [bx]
**** register used as identifier................................^

00001 errors
00000 warnings
make: *** [Makefile:97:boot/setup]

这是我的代码:

INITSEG=0x9000
!print those information
mov cx,#5
mov bx,#msgs
mov ax,#INITSEG
mov ds,ax

print_words:
mov si,[bx]
call print_msg
add bx,2
loop print_words

print_msg:
push ax
push bx
push cx
push dx

mov ah,#0x03
xor bh,bh
int 0x10

mov cx,[si]
add si,2
mov bx,#0x0007
mov ax,#0x1301
int 0x10

pop dx
pop cx
pop bx
pop ax

ret

msgs:
.word cursor,memory,cyls,heads,sectors
cursor:
.word 0x0012
.byte 13,10
.ascii "Cursor Position:"
memory:
.word 0x0009
.byte 13,10
.ascii "Memory:"
cyls:
.word 0x0007
.byte 13,10
.ascii "Cyls:"
heads:
.word 0x0008
.byte 13,10
.ascii "Heads:"
sectors:
.word 0x000A
.byte 13,10
.ascii "Sectors:"

网上查了一下,找不到原因不能使用bx寄存器访问内存,发现在as86中,我们可以通过[bx]或者[bx + k *的方式访问内存西]。所以我有点困惑。谢谢您的帮助。

标签: assemblyx86-16as86

解决方案


推荐阅读