DOS6.0 source program of the hard disk boot record source program Fdboot.asm

Source: Internet
Author: User
Tags count relative

;/*
; * Microsoft Confidential
; * Copyright (C) Microsoft Corporation 1983-1991
; * All Rights Reserved.
; */
; BOOT-IBM hard disk boot record 6/8/82
;
;
; This is the standard boot record, that'll be shipped on all hard disks. It contains:
;
; 1. Code to load (and give control to) the boot record for 1 of 4 possible
; Operating systems.
;
; 2. A partition table at the "End of" The boot record, followed by the required signature.
;
;
_data Segment Public
Assume Cs:_data,ds:_data
ORG 600h

CLI; no interrupts for now
XOR Ax,ax
MOV Ss,ax
mov sp,7c00h new stack at 0:7C00
mov si,sp; where this boot record starts-0:7c00
Push AX
Pop es; seg regs the same
Push AX
Pop ds
STI; interrupts OK now
Cld
mov di,0600h; Where to relocate the This boot record to
MOV cx,100h
REPNZ MOVSW relocate to 0:0600
; JMP Entry2
DB 0eah
DW $+4,0
Entry2:
mov si,offset tab;p artition table
MOV bl,4 number of table entries
Next
CMP byte ptr[si],80h is this a bootable entry?
JE Boot; yes
CMP byte ptr[si],0 No, is boot indicator zero?
Jne bad; No, it must being X "or" x "to be valid
Add si,16 Yes, go to next entry
Dec BL
JNZ Next
int 18h; no bootable entries-go to ROM basic
Boot
mov Dx,[si]; head and drive to boot
mov cx,[si+2]; cyl, sector to boot from
MOV Bp,si Save table entry to the partition boot record
NEXT1:
Add si,16 Next Table entry
Dec BL; # entries Left
JZ Tabok entries look OK
CMP byte ptr[si],0 All remaining entries should begin with zero
Je next1; this one is OK
Bad
MOV si,offset M1 oops-found a Non-zero entry-the table is bad
Msg
LODSB get a message character
CMP al,0
Je hold
Push SI
MOV bx,7
MOV ah,14
int 10h; display it
Pop si
JMP msg;d o the entire message
;
HOLD:JMP hold spin here-nothing more Todo
Tabok:
mov di,5; retry count
Rdboot:
mov bx,7c00h; Where to read system boot record
MOV ax,0201h read 1 sector
Push di
int 13h; Get the boot record
Pop di
Jnc goboot; Successful-now Give it control
XOR Ax,ax; Had an error, so
int 13h; recalibrate
Dec di; Reduce retry count
JNZ rdboot If retry count above zero, go retry
mov si,offset m2 all retries done-permanent error-point to message,
JMP msg; go display message and loop
Goboot:
mov si,offset m3;p repare for invalid boot record
MOV Di,07dfeh
CMP word ptr [di],0aa55h;d oes the boot record have the
; Required signature?
Jne msg; No, display invalid system boot record message
MOV si,bp Yes, pass partition table entry address
DB 0eah
DW 7c00h,0

Include FDISK5.CL1

ORG 7beh
tab:;p artition table
DW 0,0;p artition 1 begin
DW 0,0;p artition 1 End
DW 0,0;p artition 1 relative sector (low, high parts)
DW 0,0;p artition 1 # of sectors (low, high parts)
DW 0,0;p artition 2 begin
DW 0,0;p artition 2 End
DW 0,0;p artition 2 relative sector
DW 0,0;p artition 2 # of Sectors
DW 0,0;p artition 3 begin
DW 0,0;p artition 3 End
DW 0,0;p artition 3 Relative sector
DW 0,0;p artition 3 # of Sectors
DW 0,0;p artition 4 begin
DW 0,0;p artition 4 End
DW 0,0;p artition 4 Relative sector
DW 0,0;p artition 4 # of Sectors
Signa db 55h,0aah; signature

_data ends
End

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.