flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Customizable "Press key to reboot" boot sector

Author
Thread Post new topic Reply to topic
The Lightning Stalker



Joined: 07 Jun 2006
Posts: 11
The Lightning Stalker
Hello. Using some of the information on this site, I made a boot sector that can be used on CDs or floppies and thought I'd share it with you. I made it for a set of ghost CDs I made for a customer. Disc 1 boots ghost and disc 2-x boot into this boot sector and say:

Quote:
The CD in your drive is not bootable.
Please insert disc 1 to reload the system or remove this one to boot into
Windows.

Press any key to reboot._


The disc is ejected and the droor closed automatically after a key is pressed, then the system is rebooted.

Here is the code. You can make it say whatever you want.

Code:
;******************************
; Press any key to reboot v2.0
; For flat assembler
; By Robert Dvoracek
;******************************
 include 'Ata_Atapi.inc'                   ; Use Craig Bamford's library
                                           ; for CD Eject functions
 Load_Segment equ 7C00h

 org Load_Segment                          ; 7C00h does it for boot sectors
use16
;******************************
; Realmode startup code.
;******************************
start:
        xor  ax,ax
        mov  ds,ax
        mov  es,ax
        mov  ss,ax
        mov  sp,Load_Segment
;******************************
; Print message.
;******************************
        mov   si,Message                   ; Point si to Message
        call  print                        ; Call subroutine to print message
;******************************
; Eject and wait for key press.
;******************************
        call Eject_cd                      ; Call subroutine in Ata_Atapi.inc
        mov  ah,10h                        ; Read a keypress using extended
        int  16h                           ; keyboard to include F11 & F12
        call Close_cd                      ; Call subroutine in Ata_Atapi.inc
;******************************
; Reboot.
;******************************
        push   40h                         ; Move 40h
        pop    ds                          ; Into ds
        mov    word [0072h], 1234h         ; 1234h for warm reboot, 0000h for cold
        push   0FFFBh                      ; 4 less than FFFF where we're going
        push   ds                          ; +40h to FFFF:0000. Genius loco, genius!
        retf                               ; Blamo
;******************************
; Sub print.
;******************************
print:
        mov   ah,0Eh                       ; Request display
again1:
        lodsb                              ; load a byte into AL from DS:SI
        or   al,al                         ; See if it's a zero
        jz   done1                         ; Jump to label done1 if it is
        int  10h                           ; Call interrupt service
        jmp  again1                        ; Jump to label again1
done1:
        ret                                ; Return
;******************************
; Strings
;******************************
 Message db "The CD in your drive is not bootable.", 0Dh, 0Ah,\
 "Please insert disc 1 to reload the system or remove this one to boot ",\
 "into", 0dh, 0ah,\
 "Windows.", 0Dh, 0Ah,\
 0Dh, 0Ah,\
 "Press any key to reboot.", 0
;******************************
; Make program 510 bytes +
; 0xAA55
;******************************
times 510- ($-start)  db 0                 ; Fill current offset-start-510 with zeros
dw 0xAA55                                  ; Put magic number at end to get 512 Bytes    

Version History:

Original Release: Originally I had to put in ## and then edit the compiled binary in a hex editor to get carriage returns.
v1.0: With some help from WiESi this was fixed.
v2.0: Disc eject routines added with help from Dex4u

Take care,
The Lightning Stalker


Description: Source code, a preassembled boot sector and instructions.
Download
Filename: Press any key to reboot.zip
Filesize: 2.83 KB
Downloaded: 56 Time(s)



Last edited by The Lightning Stalker on 29 Feb 2008, 19:25; edited 5 times in total
Post 07 Jun 2006, 22:43
View user's profile Send private message Reply with quote
WiESi



Joined: 15 May 2006
Posts: 14
Location: Austria
WiESi
Normally this should work:
Code:
msg0 db 'The CD in your drive is not bootable.', 0dh, 0ah, 'Please insert disc 1 or eject this one to boot into Windows.', 0dh, 0ah, 0dh, 0ah, 'Press any key to reboot.'    
Post 08 Jun 2006, 07:47
View user's profile Send private message Visit poster's website Reply with quote
The Lightning Stalker



Joined: 07 Jun 2006
Posts: 11
The Lightning Stalker
Aha, thank you WiESi. Smile I don't know why it wasn't working earlier, but it's working now. Rolling Eyes I'm making several other "improvements" which I'll edit into the original post, unless you prefer I post again.
Post 08 Jun 2006, 09:41
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
You could try something like this, as it opens the cd draw and closes it before reboot.
Code:
org 0x7C00use16;****************************; Realmode startup code.;****************************start:        xor   ax,ax        mov   ds,ax        mov   es,ax        mov   ss,ax        mov   sp,0x7C00;*************************************; Print message.;*************************************        mov  si,msg0        call  print        call Eject_cd        xor   ax,ax        int   16h        call  Close_cdReBootMe:       db 0xea       dw 0x0000       dw 0xffff       jmp $;====================================================;;  print.                                            ;;====================================================;print:        mov   ah,0Eh                       ; Request displayagain1:        lodsb                              ; load a byte into AL from DS:SI        or   al,al                         ; Or AL        jz   done1                         ; Jump 0, to label done1        int  10h                           ; Call interrupt service        jmp  again1                        ; Jump to label again1done1:        ret                                ; Returninclude 'Ata_Atapi.inc' msg0 db "Please insert disc 1 and press anykey to reboot.",0;*************************************; Make program 510 byte's + 0xaa55;*************************************times 510- ($-start)  db 0dw 0xaa55    

NOTE: you need to use "'Ata_Atapi.inc" and also may a delay of about 2seconds between Close_cd and ReBootMe.


Description:
Download
Filename: Ata_Atapi.inc
Filesize: 6.62 KB
Downloaded: 88 Time(s)

Post 08 Jun 2006, 11:30
View user's profile Send private message Reply with quote
The Lightning Stalker



Joined: 07 Jun 2006
Posts: 11
The Lightning Stalker
Dex4u: I tried that on this computer here and it just sits with a blinking cursor. I'd know for sure if it had a floppy drive :/
Post 08 Jun 2006, 13:49
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
'@The Lightning Stalker, It works fine on the 3 PC i have tryed it on, try puting a
Code:
     mov  si,msg0        call  print        xor   ax,ax  ;***here ***        int   16h  ;***here ***        call Eject_cd        xor   ax,ax        int   16h        call  Close_cd    

To see if it prints message, as its the same code as before so should print message, but have only tested it from floppy.

PS: Maybe you need to stop emulation for this to work from cd ?.
and call something like this http://lrs.uni-passau.de/support/doc/interrupt-57/RB-0680.HTM
Post 08 Jun 2006, 14:06
View user's profile Send private message Reply with quote
The Lightning Stalker



Joined: 07 Jun 2006
Posts: 11
The Lightning Stalker
That's strange. I tried on 2 here, one from CD and one from floppy. Maybe I'm not including your ATAPI library properly or something.

Quote:
'@The Lightning Stalker, It works fine on the 3 PC i have tryed it on, try puting a


Okay, I'll try it.
Post 10 Jun 2006, 05:08
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
Here is the bin file, my code, the tools for puting on floppy.

I can if you want make a better one that test for drive address, as that one just gess it ( about 70% right ).


Description:
Download
Filename: OpenCD.zip
Filesize: 12.06 KB
Downloaded: 63 Time(s)

Post 10 Jun 2006, 12:04
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.