Boot Script Problems

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.
Post Reply
James

Boot Script Problems

Post by James »

I am creating my boot script, but have come across a problem. I am using emu8086, to create/compile my script:

Code: Select all

#make_boot#
org 7c00h      ; set location counter.


; directive to create BOOT file:
#MAKE_BOOT#

; Boot record is loaded at 0000:7C00,
; so inform compiler to make required
; corrections:
ORG 7C00h

; load message address into SI register:
LEA SI, msg

; teletype function id:
MOV AH, 0Eh

print:   MOV AL, [SI]
         CMP AL, 0
         JZ done
         INT 10h   ; print using teletype.
         INC SI
         JMP print

; wait for 'any key':
done:      MOV AH, 0
           INT 16h

; store magic value at 0040h:0072h:
;   0000h - cold boot.
;   1234h - warm boot.
MOV     AX, 0040h
MOV     DS, AX
MOV     w.[0072h], 0000h ; cold boot.
JMP   0FFFFh:0000h    ; reboot!

new_line EQU 100, 10
msg DB  ' ------------------------------------ '
    DB  new_line, '|                                                  |'
    DB  new_line, '|             Trip OS                           |'
    DB  new_line, '|        (c)2006 Created by                |'
    DB  new_line, '|           James Brooks                     |'
    DB  new_line, '|           Dean Hassall                      |'
    DB  new_line, '|                                                  |'
    DB  new_line, ' ------------------------------------ '
    DB  new_line, 'Press any key to reboot', 0


INT 19h        ; reboot
Now, it works etc. But this bit:

Code: Select all

msg DB  ' ------------------------------------ '
    DB  new_line, '|                                                |'
    DB  new_line, '|             Trip OS                         |'
    DB  new_line, '|        (c)2006 Created by              |'
    DB  new_line, '|           James Brooks                   |'
    DB  new_line, '|           Dean Hassall                    |'
    DB  new_line, '|                                                |'
    DB  new_line, ' ----------------------------------- '
    DB  new_line, 'Press any key to reboot', 0
Will not come out as I want it to! When I test it, it has a 'd' after each line?
James

Re:Boot Script Problems

Post by James »

When I emulate my script on the program I use, it works fine. But when I just try it from booting.. It did nothing??
Evertime I try to boot from it I get this:

Code: Select all

boot17-12
Edit: I have sorted the problem with the 'd' appearing.
James

Re:Boot Script Problems

Post by James »

Why cant I boot that from floppy?
Kemp

Re:Boot Script Problems

Post by Kemp »

I can think of two possibilities (assuming the code itself is correct).

First, your boot sector may be loaded at 07C0:0000 rather than 0000:7C00, in which case all the addressing will be off. Second, most BIOSes check for a magic value at the end of the sector to make sure it is valid and not just junk that happens to be on the disk. Your code is missing this.
James

Re:Boot Script Problems

Post by James »

Great so what do I need to add to it?
Kemp

Re:Boot Script Problems

Post by Kemp »

The banner at the top of all the forum pages links to the OSFAQ, which has the following pages that you may want to read through:

Boot Sequence
Baby Step
Rolling Your Own Bootloader
Post Reply