home *** CD-ROM | disk | FTP | other *** search
- .radix 16
- public _boot_code,_bcode_len
-
- lowseg segment at 0
- org 7fe
- signature dw ?
- lowseg ends
-
- _DATA segment
- assume CS:_DATA, DS:lowseg, ES:lowseg
- _boot_code:
- xor ax,ax
- mov es,ax
- mov ds,ax
- cli
- mov ss,ax
- mov sp,7c00
- mov si,sp
- sti
- cld
- mov di,0600
- mov cx,100
- rep movsw
- ; what we WANT to do is "jmp 0:(600 + (offset did_move))" -- I can't
- ; get MASM to do this.
- DB 0EA
- dw 600+(offset did_move - offset _boot_code)
- dw 0
- did_move:
- mov dx,600+(offset no_sig - offset _boot_code)
- cmp signature,0aa55
- jne error
- mov si,7be
- mov cx,4
- mov di,0
- mov dx,600+(offset inv_table - offset _boot_code)
- check_loop:
- lodsb
- or al,al ; if zero, ignore
- jz check_next
- cmp al,80 ; if not zero, only 80 is allowed
- jne error
- or di,di ; if not zero, we have two bootable partitions
- jne error
- mov di,si ; save ptr to bootable system and continue
- check_next:
- add si,0f ; bump partition pointer
- loop check_loop ; and scan next partition, if any
- or di,di ; checked all. do init if we got a valid boot partition
- jnz do_init
- int 18 ; else invoke ROM BASIC
- error:
- mov ah,0e ; "tty write"
- wr_err: lodsb
- or al,al
- jz did_err
- int 10
- jmp short wr_err
- did_err:
- mov al,0dh
- int 10
- mov al,0a
- int 10
- do_zip:
- jmp short do_zip
-
- do_init:
- mov si,di
- dec di
- lodsb
- mov dh,al
- mov dl,80
- mov bx,7c00
- mov cx,5
- try_read:
- push cx
- mov cx,[si]
- mov ax,201
- int 13
- pop cx
- jnc go_boot
- cmp al,11 ; data corrected
- je go_boot
- loop try_read
-
- mov dx,(offset ld_err - offset _boot_code)
- jmp short error
-
- go_boot:
- db 0ea,00,7c,00,00 ; jmp 0:7c00
- inv_table db "Invalid partition table",0
- ld_err db "Error loading operating system",0
- no_sig db "Missing operating system",0
-
- _bcode_len dw $-(offset _boot_code)
-
- _DATA ends
- end
-