Page 1 of 1
Code Will Not Function.
Posted: Sat Jun 14, 2008 2:56 pm
by ollie123
Hello there, I am having a slight problem. I am developing an OS called Project X5. However, when I run it, I do not get any output. This is the contents of my bootsector, BOOT.SYS:
Code: Select all
[BITS 16]
[ORG 0x7C00]
jmp start
loadmessage DB "Project X: Version 1", 0
loadmessage2 DB "Loading Project X Kernel..." , 0
start:
mov si, loadmessage
call print
mov si, loadmessage2
call print
cli
hlt
print:
lodsb
or al, al
jz printdone
mov ah, 09h
mov bl, 0x07
int 10h
xor ah, ah
xor bl, bl
jmp print
printdone:
ret
TIMES 510 - ( $-$$ ) DB 0
DW 0xAA55
All this does is halts the system! Can you please tell me how to fix this, or point me in the right direction, as I have read many tutorials.
Thanks.
Posted: Sat Jun 14, 2008 2:59 pm
by ollie123
BTW: I will actually add the code to load the kernel later.
Posted: Sat Jun 14, 2008 3:04 pm
by suthers
If you're using int 0x10 with AH = 0x09, you have to move the page number into BH = 0...
Jules
Posted: Sat Jun 14, 2008 3:05 pm
by inflater
Add this right after the start label:
And after that,it's good to set the stack.
@suthers: BX is 0 after the bootup.
Regards
inflater
Posted: Sat Jun 14, 2008 3:12 pm
by Blue
Hi..
I'm not sure, but I don't see anywhere where you set DS which is used for lodsb (al = DS:[SI])..
Also you use the interrupt int 10h with AH = 09h, and what I read from Ralf Brown's interrupt list is that you also need to state CX as the number of time the character shall be displayed (on some systems this is ignored)..
So I guess you should add this to your code:
Code: Select all
start:
push cs
pop ds
mov si, loadmessage
Of course i might be wrong since I'm also new, so anyone feel free to correct me..
Edit: Two people beat me to it
Blue
Posted: Sun Jun 15, 2008 1:25 am
by CmpXchg
I'd suggest function 0Eh for printing. Instead of
Code: Select all
mov ah, 09h
mov bl, 0x07
int 10h
xor ah, ah
xor bl, bl
you could try to put
And yes, set up DS & ES, and SS too:
Code: Select all
xor ax,ax
mov ds,ax
mov es,ax
mov ss,ax
mov sp,7C00h
Did it helped?
Cheers,
CmpXchg
Posted: Sun Jun 15, 2008 2:20 am
by ollie123
Ok, I've updated my code to the following:
Code: Select all
[BITS 16]
[ORG 0x7C00]
jmp start
loadmessage DB "Project X: Version 1", 0
loadmessage2 DB "Loading Project X Kernel..." , 0
start:
call setup
mov si, loadmessage
call print
mov si, loadmessage2
call print
cli
hlt
print:
lodsb
or al, al
jz printdone
mov ah,0Eh
int 10h
jmp print
printdone:
ret
setup:
xor ax,ax
mov ds,ax
mov es,ax
mov ss,ax
mov sp,7C00h
ret
TIMES 510 - ( $-$$ ) DB 0
DW 0xAA55
But it still won't function!
Posted: Sun Jun 15, 2008 2:28 am
by suthers
If you wan to use INT 10h with 0Eh, try this code:
Code: Select all
PutStr:
mov ah,0x0E
mov bh,0x00
mov bl,0x07
.nextchar:
lodsb
or al,al
jz .return
int 0x10
jmp .nextchar
.return:
ret
It's what I use in my OS, so I know it works.
Jules
Posted: Sun Jun 15, 2008 3:18 am
by ollie123
suthers wrote:If you wan to use INT 10h with 0Eh, try this code:
Code: Select all
PutStr:
mov ah,0x0E
mov bh,0x00
mov bl,0x07
.nextchar:
lodsb
or al,al
jz .return
int 0x10
jmp .nextchar
.return:
ret
It's what I use in my OS, so I know it works.
Jules
Brilliant! This code works fine. Have a free cookie.
Posted: Sun Jun 15, 2008 3:55 am
by suthers
Free cookies WHERE?!
Jules