Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
ollie123
Member
Posts: 26 Joined: Tue May 27, 2008 2:42 am
Location: Great Yarmouth, Norfolk, United Kingdom
Post
by ollie123 » Sat Jun 14, 2008 2:56 pm
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.
ollie123
Member
Posts: 26 Joined: Tue May 27, 2008 2:42 am
Location: Great Yarmouth, Norfolk, United Kingdom
Post
by ollie123 » Sat Jun 14, 2008 2:59 pm
BTW: I will actually add the code to load the kernel later.
suthers
Member
Posts: 672 Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:
Post
by suthers » Sat Jun 14, 2008 3:04 pm
If you're using int 0x10 with AH = 0x09, you have to move the page number into BH = 0...
Jules
inflater
Member
Posts: 1309 Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:
Post
by inflater » Sat Jun 14, 2008 3:05 pm
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
Blue
Member
Posts: 31 Joined: Thu Aug 02, 2007 6:34 am
Location: on the stack
Post
by Blue » Sat Jun 14, 2008 3:12 pm
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
CmpXchg
Member
Posts: 61 Joined: Mon Apr 28, 2008 12:14 pm
Location: Petrozavodsk, Russia during school months, Vänersborg Sweden in the summertime
Post
by CmpXchg » Sun Jun 15, 2008 1:25 am
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
ollie123
Member
Posts: 26 Joined: Tue May 27, 2008 2:42 am
Location: Great Yarmouth, Norfolk, United Kingdom
Post
by ollie123 » Sun Jun 15, 2008 2:20 am
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!
suthers
Member
Posts: 672 Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:
Post
by suthers » Sun Jun 15, 2008 2:28 am
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
ollie123
Member
Posts: 26 Joined: Tue May 27, 2008 2:42 am
Location: Great Yarmouth, Norfolk, United Kingdom
Post
by ollie123 » Sun Jun 15, 2008 3:18 am
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.
suthers
Member
Posts: 672 Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:
Post
by suthers » Sun Jun 15, 2008 3:55 am
Free cookies WHERE?!
Jules