I decided to create a small image with multiple nested Extended Partitions to verify that my MBR code indeed did what I advertised it would do.
Using my MPART tool, I gave it a resource input file of:
Filename: "mbr_test.txt"
Code: Select all
out: file="mbr_test.img", spt=63, heads=16 # the image file
mbr: file="mbr.bin" # use "mbr.bin" as the MBR image file
part: base= 1, size=100, type= 1, active=0, last=0
part: base= 101, size=1, type=15, active=0, last=1
part: base= 102, size=1, type= 15, active=0, last=0
part: base= 103, size=1, type=15, active=0, last=0
part: base= 104, size=100, type=1, active=0, last=1
part: base= 204, size=1, type=15, active=0, last=1
part: base= 205, size=1, type=15, active=0, last=1
part: base= 206, size=100, type=1, active=0, last=1
part: base= 306, size=1, type= 15, active=0, last=1
part: base= 307, size=1, type=15, active=0, last=0
part: file="mbr_test.bin", base= 308, size=100, type=1, active=1, last=1
part: base= 408, size=100, type=1, active=0, last=1
Code: Select all
mpart /s:mbr_test.txt
Code: Select all
standard partition (100 sectors)
extended partition
--extended partition
----extended partition
------standard partition (100 sectors)
----extended partition
------extended partition
--------standard partition (100 sectors)
--extended partition
----extended partition
------standard partition (100 sectors) (marked bootable)
----standard partition (100 sectors)
To be able to tell if you succeeded, this also assumes you have a file called "MBR_TEST.BIN" which is simply a bit of code placed in the "bootable" partition to print "Hey, we made it..."
Filename: "mbr_test.asm"
Code: Select all
; assembled with: http://www.fysnet.net/newbasic.htm
outfile 'mbr_test.bin' ; name of the file to create
.model tiny
.code
.186
; seg = 07C0h and offset 0000h
org 00h
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; set up the stack and seg registers (real mode)
mov ax,07C0h ; set our stack, DS, ES
mov ds,ax ;
xor ax,ax ;
mov ss,ax ; first push at 0x07BFE
mov sp,7C00h ; ss = 0x0000, sp = 0x7C00
mov si,offset we_made_it
call display_string
halt: hlt
jmp short halt
we_made_it db 13,10,' ***** We made it...',13,10,0
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; display a string to the screen using the BIOS
; (destroys all registers used)
display_string proc near
mov ah,0Eh ; print char service
xor bx,bx ;
cld
display_loop: ; ds:si = asciiz message
lodsb
or al,al
jz short end_string
int 10h ; output the character
jmp short display_loop
end_string: ret
display_string endp
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; put sig at end of sector
org (200h-2)
dw 0AA55h
.end
Code: Select all
out: file="mbr_test.img", spt=63, heads=16 # the image file
mbr: file="mbr.bin" # use "mbr.bin" as the MBR image file
MBR.BIN being the binary 512-byte assembled code you are testing.
Line 13 being the active partition holding the boot code to show we made it (using filename "MBR_TEST.BIN" as the partitions' contents)
Code: Select all
part: file="mbr_test.bin", base= 308, size=100, type=1, active=1, last=1
You can change the "mbr_test.txt" to have more partitions, deeper nested partitions, or a different active partition just to be sure your code works.
For information on how the MPART tool parses your input file, see the sample file at the URL I gave above.
Hope this helps when testing your MBR code.
Ben
- http://www.fysnet.net/osdesign_book_series.htm