home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / msdos / latrobe / b / biodif.arc / MSBOOT.DIF < prev    next >
Text File  |  1987-06-23  |  25KB  |  725 lines

  1. ************
  2. File MSBOOT.OLD;1
  3.    44   ;
  4. ******
  5. File MSBOOT.ASM;1
  6.    44   ;    RGT    16 Jan 1986    Modify it to use hard disk information
  7.    45   ;                when booting from hard disk.
  8.    46   ;
  9. ************
  10. ************
  11. File MSBOOT.OLD;1
  12.   119   F_MAX_FAT_SECTORS    EQU    3        ;Assume 3 sectors per FAT
  13.   120   F_MAX_NUM_FATS        EQU    2        ;2 FATs on disk
  14.   121   F_SECTOR_SIZE        EQU    512        ;Sector size
  15.   122   F_CLUSTER_SIZE        EQU    1        ;Cluster size
  16.   123   F_MAX_SECT_PER_TRACK    EQU    10        ;Normal sectors
  17.   124   F_MAX_SURFACES        EQU    1        ;Number of surfaces
  18.   125   ;
  19. ******
  20. File MSBOOT.ASM;1
  21.   121   F_NUM_FAT_SECTORS    EQU    3        ;Assume 3 sectors per FAT
  22.   122   F_NUM_FATS        EQU    2        ;2 FATs on disk
  23.   123   F_SECTOR_SIZE        EQU    512        ;Sector size
  24.   124   F_CLUSTER_SIZE        EQU    1        ;Cluster size
  25.   125   F_SECT_PER_TRACK    EQU    10        ;Normal sectors
  26.   126   F_NUM_SURFACES        EQU    1        ;Number of surfaces
  27.   127   F_NUM_RESERVED_SECTORS    EQU    20        ;Number of reserved sectors
  28.   128   F_NUM_DIR_SECTORS    EQU    6        ;Number of directory sectors
  29.   129   F_DENSITY_TYPE        EQU    FDISK_RAINB    ;Disk density code
  30.   130   ;
  31.   131   ;   Define some sizes for the double-sided floppy disks
  32.   132   ;
  33.   133   F2_NUM_FAT_SECTORS    EQU    5        ;Assume 5 sectors per FAT
  34.   134   F2_NUM_FATS        EQU    2        ;2 FATs on disk
  35.   135   F2_SECTOR_SIZE        EQU    512        ;Sector size
  36.   136   F2_CLUSTER_SIZE        EQU    1        ;Cluster size
  37.   137   F2_SECT_PER_TRACK    EQU    10        ;Normal sectors
  38.   138   F2_NUM_SURFACES        EQU    2        ;Number of surfaces
  39.   139   F2_NUM_RESERVED_SECTORS    EQU    20        ;Number of reserved sectors
  40.   140   F2_NUM_DIR_SECTORS    EQU    7        ;Number of directory sectors
  41.   141   F2_DENSITY_TYPE        EQU    FDISK_RAINB+FDISK_DSIDE    ;Disk density code
  42.   142   ;
  43. ************
  44. ************
  45. File MSBOOT.OLD;1
  46.   128   H_MAX_FAT_SECTORS    EQU    6        ;Assume 3 sectors per FAT
  47.   129   H_MAX_NUM_FATS        EQU    2        ;2 FATs on disk
  48.   130   H_SECTOR_SIZE        EQU    512        ;Sector size
  49.   131   H_CLUSTER_SIZE        EQU    4        ;Cluster size
  50.   132   H_MAX_SECT_PER_TRACK    EQU    16        ;Normal sectors
  51.   133   H_MAX_SURFACES        EQU    8        ;Number of surfaces
  52.   134   H_NUM_RESERVED_SECTORS    EQU    48        ;Number of reserved sectors
  53.   135   H_PRECOMP_VALUE        EQU    50        ;Precomp value
  54.   136   ;
  55. ******
  56. File MSBOOT.ASM;1
  57.   145   H_NUM_FAT_SECTORS    EQU    12        ;Assume 12 sectors per FAT
  58.   146   H_NUM_FATS        EQU    2        ;2 FATs on disk
  59.   147   H_SECTOR_SIZE        EQU    512        ;Sector size
  60.   148   H_CLUSTER_SIZE        EQU    4        ;Cluster size
  61.   149   H_SECT_PER_TRACK    EQU    16        ;Normal sectors
  62.   150   H_NUM_SURFACES        EQU    8        ;Number of surfaces
  63.   151   H_NUM_RESERVED_SECTORS    EQU    32        ;Number of reserved sectors
  64.   152   H_NUM_DIR_SECTORS    EQU    16        ;Number of directory sectors
  65.   153   H_PRECOMP_VALUE        EQU    50        ;Precomp value
  66.   154   ;
  67.   155   ;   Define the maximum sector size for allocating buffers
  68.   156   ;
  69.   157   MAX_SECTOR_SIZE        EQU    512
  70.   158   ;
  71. ************
  72. ************
  73. File MSBOOT.OLD;1
  74.   158   ;
  75. ******
  76. File MSBOOT.ASM;1
  77.   180   
  78.   181   ;
  79. ************
  80. ************
  81. File MSBOOT.OLD;1
  82.   167   ;    The FORMAT command looks for the following instructions on
  83. ******
  84. File MSBOOT.ASM;1
  85.   190   ;
  86.   191   ;    The hard disk bootstrap looks at the first byte
  87.   192   ;    of the MS-DOS boot code.
  88.   193   ;    If it is not a JMP instruction, it will not boot.
  89.   194   ;
  90.   195   ;    The FORMAT command looks for the following instructions on
  91. ************
  92. ************
  93. File MSBOOT.OLD;1
  94.   180   ;
  95.   181       JMP    START            ;And jump to start code
  96.   182       NOP                ;NOP for space for CLI instruction
  97.   183   ;
  98. ******
  99. File MSBOOT.ASM;1
  100.   208   ;    Since this will first be written to the floppy, set up for floppy.
  101.   209   ;
  102.   210       CLI                ;Disable interrupts
  103.   211       JMP    START            ;And jump to start code
  104.   212   ;
  105. ************
  106. ************
  107. File MSBOOT.OLD;1
  108.   233   READ_AREA    DB    H_SECTOR_SIZE DUP(0)
  109.   234   ;
  110. ******
  111. File MSBOOT.ASM;1
  112.   262   READ_AREA    DB    MAX_SECTOR_SIZE DUP(0)
  113.   263   ;
  114. ************
  115. ************
  116. File MSBOOT.OLD;1
  117.   247   DISK_CMD_DENSITY DB    0        ;Disk density (Not used)
  118.   248   DISK_CMD_GAPLEN    DB    0        ;Gap length (Not used)
  119. ******
  120. File MSBOOT.ASM;1
  121.   276   DISK_CMD_DENSITY DB    F_DENSITY_TYPE    ;Disk density code
  122.   277   DISK_CMD_GAPLEN    DB    0        ;Gap length (Not used)
  123. ************
  124. ************
  125. File MSBOOT.OLD;1
  126.   251   DISK_CMD_SECSIZ    DW    H_SECTOR_SIZE    ;Sector size (word)
  127.   252   DISK_CMD_DMAOFF    DW    OFFSET READ_AREA ;DMA offset (word)
  128. ******
  129. File MSBOOT.ASM;1
  130.   280   DISK_CMD_SECSIZ    DW    F_SECTOR_SIZE    ;Sector size (word)
  131.   281   DISK_CMD_DMAOFF    DW    OFFSET READ_AREA ;DMA offset (word)
  132. ************
  133. ************
  134. File MSBOOT.OLD;1
  135.   257   ;   Define the count of sectors to be read
  136. ******
  137. File MSBOOT.ASM;1
  138.   286   ;   Store a flag in case booting from floppy disk.
  139.   287   ;    This will tell if it is double-sided or not.
  140.   288   ;
  141.   289   FLOPPY_DSIDED    DB    0
  142.   290   ;
  143.   291   ;   Define the count of sectors to be read
  144. ************
  145. ************
  146. File MSBOOT.OLD;1
  147.   261   ;   Define the track number of the hard disk to be read
  148.   262   ;
  149. ******
  150. File MSBOOT.ASM;1
  151.   295   ;   Store the track number of the hard disk directory
  152.   296   ;
  153.   297   DIR_TRACK    DW    0
  154.   298   ;
  155.   299   ;   Store the sector number of the hard disk directory
  156.   300   ;
  157.   301   DIR_SECTOR    DB    0
  158.   302   ;
  159.   303   ;   Store the track number of the hard disk to be read
  160.   304   ;
  161. ************
  162. ************
  163. File MSBOOT.OLD;1
  164.   265   ;   Define the sector number of the hard disk to be read
  165.   266   ;
  166. ******
  167. File MSBOOT.ASM;1
  168.   307   ;   Store the sector number of the hard disk to be read
  169.   308   ;
  170. ************
  171. ************
  172. File MSBOOT.OLD;1
  173.   269   ;   Define the track number of the first DPD block
  174. ******
  175. File MSBOOT.ASM;1
  176.   311   ;   Store the information for this disk
  177.   312   ;
  178.   313   NUM_FAT_SECTORS        DB    0    ;Number of FAT sectors
  179.   314   NUM_FATS        DB    0    ;Number of FATs on disk
  180.   315   SECTOR_SIZE        DW    0    ;Sector size
  181.   316   CLUSTER_SIZE        DW    0    ;Cluster size
  182.   317   SECT_PER_TRACK        DW    0    ;Number of sectors per track
  183.   318   NUM_SURFACES        DB    0    ;Number of surfaces
  184.   319   NUM_RESERVED_SECTORS    DW    0    ;Number of reserved sectors
  185.   320   NUM_DIR_SECTORS        DW    0    ;Number of directory sectors
  186.   321   ;
  187.   322   ;   Define the track number of the first DPD block
  188. ************
  189. ************
  190. File MSBOOT.OLD;1
  191.   281   ;   Define the flag that a hard disk interrupt occured
  192. ******
  193. File MSBOOT.ASM;1
  194.   334   ;   Define the first track number of the partition
  195.   335   ;
  196.   336   FIRST_PARTITION_TRACK    DW    0
  197.   337   ;
  198.   338   ;   Define the flag that a hard disk interrupt occured
  199. ************
  200. ************
  201. File MSBOOT.OLD;1
  202.   300   ;
  203. ******
  204. File MSBOOT.ASM;1
  205.   357   ;    Since sector numbers always start at 1,
  206.   358   ;    add an extra byte for the proper offset.
  207.   359   ;
  208. ************
  209. ************
  210. File MSBOOT.OLD;1
  211.   311   MS_DOS_LOADING_MSG    DB    'MS-DOS (8) loading . .'
  212.   312   ;
  213. ******
  214. File MSBOOT.ASM;1
  215.   370   MS_DOS_LOADING_MSG    DB    'MS-DOS (RGT) loading . .'
  216.   371   ;
  217. ************
  218. ************
  219. File MSBOOT.OLD;1
  220.   326   ;   Define the message for disk not MS-DOS system disk
  221. ******
  222. File MSBOOT.ASM;1
  223.   385   ;   Define the message for an error reading directory on the disk
  224.   386   ;
  225.   387   READ_DIR_ERROR_MSG    DB    'Error reading disk directory',0
  226.   388   ;
  227.   389   ;   Define the message for disk not MS-DOS system disk
  228. ************
  229. ************
  230. File MSBOOT.OLD;1
  231.   334   
  232. ******
  233. File MSBOOT.ASM;1
  234.   397   ;   Define message for types of disks found
  235.   398   ;
  236.   399   DSIDE_DISK_MSG    DB    CR,LF,'Floppy disk is double-sided',CR,LF,LF,0
  237.   400   SSIDE_DISK_MSG    DB    CR,LF,'Floppy disk is single-sided',CR,LF,LF,0
  238.   401   ;
  239.   402   
  240. ************
  241. ************
  242. File MSBOOT.OLD;1
  243.   348       MOV    DISK_CMD_DRIVE,AL    ;Store disk device in memory
  244.   349       MOV    CX,8            ;Set count to 8 bytes
  245. ******
  246. File MSBOOT.ASM;1
  247.   416       MOV    AH,AL            ;Copy into reg AH
  248.   417       AND    AL,07FH            ;Mask out double-sided bit
  249.   418       MOV    DISK_CMD_DRIVE,AL    ;Store disk device in memory
  250.   419       AND    AH,080H            ;Mask out all but double-sided bit
  251.   420       MOV    FLOPPY_DSIDED,AH    ;Store in memory
  252.   421       MOV    CX,8            ;Set count to 8 bytes
  253. ************
  254. ************
  255. File MSBOOT.OLD;1
  256.   361   ;   Restart vector for another attempt to load MS-DOS operating system
  257.   362   ;
  258. ******
  259. File MSBOOT.ASM;1
  260.   433   ;   Restart address for another attempt to load MS-DOS operating system
  261.   434   ;
  262. ************
  263. ************
  264. File MSBOOT.OLD;1
  265.   383       JL    READ_IO_SYSTEM        ;If not hard disk, read I/O system
  266.   384       CALL    HDISK_INIT        ;Otherwise, initialize hard disk
  267.   385   ;
  268. ******
  269. File MSBOOT.ASM;1
  270.   455       JL    FDISK_INIT        ;If not hard disk, check type of disk
  271.   456       CALL    HDISK_INIT        ;Otherwise, initialize hard disk
  272.   457       JMP    READ_IO_SYSTEM        ;And go read I/O system
  273.   458   ;
  274.   459   ;   Disk is floppy disk  --  find out if disk is single- or double-sided disk
  275.   460   ;
  276.   461   FDISK_INIT:
  277.   462       MOV    AL,FLOPPY_DSIDED    ;Get flag for double-sided floppy
  278.   463   ;
  279.   464   ;   Found valid disk type  --  store disk type found and print it for user
  280.   465   ;
  281.   466       OR    AL,AL            ;Check if single-sided disk
  282.   467       JNZ    FDISK_INIT_010        ;If not, print other message
  283.   468   ;
  284.   469   ;   Disk is a single-sided disk  --  store disk parameters and print message
  285.   470   ;
  286.   471       MOV    DISK_CMD_DENSITY,F_DENSITY_TYPE        ;Set disk density code
  287.   472       MOV    NUM_FAT_SECTORS,F_NUM_FAT_SECTORS
  288.   473       MOV    NUM_FATS,F_NUM_FATS
  289.   474       MOV    SECTOR_SIZE,F_SECTOR_SIZE
  290.   475       MOV    CLUSTER_SIZE,F_CLUSTER_SIZE
  291.   476       MOV    SECT_PER_TRACK,F_SECT_PER_TRACK
  292.   477       MOV    NUM_SURFACES,F_NUM_SURFACES
  293.   478       MOV    NUM_RESERVED_SECTORS,F_NUM_RESERVED_SECTORS
  294.   479       MOV    NUM_DIR_SECTORS,F_NUM_DIR_SECTORS
  295.   480       MOV    DIR_TRACK,2        ;Set track of directory
  296.   481       MOV    DIR_SECTOR,7        ;Set sector of directory
  297.   482       MOV    SI,OFFSET SSIDE_DISK_MSG ;Get message for single-sided disk
  298.   483       JMP    SHORT FDISK_INIT_020    ;And print it out
  299.   484   ;
  300.   485   ;   Disk is a double-sided disk  --  store disk information and print message
  301.   486   ;
  302.   487   FDISK_INIT_010:
  303.   488       MOV    DISK_CMD_DENSITY,F2_DENSITY_TYPE    ;Set disk density code
  304.   489       MOV    NUM_FAT_SECTORS,F2_NUM_FAT_SECTORS
  305.   490       MOV    NUM_FATS,F2_NUM_FATS
  306.   491       MOV    SECTOR_SIZE,F2_SECTOR_SIZE
  307.   492       MOV    CLUSTER_SIZE,F2_CLUSTER_SIZE
  308.   493       MOV    SECT_PER_TRACK,F2_SECT_PER_TRACK
  309.   494       MOV    NUM_SURFACES,F2_NUM_SURFACES
  310.   495       MOV    NUM_RESERVED_SECTORS,F2_NUM_RESERVED_SECTORS
  311.   496       MOV    NUM_DIR_SECTORS,F2_NUM_DIR_SECTORS
  312.   497       MOV    DIR_TRACK,3        ;Set track of directory
  313.   498       MOV    DIR_SECTOR,1        ;Set sector of directory
  314.   499       MOV    SI,OFFSET DSIDE_DISK_MSG ;Get message for double-sided disk
  315.   500   ;
  316.   501   ;   Print out the type of disk found
  317.   502   ;
  318.   503   FDISK_INIT_020:
  319.   504       CALL    PRINT_MESSAGE        ;And print it out
  320.   505   ;
  321. ************
  322. ************
  323. File MSBOOT.OLD;1
  324.   390       MOV    DISK_CMD_DMASEG_OFF[BX],CS    ;Store segment of destination
  325.   391       MOV    CX,24            ;Get count of segments
  326.   392       MOV    AX,IO_SYS_SEG        ;Get segment for loading I/O system
  327. ******
  328. File MSBOOT.ASM;1
  329.   510       MOV    AL,0FFH            ;Set reg AL to 0FFH
  330.   511       MOV    DISK_CMD_CURTRK_OFF[BX],AL    ;And set current track to this value
  331.   512       MOV    DISK_CMD_DMASEG_OFF[BX],CS    ;Store segment of destination
  332.   513       CALL    GET_IO_POSITION        ;Get IO.SYS position and size
  333.   514       MOV    BX,OFFSET DISK_CMD_CMD    ;Get address of command block
  334.   515       MOV    READ_TRACK,AX        ;Store track to read for hard disk
  335.   516       MOV    READ_SECTOR,DL        ;Store sector to read for hard disk
  336.   517       MOV    DISK_CMD_TRACK_OFF[BX],AL    ;Set track to read for floppy
  337.   518       MOV    DISK_CMD_SECTOR_OFF[BX],DL    ;Set sector to read for floppy
  338.   519       MOV    AX,IO_SYS_SEG        ;Get segment for loading I/O system
  339. ************
  340. ************
  341. File MSBOOT.OLD;1
  342.   395       MOV    AL,3            ;Set AL to 3
  343.   396       MOV    DISK_CMD_TRACK_OFF[BX],AL    ;And set to track to read
  344.   397       MOV    DISK_CMD_SECTOR_OFF[BX],AL    ;Also set to sector to read
  345.   398       MOV    AL,0FFH                ;Set reg AL to 0FFH
  346.   399       MOV    DISK_CMD_CURTRK_OFF[BX],AL    ;And set current track to this value
  347.   400       CALL    READ_SECTORS        ;Call routine to read the logical device
  348. ******
  349. File MSBOOT.ASM;1
  350.   522       CALL    READ_SECTORS        ;Call routine to read the logical device
  351. ************
  352. ************
  353. File MSBOOT.OLD;1
  354.   410       MOV    CX,36            ;Get number of sectors for MS-DOS code
  355.   411       MOV    AX,MS_DOS_SEG        ;Get segment for loading that code
  356. ******
  357. File MSBOOT.ASM;1
  358.   532       CALL    GET_MSDOS_POSITION    ;Get MSDOS.SYS position and size
  359.   533       MOV    BX,OFFSET DISK_CMD_CMD    ;Get address of command block
  360.   534       MOV    READ_TRACK,AX        ;Store track to read for hard disk
  361.   535       MOV    READ_SECTOR,DL        ;Store sector to read for hard disk
  362.   536       MOV    DISK_CMD_TRACK_OFF[BX],AL    ;Set track to read for floppy
  363.   537       MOV    DISK_CMD_SECTOR_OFF[BX],DL    ;Set sector to read for floppy
  364.   538       MOV    DISK_CMD_DMASEG_OFF[BX],CS    ;Store segment of destination
  365.   539       MOV    AX,MS_DOS_SEG        ;Get segment for loading that code
  366. ************
  367. ************
  368. File MSBOOT.OLD;1
  369.   420       MOV    CL,DISK_CMD_DRIVE    ;Get logical device being booted
  370. ******
  371. File MSBOOT.ASM;1
  372.   548   ;
  373.   549   ;   I/O system is loaded, and MS-DOS is loaded.
  374.   550   ;    Jump to IO.SYS to initiate system.
  375.   551   ;
  376.   552       MOV    CL,DISK_CMD_DRIVE    ;Get logical device being booted
  377. ************
  378. ************
  379. File MSBOOT.OLD;1
  380.   455   ;    Reg BX    --  Offset to string to be printed.
  381.   456   ;    Reg CX    --  Count of number of sectors to be read
  382.   457   ;
  383. ******
  384. File MSBOOT.ASM;1
  385.   587   ;    Reg BX        --  Offset of command buffer to be used for read of floppy
  386.   588   ;    Reg CX        --  Count of number of sectors to be read
  387.   589   ;    Reg ES:DI    --  Address of buffer for storing data
  388.   590   ;
  389.   591   ;    For floppy disks, track and sector must be stored in command buffer
  390.   592   ;    For hard disks, track is in READ_TRACK, and sector is in READ_SECTOR
  391.   593   ;
  392. ************
  393. ************
  394. File MSBOOT.OLD;1
  395.   460   ;    None
  396.   461   ;
  397. ******
  398. File MSBOOT.ASM;1
  399.   596   ;    Carry set if read failed.
  400.   597   ;    Carry clear if read succeeded.
  401.   598   ;
  402. ************
  403. ************
  404. File MSBOOT.OLD;1
  405.   470   ;   Device being booted is a floppy disk
  406.   471   ;
  407. ******
  408. File MSBOOT.ASM;1
  409.   607   ;   Device being booted is a floppy disk.
  410.   608   ;
  411. ************
  412. ************
  413. File MSBOOT.OLD;1
  414.   476       CALL    DECDISK            ;Read sectors of floppy disk
  415. ******
  416. File MSBOOT.ASM;1
  417.   613   ;
  418.   614   ;   If this is a double-sided disk, then set the density to double-sided.
  419.   615   ;
  420.   616       MOV    BYTE PTR DISK_CMD_DENSITY_OFF[BX],FDISK_RAINB
  421.   617                           ;Set to single-density Rainbow
  422.   618       CMP    NUM_SURFACES,1        ;See if double-sided disk
  423.   619       JZ    FLOPPY_DISK_LOOP_READ    ;If not, then just read disk
  424.   620   ;
  425.   621   ;   This is a double-sided floppy disk.
  426.   622   ;    Set the density.
  427.   623   ;
  428.   624       OR    BYTE PTR DISK_CMD_DENSITY_OFF[BX],FDISK_DSIDE
  429.   625                       ;Set double-sided density bit
  430.   626   ;
  431.   627   ;   Now read the disk sectors
  432.   628   ;
  433.   629   FLOPPY_DISK_LOOP_READ:
  434.   630       CALL    DECDISK            ;Read sectors of floppy disk
  435. ************
  436. ************
  437. File MSBOOT.OLD;1
  438.   516       ADD    DI,H_SECTOR_SIZE    ;Increment destination by sector size
  439.   517       CALL    HD_NEXT_SECTOR        ;Increment to next sector on disk
  440. ******
  441. File MSBOOT.ASM;1
  442.   670       ADD    DI,SECTOR_SIZE        ;Increment destination by sector size
  443.   671       CALL    HD_NEXT_SECTOR        ;Increment to next sector on disk
  444. ************
  445. ************
  446. File MSBOOT.OLD;1
  447.   559   ;   Initialize the disk controller (software initialization)
  448. ******
  449. File MSBOOT.ASM;1
  450.   713   ;   Initialize known disk parameters
  451.   714   ;
  452.   715       MOV    NUM_FAT_SECTORS,H_NUM_FAT_SECTORS
  453.   716       MOV    NUM_FATS,H_NUM_FATS
  454.   717       MOV    SECTOR_SIZE,H_SECTOR_SIZE
  455.   718       MOV    CLUSTER_SIZE,H_CLUSTER_SIZE
  456.   719       MOV    SECT_PER_TRACK,H_SECT_PER_TRACK
  457.   720       MOV    NUM_SURFACES,H_NUM_SURFACES
  458.   721       MOV    NUM_RESERVED_SECTORS,H_NUM_RESERVED_SECTORS
  459.   722       MOV    NUM_DIR_SECTORS,H_NUM_DIR_SECTORS
  460.   723   ;
  461.   724   ;   Initialize the disk controller (software initialization)
  462. ************
  463. ************
  464. File MSBOOT.OLD;1
  465.   597       MOV    AX,ES:HOM_DPDTRACK[BX]    ;Get track of DPD block
  466. ******
  467. File MSBOOT.ASM;1
  468.   762       XOR    AX,AX            ;Clear reg AX
  469.   763       MOV    AL,ES:HOM_NOSURFACE[BX]    ;Get number of surfaces on disk
  470.   764       MOV    NUM_SURFACES,AL        ;Store in memory
  471.   765       MOV    AL,ES:HOM_SECPERTRK[BX]    ;Get number of sectors on disk track
  472.   766       MOV    SECT_PER_TRACK,AX    ;Store in memory
  473.   767       MOV    AX,ES:HOM_DPDTRACK[BX]    ;Get track of DPD block
  474. ************
  475. ************
  476. File MSBOOT.OLD;1
  477.   681       INC    BYTE PTR DPD_SECTOR    ;Increment to next DPD sector
  478.   682       JMP    SHORT READ_DPD_BLOCK    ;And read in that sector
  479. ******
  480. File MSBOOT.ASM;1
  481.   851       INC    DPD_SECTOR        ;Increment to next DPD sector
  482.   852       JMP    SHORT READ_DPD_BLOCK    ;And read in that sector
  483. ************
  484. ************
  485. File MSBOOT.OLD;1
  486.   687       MOV    CX,DPD_PART_LTRACK[BX+SI]    ;Get last track of partition
  487.   688       MOV    BX,DPD_PART_FTRACK[BX+SI]    ;Get last track of partition
  488.   689       CALL    CALCULATE_NUMBER_OF_FAT_SECTORS    ;And find number of FAT sectors
  489.   690                           ;for this partition
  490.   691       ADD    AX,48            ;Add number of reserved sectors
  491.   692                       ;and sectors for directory
  492.   693       XOR    DX,DX            ;Clear upper word
  493.   694       MOV    CX,H_MAX_SECT_PER_TRACK    ;Get number of sectors per track
  494.   695       DIV    CX            ;Divide to get track and sector
  495.   696       INC    DX            ;Sectors start at 1, so increment sector
  496.   697       MOV    READ_SECTOR,DL        ;Store as sector number to read
  497.   698       ADD    AX,BX            ;Add first track to track number
  498.   699       MOV    READ_TRACK,AX        ;Store as track number to read
  499.   700       RET                ;And return to caller
  500. ******
  501. File MSBOOT.ASM;1
  502.   857       MOV    CLUSTER_SIZE,H_CLUSTER_SIZE    ;Set to number of sectors per cluster
  503.   858       MOV    CX,DPD_PART_LTRACK[BX+SI]    ;Get last track of partition
  504.   859       MOV    BX,DPD_PART_FTRACK[BX+SI]    ;Get first track of partition
  505.   860       MOV    FIRST_PARTITION_TRACK,BX    ;Save first partition track
  506.   861       CALL    CALCULATE_NUMBER_OF_FAT_SECTORS    ;And find number of FAT sectors
  507.   862                           ;for this partition
  508.   863       PUSH    AX            ;Save number of FAT sectors found
  509.   864       SHR    AX,1            ;Since there are 2 copies of the FAT,
  510.   865                       ;divide to get no. of sectors per FAT
  511.   866       MOV    NUM_FAT_SECTORS,AL    ;Store number of FAT sectors found
  512.   867       POP    AX            ;Restore total number found
  513.   868   
  514.   869       ADD    AX,NUM_RESERVED_SECTORS    ;Add number of reserved sectors
  515.   870       XOR    DX,DX            ;Clear upper word
  516.   871       DIV    SECT_PER_TRACK        ;Divide by number of sectors per track
  517.   872                       ;to get track and sector
  518.   873       INC    DX            ;Sectors start at 1, so increment sector
  519.   874       MOV    DIR_SECTOR,DL        ;Store as sector number of directory
  520.   875       ADD    AX,BX            ;Add first track to track number
  521.   876       MOV    DIR_TRACK,AX        ;Store as track number of directory
  522.   877       RET                ;And return to caller
  523. ************
  524. ************
  525. File MSBOOT.OLD;1
  526.   722   ;   Registers Changed:    ALL except CS
  527.   723   ;
  528. ******
  529. File MSBOOT.ASM;1
  530.   899   ;   Registers Changed:    AX, CX, DX, BP
  531.   900   ;
  532. ************
  533. ************
  534. File MSBOOT.OLD;1
  535.   729       SHL    CX,1            ;Multiply by number of sectors per track
  536.   730       SHL    CX,1
  537.   731       SHL    CX,1
  538.   732       SHL    CX,1
  539.   733       MOV    BP,2            ;Assume 2 FAT sectors
  540. ******
  541. File MSBOOT.ASM;1
  542.   906       MOV    AX,CX            ;Move to reg AX
  543.   907       MUL    SECT_PER_TRACK        ;Multiply by number of sectors per track
  544.   908       MOV    CX,AX            ;Put back in reg CX
  545.   909       MOV    BP,2            ;Assume 2 FAT sectors
  546. ************
  547. ************
  548. File MSBOOT.OLD;1
  549.   739       SUB    AX,H_NUM_RESERVED_SECTORS ;Subtract reserved sectors
  550.   740       SUB    AX,BP            ;Subtract number of FAT sectors
  551.   741       SHR    AX,1            ;Divide by number of sectors per cluster
  552.   742       SHR    AX,1
  553.   743       MOV    BX,AX            ;Store in reg BX
  554. ******
  555. File MSBOOT.ASM;1
  556.   915       SUB    AX,NUM_RESERVED_SECTORS    ;Subtract reserved sectors
  557.   916       SUB    AX,NUM_DIR_SECTORS    ;Subtract directory sectors
  558.   917       SUB    AX,BP            ;Subtract number of FAT sectors
  559.   918       XOR    DX,DX            ;Clear upper word of double word
  560.   919       DIV    CLUSTER_SIZE        ;Divide by number of sectors per cluster
  561.   920       MOV    BX,AX            ;Store in reg BX
  562. ************
  563. ************
  564. File MSBOOT.OLD;1
  565.   749       MOV    BX,H_SECTOR_SIZE    ;Get sector size of disk
  566.   750       XOR    DX,DX            ;Clear upper word of double word
  567. ******
  568. File MSBOOT.ASM;1
  569.   926       MOV    BX,SECTOR_SIZE        ;Get sector size of disk
  570.   927       XOR    DX,DX            ;Clear upper word of double word
  571. ************
  572.     
  573. ;
  574. ;   Function:    GET_IO_POSITION
  575. ;
  576. ;   Abstract:
  577. ;
  578. ;    Read the directory of the disk and find the starting track,
  579. ;    starting sector, and number of sectors used by IO.SYS.
  580. ;
  581. ;   Entry Parameters:
  582. ;
  583. ;    DIR_TRACK    --  Track number of first sector of directory
  584. ;    DIR_SECTOR    --  Sector number of first sector of directory
  585. ;
  586. ;   Exit Parameters:
  587. ;
  588. ;    Reg AX        --  Track number of first sector of IO.SYS
  589. ;    Reg CX        --  Number of sectors in IO.SYS
  590. ;    Reg DL        --  Sector number of first sector of IO.SYS
  591. ;
  592. ;   Registers Changed:    All, except ES, DI
  593. ;
  594. ;   Side Effects:    Reads first sector of directory into READ_AREA
  595. ;
  596. GET_IO_POSITION    PROC    NEAR
  597.     XOR    AX,AX            ;Set to no offset of directory
  598.     CALL    GET_FILE_POSITION    ;Read first sector of directory
  599.     RET                ;And return to caller
  600. ;
  601. GET_IO_POSITION    ENDP            ;End of procedure
  602. ;
  603.     
  604. ;
  605. ;   Function:    GET_MSDOS_POSITION
  606. ;
  607. ;   Abstract:
  608. ;
  609. ;    Read the directory of the disk and find the starting track,
  610. ;    starting sector, and number of sectors used by MSDOS.SYS.
  611. ;
  612. ;   Entry Parameters:
  613. ;
  614. ;    DIR_TRACK    --  Track number of first sector of directory
  615. ;    DIR_SECTOR    --  Sector number of first sector of directory
  616. ;
  617. ;   Exit Parameters:
  618. ;
  619. ;    Reg AX        --  Track number of first sector of MSDOS.SYS
  620. ;    Reg CX        --  Number of sectors in MSDOS.SYS
  621. ;    Reg DL        --  Sector number of first sector of MSDOS.SYS
  622. ;
  623. ;   Registers Changed:    All, except ES, DI
  624. ;
  625. ;   Side Effects:    Reads first sector of directory into READ_AREA
  626. ;
  627. GET_MSDOS_POSITION    PROC    NEAR
  628.     MOV    AX,32            ;Set to offset of second file
  629.     CALL    GET_FILE_POSITION    ;Read first sector of directory
  630.     ADD    CX,2            ;Add 2 sectors just to be safe
  631.     RET                ;And return to caller
  632. ;
  633. GET_MSDOS_POSITION    ENDP        ;End of procedure
  634. ;
  635.     
  636. ;
  637. ;   Function:    GET_FILE_POSITION
  638. ;
  639. ;   Abstract:
  640. ;
  641. ;    Read the first sector of the directory of the disk.
  642. ;
  643. ;   Entry Parameters:
  644. ;
  645. ;    Reg AX        --  Offset to directory entry of interest in dir
  646. ;    DIR_TRACK    --  Track number of first sector of directory
  647. ;    DIR_SECTOR    --  Sector number of first sector of directory
  648. ;
  649. ;   Exit Parameters:
  650. ;
  651. ;    Reg AX        --  Track number of first sector of file.
  652. ;    Reg CX        --  Number of sectors in file.
  653. ;    Reg DL        --  Sector number of first sector of file.
  654. ;
  655. ;   Registers Changed:    All, except ES, DI
  656. ;
  657. ;   Side Effects:
  658. ;
  659. ;    Save offset to directory entry
  660. ;
  661. GET_FILE_POSITION    PROC    NEAR
  662.     PUSH    ES            ;Save reg ES
  663.     PUSH    AX            ;Save offset to directory entry
  664. ;
  665. ;   Read the directory sector from disk
  666. ;
  667.     MOV    DI,OFFSET READ_AREA    ;Get address of buffer
  668.     MOV    AX,CS            ;Copy CS segment to ES
  669.     MOV    ES,AX
  670.     MOV    BX,OFFSET DISK_CMD_CMD    ;Get address of command block
  671.     MOV    AL,DIR_SECTOR        ;Get sector number to directory
  672.     MOV    DISK_CMD_SECTOR_OFF[BX],AL    ;Store it in command block
  673.     MOV    READ_SECTOR,AL        ;Store in READ_SECTOR for hard disk
  674.     MOV    AX,DIR_TRACK        ;Get track of directory
  675.     MOV    DISK_CMD_TRACK_OFF[BX],AL    ;Store it in command block
  676.     MOV    READ_TRACK,AX        ;Store in READ_TRACK for hard disk
  677.     MOV    CX,1            ;Set count to 1 sector
  678.     CALL    READ_SECTORS        ;Read sector of floppy disk
  679.     MOV    SI,OFFSET READ_DIR_ERROR_MSG    ;Get address of read error message
  680.     JNC    GET_FILE_POSITION_110    ;If successful, continue
  681.     JMP    PRINT_ERROR        ;If error, print it and try again
  682. ;
  683. ;   Have sector of directory  --  get size and cluster of start of file
  684. ;
  685. GET_FILE_POSITION_110:
  686.     MOV    BX,OFFSET READ_AREA    ;Get offset to first entry
  687.                     ;This should be IO.SYS
  688.     POP    AX            ;Restore offset to directory entry
  689.     ADD    BX,AX            ;Add offset to directory entry
  690.     MOV    DX,[BX+30]        ;Get upper word of size of file
  691.     MOV    AX,[BX+28]        ;Get lower word of size of file
  692.     DIV    SECTOR_SIZE        ;Divide by sector size
  693.     OR    DX,DX            ;See if any remainder
  694.     JZ    GET_FILE_POSITION_130    ;If not, continue
  695.     INC    AX            ;Otherwise, increment to next sector
  696. GET_FILE_POSITION_130:
  697.     MOV    CX,AX            ;Move number of sectors to reg CX
  698.     MOV    AX,[BX+26]        ;Get cluster number of entry
  699.     SUB    AX,2            ;Subtract 2 since first data cluster
  700.                     ;is actually cluster 2
  701.     MUL    CLUSTER_SIZE        ;Multiply by cluster size to get sectors
  702.     ADD    AX,NUM_RESERVED_SECTORS    ;Add number of reserved sectors
  703.     ADD    AX,NUM_DIR_SECTORS    ;Add number of directory sectors
  704.     XOR    DX,DX            ;Clear reg DX
  705.     MOV    DL,NUM_FAT_SECTORS    ;Get the number of FAT sectors
  706.     ADD    DX,DX            ;Double it for 2 FATs
  707.     ADD    AX,DX            ;And add to get sector of file
  708. ;
  709. ;   Now reg AX contains logical sector number of first sector of file.
  710. ;    Convert this to sector and track number.
  711. ;
  712.     XOR    DX,DX            ;Clear upper word
  713.     DIV    SECT_PER_TRACK        ;Divide by number of sectors per track
  714.     INC    DX            ;Increment sector number to base at zero
  715.     ADD    AX,FIRST_PARTITION_TRACK    ;Add the track number of the
  716.                         ;first track of the partition
  717. ;
  718. ;   That is all  --  return to caller
  719. ;
  720.     POP    ES            ;Restore extra segment
  721.     RET                ;Return to caller
  722. ;
  723. GET_FILE_POSITION    ENDP        ;End of procedure
  724.  
  725.