View Single Post
Old Oct 20th, 2006, 8:43 PM   #14
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 431
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
Yes the majority of that deals with writing to a FAT filesystem. However, it shows the general structure of the boot sector before any file operations. The code for the menuetOS that I posted previously for instance, won't load. However this code:
boot_program	   equ 07c00h ;position for boot code
   
		   jmp start_program
		   nop
   
oemname 	   db 'MENUETOS'
bytespersector	   dw 512
sectorspercluster  db 1
ressectors	   dw 1
numcopiesfat	   db 2
maxallocrootdir    dw 224
maxsectors	   dw 2880 ;for 1.44 mbytes disk
mediadescriptor    db 0f0h ;fd = 2 sides 18 sectors
sectorsperfat	   dw 9
sectorspertrack    dw 18
heads		   dw 2
hiddensectors	   dd 0
hugesectors	   dd 0 ;if sectors > 65536
drivenumber	   db 0
		   db 0
bootsignature	   db 029h ;extended boot signature
volumeid	   dd 0
volumelabel	   db 'MENUET DISK'
filesystemtype	   db 'FAT12   '


start_program:

  xor ax,ax
  mov ss,ax
  mov sp,boot_program
  push ss
  pop ds

  mov  si,loading+boot_program
loop_loading:
  lodsb
  or al,al
  jz procura_arquivo_novamente
  mov ah,0eh
  mov bx,07h
  int 010h
  jmp loop_loading


procura_arquivo_novamente:

  push ss
  pop es

  mov  bp,16

newtry:

  dec bp

loop_envio_mensagem:

  lodsb
  or al,al
  jz espera_digitar_tecla
  mov ah,0eh
  mov bx,07h
  int 010h
  jmp loop_envio_mensagem

espera_digitar_tecla:

  jmp $

loading   db 13,10,'Starting MenuetOS ',00h


times 0x1fe-$ db 00h

  db 55h,0aah ;boot signature
With the relevant declarations of bytes and words at the beginning does launch successfully. So I'm figuring that snippet of code is what makes all the difference. As the author of the link that I stated he shows that the boot sector can be divided into 6 areas:
Assembly Language Jump to Boot Code
Disk Parameters Needed by DOS
Assembly Language Boot Code
Error Messages
System File Names
DOS Signature
The DOS Signature refers to the 'magic number' 55aah, the Assembly Language Jump to Boot Code is a DOS requirement according to the author along with a NOP after it, precisely as the menuetOS author is doing. The Disk Paramters Needed by DOS are those that the menuetOS author has included on his code, finally the actual boot strapper code is located in Assembly Language Boot Code, the Error Messages and System File Names are also part of that if I'm not mistaken but are this FAT system specific code of the author.
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote