Message board for the users of flat assembler.
> OS Construction > Performing a warm reboot
Hello all. I have recently just started with FASM; I have to say, it's an excellent assembler.
I am interested in performing a warm reboot on the system -- by reading, I have learned that int 19h is NOT the way to go for this. So after googling a bit, I came across the following page on BIOS interrupts - http://www.xaff.org/GI/biosref.html -- instead of just saying "Do NOT use int 19h", it gave some instructions on performing a warm reboot, which are:
So after doing a bit more reading, I think I found out how to properly follow these instructions and put it into code. This code seems to work, but I don't know if it is entirely correct. The assembly code I have managed to create from these instructions is:
; -- Snippet -- ; mov ax, 0x0040 ; AX = 0x0040 mov es, ax ; ES = AX mov di, 0x0072 ; DI = 0x0072 (our offset is ES:DI) mov ax, 0x1234 ; AX = 0x1234 stosw ; Put AX at ES:DI jmp 0FFFFh:0000h ; Jump to reboot.
Is this correct? I understand that there is a clear difference between 'working' and 'correct'.
This message may not belong under 'OS Construction', but I am working up towards making a small bootloader, so I wasn't sure where to go.
Thanks for any help,
|26 Jul 2005, 16:38||
mov ax, 0040h mov ds, ax mov WORD [0072h], 1234h ; Sets warm boot jmp 0F000h:0FFF0h ; Jump to reset code ; NOTE: 0F000h:0FFF0h and 0FFFFh:0000h are the same address (on real mode) ; The following was taken from ralf brown interrupt list ;MEM 0040h:0072h - POST RESET FLAG ;Size: WORD ;Desc: specify the action the BIOS should take at the beginning of the ; power-on self-test when the machine is reset ;SeeAlso: INT 19,MEM F000h:FFF0h ; ;(Table M0021) ;Values for POST reset flag: ; 0000h cold boot ; 0064h Burn-in mode ; 1234h to bypass memory test (warm boot) ; 4321h [PS/2 except Mod 25,30] to preserve memory ; 5678h [Conv] system suspended ; 9ABCh [Conv] manufacturing test mode ; ABCDh [Conv] POST loop mode ;MEM F000h:FFF0h - RESET JUMP ;Size: 5 BYTEs
Another detail, if you want to make the code smaller (14 bytes instead of 16 bytes) you can change mov ax, 0040h / mov ds, ax to push 0040h / pop ds but this change will be dissasembled incorrectly by the debug command:
168E:0100 6A DB 6A
168E:0101 40 INC AX
6a 40 is the push 0040h. Actually pushing immediates values is not supported by 8086/8088 and maybe it's the reason why debug doesn't display push 0040
Sorry my english it's too bad, just try to understand the code and you will be alright
Last edited by LocoDelAssembly on 27 Jul 2005, 17:40; edited 1 time in total
|27 Jul 2005, 16:24||
This one is one byte less (13 bytes)
push 40h pop ds mov word [0072h], 1234h push 0FFFBh push ds retf
|27 Jul 2005, 17:25||
Thanks for the code locodelassembly; it works perfectly, and is small too.
|27 Jul 2005, 21:27||
If you're making an error handling routine for a boot sector than it is better, i think, to use INT 18h. BIOS developers suggest this to give the control back to BIOS and try to boot the next IPL Device. Take a look at BIOS Boot Specification for more information.
Last edited by zhak on 08 Aug 2005, 16:19; edited 1 time in total
|05 Aug 2005, 22:14||
I took this from ralf brown's interrupt list[/edit]
INT 19 - SYSTEM - BOOTSTRAP LOADER
Desc: This interrupt reboots the system without clearing memory or restoring
interrupt vectors. Because interrupt vectors are preserved, this
interrupt usually causes a system hang if any TSRs have hooked
vectors from 00h through 1Ch, particularly INT 08.
Notes: Usually, the BIOS will try to read sector 1, head 0, track 0 from drive
A: to 0000h:7C00h. If this fails, and a hard disk is installed, the
BIOS will read sector 1, head 0, track 0 of the first hard disk.
This sector should contain a master bootstrap loader and a partition
table (see #00650). After loading the master boot sector at
0000h:7C00h, the master bootstrap loader is given control
(see #00653). It will scan the partition table for an active
partition, and will then load the operating system's bootstrap
loader (contained in the first sector of the active partition) and
give it control.
true IBM PCs and most clones issue an INT 18 if neither floppy nor hard
disk have a valid boot sector
to accomplish a warm boot equivalent to Ctrl-Alt-Del, store 1234h in
0040h:0072h and jump to FFFFh:0000h. For a cold boot equivalent to
a reset, store 0000h at 0040h:0072h before jumping.
INT 18 - DISKLESS BOOT HOOK (START CASSETTE BASIC)
Desc: called when there is no bootable disk available to the system
Notes: very few PCs other than those produced by IBM contain BASIC in ROM, so
the action is unpredictable on compatibles; this interrupt often
reboots the system, and often has no effect at all
some PC and XT clones had an optional IBM CASSETTE BASIC stored
in the ROM, too.
most BIOSes will display an error message similar to "NO BASIC", and
either reboot or return to the caller.
PS/2 machines usually pop up a graphical box to the effect that
the user should enter a floppy and press F1.
Some clones display the message "No boot device available,
strike F1 to retry, F2 for setup utility"
network cards with their own BIOS can hook this interrupt to allow
a diskless boot off the network (even when a hard disk is present
if none of the partitions is marked as the boot partition)
|05 Aug 2005, 23:59||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.
Website powered by rwasa.