Problem with real mode
Posted: Sun Nov 21, 2010 12:34 pm
Hello, I'm new of this forum!
I have a problem with a boot program. This must print to the video the string "HELLO WORD", but don't show nothing! I think it's the fault of the addresing of memory because the code is executed correctly.
Thi is the my makefile :
The script for the linking is :
I Have try also only . = 0x07c0, but the result is the same!
thanks..
Sorry for my bad English..
I have a problem with a boot program. This must print to the video the string "HELLO WORD", but don't show nothing! I think it's the fault of the addresing of memory because the code is executed correctly.
Code: Select all
.code16 # code 16 bit
.set SEG_BOOT, 0x07c0
.set INIT_STACK, 0x400
.text
movw $SEG_BOOT, %ax # caricamento di valori noti nei registri
movw %ax, %ds # data selector
movw %ax, %es
cli #disable interrupt because change the stack
movw %ax, %ss
movw $INIT_STACK, %sp # begin stack a 0x07c0:0400, cioe'
sti
movw $mess, %si # address of the first char on the si
movb $0x0e, %ah # print char
movb $0, %bh # number of paging
nuovo_car:
lodsb # load char to the al
cmpb $0, %al # test if it is the last
je fine
int $0x10 # print
jmp nuovo_car
fine: jmp fine # loop
mess : .asciz "Hello word"
.org 510
sign: .byte 0x55 # signature per un settore di avviamento valido
.byte 0xaa
Code: Select all
all: test.fd
test.fd: test.sect
dd if=/dev/zero bs=512 count=2879 | cat test.sect - > test.fd
test.sect: test.bin
objcopy -O binary test.bin test.sect
test.bin : test.o
ld test.o -m elf_i386 -Tldscript -o test.bin -M > test.map
test.o: test.s
as test.s -o test.o -g --32
clean :
rm test.fd test.o test.bin test.sect
qemu :
qemu -fda test.fd
Code: Select all
SECTIONS
{
. = 0x07c0; /* indirizzo di partenza */
.text :
{
_text = . ;
*(.text)
*(.rodata)
. = ALIGN(4096);
}
.data :
{
_data = . ;
*(.data)
. = ALIGN(4096);
}
.bss :
{
_bss = . ;
*(.bss)
. = ALIGN(4096);
_end = . ;
}
}
thanks..
Sorry for my bad English..