        .286c

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

writeb          proc    far
start:          jmp     main
include         \nxdos\src\toolbox.asm
                _compile
main:
                mov     ax, 3D00h
                mov     dx, offset nxbootfile    ;  open file, al=mode,name@ds:dx
                int     21h                     
                jc      tryregular
                jmp     loadsuccess
tryregular:
                mov     ax, 3D00h
                mov     dx, offset bootfile      ;  open file, al=mode,name@ds:dx
                int     21h                     
                jc      error 
loadsuccess:
                mov     bx, ax
                mov     ah, 3Fh                 
                mov     cx, 200h                ;  read file, bx=file handle
                mov     dx, offset writebbuffer 
                int     21h                     
                jc      error                                

                mov     ah,0                   
                mov     dl,0                   
                int     13h               
                                          
                mov     ah,3                   
                mov     al,1                    ;  write sectors from mem es:bx
                mov     cx,1                   
		mov	dx,0
                mov     bx,offset writebbuffer
                int     13h                     

                xor     ah,ah 
                jnz     error                   ; Jump if not zero
                jmp     exit
error:
                _doswrite errormsg

exit:           call dosexit
                int 20h 

writeb          endp

databyte        db      0
errormsg        db      'Error$'
bootfile        db      'METAKERN.BSS', 0
nxbootfile      db      'NXDOS.BSS', 0
writebbuffer    db      0

code   ends
ProgramEnd      EQU $-01h
		end	start
