;*****************************
;MBR Save Utility 
;*****************************
;by Evil-E [CodeBreakers]

MODEL TINY
CODESEG
STARTUPCODE

mov     ah,9              ; display copyright message :-)
mov     dx,offset msg
int     21h

xor     ax,ax             ; reset disk system
mov     dl,80h
int     13h

mov     bp,4              ; read bootsector 4 times ...
read:
mov     ax,201h           ; read sector
mov     dx,0080h          ; head 0, harddisk
mov     cx,1              ; track 0, sector 1
mov     bx, offset buffer
int     13h
dec     bp
jnz     read

mov     ax,3c00h          ; create file
xor     cx,cx
mov     dx,offset file
int     21h
xchg    bx,ax            ; move filehandle into BX

mov     ah,40h           ; write bootsector into file boot.bin
mov     cx,512
mov     dx,offset buffer
int     21h
jc      error_writing

mov     ah,3eh           ; close file
int     21h
int     20h              ; return to DOS ...

error_writing:
mov    ah,9              ; display error message
mov    dx,offset error
int    21h
int    20h               ; return to DOS ...

file   db  'BOOT.BIN',0
msg    db  'SAVE Version 1.0 by Evil-E [CB] (c) 1998',13,10
       db  '----------------------------------------',13,10
       db  'Writing bootsector to boot.bin ...$'
error  db  'ERROR: Can''t write bootsector to boot.bin$',13,10
buffer db  512 dup (0)     ; for saving boot sector in

END 
