I am reading Linux 0.11's source code these days.And when I tried to modify it and print some hardware's properties on the screen, there are errors from 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]
And here is my code:
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:"
I have checked them online but I can't find the reason why I can't use bx register to access memory, and I have found that in as86, we can access memory by the way of [bx] or [bx + k * si]. So I'm a little confused. Thank you for your help.