Guest User

FAT12 Bootsector

a guest
Aug 21st, 2011
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [BITS 16]
  2. [ORG 0x7C00]
  3.  
  4. ;; jmp to code
  5. jmp 0x0000:start
  6.  
  7. ;; FAT 12 Bios Parameter Block
  8. ;;%include "fat12_bpb.inc"
  9.         ;; FAT 12 Bios Parameter Block
  10.         OSName                  db "        "
  11.         BytesPerSector          dw 512
  12.         SectorsPerCluster       db 1
  13.         ReservedSectorCount     dw 1
  14.         NumFATs                 db 2
  15.         RootEntriesCount        dw 224
  16.         TotalAmountOfSectors    dw 2880
  17.         MediaType               db 0xF0
  18.         FATSize                 dw 9
  19.         SectorsPerTrack         dw 18
  20.         NumberOfHeads           dw 2
  21.         HiddenSectors           dd 0
  22.         TotalAmountOfSectors32  dd 0
  23.         BootDriveNumber         db 0
  24.         WinNTReserved           db 0
  25.         ExtendedBootSignature   db 0x29
  26.         VolumeID                dd 0
  27.         VolumeLabel             db "           "
  28.         FileSysType             db "FAT12   "
  29.  
  30. start:
  31.         cli             ;; Disable interrupts
  32.         mov ax, 0x9000  ;; Stackaddress
  33.         mov ss, ax      ;; Stack = 0x9000
  34.         xor sp, sp      ;; Stackpointer = 0x0000
  35.         sti             ;; Enable interrupts
  36.  
  37.         ;; initialise segment registers
  38.         xor ax, ax
  39.         mov es, ax
  40.         mov ds, ax
  41.  
  42.         ;; save bootdrive
  43.         mov [BootDriveNumber], dl
  44.  
  45.         mov si, loadmessage
  46.         call printstring
  47.  
  48.         ;; A never ending loop, yay. :D
  49.         jmp $
  50.  
  51.         ;; TODO: Rest of stage 1
  52.  
  53. ;;-------------------------------------------------------
  54. ;; Data
  55. ;;-------------------------------------------------------
  56.  
  57. loadmessage db "Loading stage",13,10,0
  58. stage2_filename db "STAGE2  SYS"
  59.  
  60. ;;-------------------------------------------------------
  61. ;; Functions
  62. ;;-------------------------------------------------------
  63.  
  64. printstring:
  65.         lodsb                   ;; Load Byte
  66.         or al, al               ;;
  67.         jz short printstringd   ;; 0-Byte? => stop
  68.  
  69.         mov ah, 0x0E            ;; BIOS Function 0x0E
  70.         mov bx, 0x0007          ;; Attribute-Byte
  71.         int 0x10                ;; Write character
  72.         jmp printstring
  73. printstringd:
  74.         retn
  75.  
  76. ;; TODO: Write FAT 12 functions
  77.  
  78. ;; fill rest of sector with zeros
  79. times 510-($-$$) db 0
  80.  
  81. ;; add boot signature
  82. dw 0xAA55
Advertisement
Add Comment
Please, Sign In to add comment