flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > [] |
Author |
|
mikegonta 26 May 2007, 20:58
[ Post removed by author. ]
Last edited by mikegonta on 27 Jan 2009, 21:59; edited 2 times in total |
|||
26 May 2007, 20:58 |
|
Mac2004 27 May 2007, 09:00
Nice example indeed!
regards, Mac2004 |
|||
27 May 2007, 09:00 |
|
Dex4u 27 May 2007, 17:00
rhyno_dagreat wrote: Cool. Though I never quite understood what the File Allocation Table itself is, maybe that's why I'm stuck in the mud with trying to understand it constantly. All I know is that there's one File Allocation Table for every FAT partition |
|||
27 May 2007, 17:00 |
|
rhyno_dagreat 27 May 2007, 17:59
Dex4u wrote:
which explains why he has two FATs there. But what's their structure? All I see is three bytes in the first sector out of nine sectors total. |
|||
27 May 2007, 17:59 |
|
rhyno_dagreat 28 May 2007, 04:38
http://en.wikipedia.org/wiki/File_Allocation_Table
This has just helped quite a bit... yet I still don't know what those 3 bytes are, as they aren't in the list of bytes representing something/and or another about a cluster. Edit: I found where he/you (depending on if you're reading this, Mike) got the first byte from, but what about the following two? |
|||
28 May 2007, 04:38 |
|
mikegonta 28 May 2007, 10:51
[ Post removed by author. ]
Last edited by mikegonta on 27 Jan 2009, 21:59; edited 3 times in total |
|||
28 May 2007, 10:51 |
|
rhyno_dagreat 29 May 2007, 04:05
Thanks.
|
|||
29 May 2007, 04:05 |
|
Hayden 30 May 2007, 02:54
Here is a small boot record that i wrote... by default it will load 64k from lba[1] and then execute, you can make adjustments to that easily. it will also work from hard disks and maybee from boot-cd in program mode. the system is left in real mode and a default stack is supplied. [ds:bx] and [es:bx] points to the origin on entry into the users system, by default this origin is zero.
Code: ; ------------------------------------------------ ; BOOT-OS.ASM Build(0620a) ; Created By: Hayden McKay ; ------------------------------------------------ use16 jmp far 007C0h:init_bootsys ; must be far align 4 SystemStack dd 08000h:0fbffh ; 1k SystemSpace dd 09000h:00000h ; 64k SectorStart dw 1 ; lba SectorCount db 128 ; maximum 64k align 4 init_bootsys: ; setup stack ect... lss sp, dword [cs:SystemStack] ; nmi safe pushf pusha push dx ; boot num push sp ; setup for lba->chs translation... mov ah,08h ; drive params int 13h xor ah, ah mov al, dh ; maximum head and cx,3fh ; clear d6->d7 inc ax mul cx mov si, cx ; sector count mov di, ax ; heads x secs ; begin the lba->chs, mutli-sector read... pop bp ; ptr boot num les bx, dword [cs:SystemSpace] align 4 read_sectors: mov ax, word [cs:SectorStart] xor dx, dx div di mov cl, ah mov ch, al ; cylinder d0->d7 shl cl, 6d ; cylinder d8->d9 mov ax, dx xor dx, dx div si inc dl mov dh, al ; head or cl, dl ; sector d0->d5 mov dl, byte [ss:bp] ; read how many sectors... mov al, cl and ax,3fh sub ax, si ; - max sec... neg ax ; abs inc al ; +=1 cmp al, byte [cs:SectorCount] ; more than... jbe @f mov al, byte [cs:SectorCount] ; less than... align 4 @@: ; use the bios int13 i/o... pusha ; bios safe xor ax, ax ; calibrate int 13h popa pusha mov ah,02h ; read secs stc ; bios safe int 13h popa jc @b ; use force ; prepare for some more sectors... add word [cs:SectorStart], ax ; update start sub byte [cs:SectorCount], al ; update count jz @f ; done! shl ax, 9d ; *=512 add bx, ax ; update es:bx jmp near read_sectors align 4 @@: pop dx ; boot num ; initiate the system file... popa popf lds bx, dword [cs:SystemSpace] ; setup data call far dword [cs:SystemSpace] ; enter code ; 157 bytes ; Todo list... ; * maybee copy the system to the hma ; * maybee supply an open file system rb 510d - $ db 055h db 0AAh ; bootme! enjoy! _________________ New User.. Hayden McKay. Last edited by Hayden on 19 Jun 2007, 14:47; edited 2 times in total |
|||
30 May 2007, 02:54 |
|
rhyno_dagreat 31 May 2007, 02:48
Thanks for that Hayden!
|
|||
31 May 2007, 02:48 |
|
hckr83 07 Jun 2007, 00:33
This is really pretty amazing!
The only bad thing i syou don't do A20, but that doesn't matter as long as you only do odd number MB like 1 or something... Am I wrong about A20? I know you can use 0x10,000 but what limits are done by not doing A20? |
|||
07 Jun 2007, 00:33 |
|
Hayden 07 Jun 2007, 21:42
http://en.wikipedia.org/wiki/A20_line
* The a20 gate enables realmode access to the ~64k HMA below the 1M * From protected mode the a20 gate has no usefulness at all * From realmode the HMA can not be used for device buffers Example, if i enable the a20 gate then do sector reads to [ffff:0010] via int13, the data is not there, the fdd/dma controller gets it lost someware... I'm really bad at explaining these things... [/url] _________________ New User.. Hayden McKay. |
|||
07 Jun 2007, 21:42 |
|
JMD 08 Jun 2007, 01:05
The fat table is just a contigious list of pointers to cluster for which each file fragement is located on the disk. A cluster is just a group of sectors. A sector is a group of bytes, typical sector contains 512 bytes where you can store data.
If you want to read a file, You first start by calculating the (root) directory posistion. A directory contains one 32 byte entry for each file. The entries begin with the name of the file and also contain other information about the file. Next search through the directory for the file name you want, once you find the file name, within the file entry is other information including the cluster number of the first file fragement. Using this cluster number you can determine the position in the data section of the disk of the files first fragement and the offset to the next fragment in the fat table. To determine the location of the file fragment in the data section you need to know the starting sector of the data section then add to it the cluster number times number of sectors per cluster..... fragement location = (Data Section starting sector) + (Cluster number from file entry * sectors/cluster) Once you copied all fragements of the file the last entry in the fat table is usually 0xFFF indicating End Of File. A typical harddrive is laid out like this..... Code: *********************************** Sector 1 contains boot loader code and drive geometry and format information *********************************** Predefined number of Reserved sectors. *********************************** Fat Table 1 *********************************** Fat Table 2 *********************************** Root Directory *********************************** Data Section *********************************** Within sector one is the disk geometry and format information, here you can use this data to determine how many reserved sectors there are, how many sectors for each fat table there is, and how many entries are in the root directory. With all this information you can determine where the start of the data section is. To see how this works you can look at my boot sector also its located in this thread.... http://board.flatassembler.net/topic.php?p=51973#51973 |
|||
08 Jun 2007, 01:05 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.