I write some simple codes in call BIOS to print "hello,world !",
compile in nasm.
when I use BOCHS and vmware to emulate ,It has nothing wrong.
but when use real PC to boot ,It just display nothing, but hang .
could somebody tell me what theproblem is
and how to correct it?
thx a lot .
here are the codes:
[bits 16]
[org 0x7c00]
;set the screen to text mode
mov al,3
mov ah,0
int 10h
;clear screen
mov cx,80*25
mov al,' '
mov bl,1eh ;use yellow in blue lettering
mov ah,09h
int 10h
;display the message
mov bp,msg
mov cx,len
mov dx,0 ;display on (0,0)
mov al,0 ;make cursor return
mov bl,1eh
mov ah,13h ;call BIOS
int 10h
loop1: jmp loop1
msg db 'Hello,world !'
len equ $-msg
times 510-($-$$) db 0
dw 0xaa55
some problem in BIOS call
Re:some problem in BIOS call
First problem I see is that you assume ES = 0 at boot (Int 10h, 13h uses es:bp as pointer to the string). This is not guaranteed to be the case on real hardware. Throw
In there somewhere before the call to BIOS write string function and see if it works better.
Second problem is pretty much the same as the first. You never actually set BH = 0 (Or to anything else for that matter), so you're relying on BH being set to 0 before the bootsector is loaded. This is unlikely to be universally true, so it's possible something is being written, just not on the visible page.
You should never assume that a register holds something sensible unless you were the one to set its value. The only real exception is that BIOS will pass the drive number to your bootsector code in DL, everything else should be treated as an unknown (Because the register contents handed to the bootsector by individual BIOS varies hugely).
Code: Select all
xor ax, ax
mov ds, ax
mov es, ax
Second problem is pretty much the same as the first. You never actually set BH = 0 (Or to anything else for that matter), so you're relying on BH being set to 0 before the bootsector is loaded. This is unlikely to be universally true, so it's possible something is being written, just not on the visible page.
You should never assume that a register holds something sensible unless you were the one to set its value. The only real exception is that BIOS will pass the drive number to your bootsector code in DL, everything else should be treated as an unknown (Because the register contents handed to the bootsector by individual BIOS varies hugely).