
; Copyright 2004-2005 Christopher Evans
; email:   tekno1911@yahoo.com
; Website: http://nxdos.sourceforge.net/
;                                                                           ;
;       This program is copyrighted, but may be freely distributed          ;
;       under the terms of the Free Software Foundation's GNU General       ;
;       Public License v2 (or later.)  See the file COPYING for the         ;
;       legalities.  If you did not receive a copy of COPYING, you          ;
;       may request one from the Free Software Foundation, Inc.,            ;
;       59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           ;
;       ABSOLUTELY NO WARRANTY -- use it at your own risk!                  ;
;                                                                           ;

code            segment byte public
                assume  cs:code, ds:code
		org	100h
readb           proc    far

start:          jmp     initialize
include         \nxdos\src\toolbox.asm
                _compile
initialize:
                push  cs
                pop   es

                mov  ah, 2   ; read sector
                mov  al, 1   ; sectors
                mov  ch, 0   ; cylinder 
                mov  cl, 1   ; sector
                mov  dh, 0   ; head
                mov  dl, 80h ; bios drive
                ; ES:BX = receive buffer
                push cs      
                pop  es
                mov  bx, offset readbuffer
                int  13h

                _print message, 1
                _fopen filename, 1, 0, 0
                mov  filehandle, ax
                _fwrite filehandle, readbuffer, 512
                _fclose filehandle
                _newline

exitptr:        call dosexit
                int 20h      

readb           endp

filehandle      dw ?
message         db 'Writing 512 bytes to '
filename        db 'MBR.BSS',0
readbuffer      db      0

code            ends

ProgramEnd      EQU $-01h

		end	start

Partition Table Information and location:

Format of hard disk master boot record:
. Offset  Size    Description
. 000h 446 BYTEs  Master bootstrap loader code
. 1BEh 16 BYTEs   partition record for partition 1 ( Byte definition below )
. 1CEh 16 BYTEs   partition record for partition 2
. 1DEh 16 BYTEs   partition record for partition 3
. 1EEh 16 BYTEs   partition record for partition 4
. 1FEh    WORD    signature, AA55h indicates valid BIOS extension block
.
Format of partition record:
Offset  Size    Description
 00h    BYTE    boot indicator (80h = active, 00H = inactive )
 01h    BYTE    partition start head
 02h    BYTE    partition start sector (bits 0-5)
 03h    BYTE    partition start track (bits 8,9 in bits 6,7 of sector)
 04h    BYTE    operating system indicator (see below)
 05h    BYTE    partition end head
 06h    BYTE    partition end sector (bits 0-5)
 07h    BYTE    partition end track (bits 8,9 in bits 6,7 of sector)
 08h    DWORD   sectors preceding partition
 0Ch    DWORD   length of partition in sectors
