PageRenderTime 279ms CodeModel.GetById 141ms app.highlight 4ms RepoModel.GetById 131ms app.codeStats 0ms

/asm/boot/test/bpb.s

http://github.com/dennis-gemini/tests
Assembly | 75 lines | 70 code | 5 blank | 0 comment | 21 complexity | 74c6d9374e9258d3108870abdc1f99c3 MD5 | raw file
 1/*****************************************************************************
 2 * Reference of FAT12/FAT16/FAT32 formats:
 3 * 	http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx
 4 *****************************************************************************/
 5.code16
 6.text
 7.extern start
 8.global BPB_BytsPerSec
 9.global BPB_SecPerClus
10.global BPB_RsvdSecCnt
11.global BPB_NumFATs
12.global BPB_RootEntCnt
13.global BPB_FATSz16
14.global BPB_SecPerTrk
15.global BPB_NumHeads
16.global BS_DrvNum
17
18                /***************************************
19                 * Common part for FAT12/FAT16/FAT32
20                 ***************************************/
21                jmp start                     # e9 <offset_16>
22                #nop                          # eb <offset_8> 90
23
24                .ascii "MSWIN4.1"             #+03 BS_OEMName:     OEM name (use MSWIN4.1 for compatibility)
25BPB_BytsPerSec: .short 512                    #+11 BPB_BytsPerSec: Bytes per sector (possible values are 512, 1024, 2048, and 4096)
26BPB_SecPerClus: .byte  1                      #+13 BPB_SecPerClus: Sectors per cluster (n^2: 1, 2, 4, 8, 16, 32, 64, and 128)
27BPB_RsvdSecCnt: .short 1                      #+14 BPB_RsvdSecCnt: Reserved sector count (1 for FAT12/FAT16, 32 for FAT32)
28BPB_NumFATs:    .byte  2                      #+16 BPB_NumFATs:    Number of FATs
29BPB_RootEntCnt: .short 224                    #+17 BPB_RootEntCnt: Root entry count (512 for FAT16, 0 for FAT32)
30                .short 2880                   #+19 BPB_TotSec16:   Total sector (16-bit). For FAT12/FAT16, BPB_TotSec16 != 0 && BPB_TotSec32 == 0. For FAT32, BPB_TotSec16 == 0 && BPB_TotSec32 != 0
31                .byte  0xf0                   #+21 BPB_Media:      0xf0 for removal media, 0xf8 for fixed media (available values: 0xf0 - 0xff)
32BPB_FATSz16:    .short 9                      #+22 BPB_FATSz16:    Sectors per FAT (16-bit) for FAT12/FAT16. 0 for FAT32.
33BPB_SecPerTrk:  .short 18                     #+24 BPB_SecPerTrk:  Sectors per track
34BPB_NumHeads:   .short 2                      #+26 BPB_NumHeads:   Number of heads (2 for 1.44 MB 3.5-inch floppy)
35                .int   0                      #+28 BPB_HiddSec:    Hidden sectors (0 for non-partitioned media)
36                .int   0                      #+32 BPB_TotSec32:   Total sector (32-bit) (BPB_TotSec32 >= 0x10000 when BPB_TotSec16 == 0)
37
38.ifndef FAT32
39                /***************************************
40                 * FAT12/FAT16 specific fields
41                 ***************************************/
42BS_DrvNum:      .byte  0                      #+36 BS_DrvNum:      Drive number (0x00 for FDD, 0x80 for HDD)
43                .byte  0                      #+37 BS_Reserved1:   Reserved (used by WindowsNT) (= 0)
44                .byte  0x29                   #+38 BS_BootSig:     Boot signature (= 0x29) indicating the following 3 fields are present.
45                .int   0                      #+39 BS_VolID:       Volume serial number. (It is usually assigned with timestamp.)
46                .ascii "Dennis Chen"          #+43 BS_VolLab:      Volume label (11 bytes = 8 + 3). It's likely to use "NO NAME    " by default.
47                .ascii "FAT12   "             #+54 BS_FileSysType: File system type: "FAT12   ", "FAT16   ", or "FAT     "
48                                              #+62
49.else
50                /***************************************
51                 * FAT32 specific fields
52                 ***************************************/
53BPB_FATSz32:    .int   0                      #+36 BPB_FATSz32:    Sectors per FAT for FAT32. (BPB_FATSz16 should be 0.)
54                .short 0                      #+40 BPB_ExtFlags:   Extended flags for FAT32.
55                .short 0                      #+42 BPB_FSVer:      Hi-byte: Major version number, lo-byte: Minor version number. 0:0 for ignore.
56BPB_RootClus:   .int   2                      #+44 BPB_RootClus:   Cluster number of the first cluster of the root directory
57                .short 1                      #+48 BPB_FSInfo:     Sector number of FSINFO structure
58                .short 6                      #+50 BPB_BkBootSec:  Sector number of backup boot record
59                .space 12                     #+52 BPB_Reserved:   Reserved
60BS_DrvNum:      .byte  0                      #+64 BS_DrvNum:      Drive number (0x00 for FDD, 0x80 for HDD)
61                .byte  0                      #+65 BS_Reserved1:   Reserved
62                .byte  0x29                   #+66 BS_BootSig:     Boot signature (= 0x29) indicating the following 3 fields are present.
63                .int   0                      #+67 BS_VolID:       Volume serial number. (It is usually assigned with timestamp.)
64                .ascii "Dennis Chen"          #+71 BS_VolLab:      Volume label (11 bytes = 8 + 3). It's likely to use "NO NAME    " by default.
65                .ascii "FAT12   "             #+82 BS_FileSysType: File system type: "FAT12   ", "FAT16   ", or "FAT     "
66                                              #+90
67.endif
68
69		/***************************************
70		* signature at the end of boot sector
71		***************************************/
72.section .signature
73                .byte 0x55
74                .byte 0xaa
75