flat assembler
Message board for the users of flat assembler.

Index > OS Construction > FAT13 Boot Sector System I Invented.

Author
Thread Post new topic Reply to topic
mbr_tsr



Joined: 03 Apr 2011
Posts: 12092
mbr_tsr 04 Oct 2012, 01:23
Code:
;A Fat13 Boot Sector By S.T.C.
;Loads the First Sector's As the Kernel
;Creates a Bootable Floppy Disk Image
;Very useful even if you don't have a floppy drive.

Org 0x7C00

BootSectorStart:

jmp StartFAT13
Fat13Drive     db 0   ;0=A: 1=B:
StartingSector dw 1   ;First Sector to Load
SectorsToRead  dw 1   ;Number of Sectors to Load
LoadSegment    dw 0x2000  ;Kernel Segment
LoadOffset     dw 0x0100  ;Kernel Offset
StartFAT13:

push cs
pop  ds

mov bp, 2  ;2=Read 3=Write
mov ax, word [cs:LoadSegment]
mov es, ax
mov bx, word [cs:LoadOffset]
mov ax, word [cs:StartingSector]
mov cx, word [cs:SectorsToRead]

Seek:
MAIN:
mov  di, 0x0005                       ; five retries for error
SECTORLOOP:
push ax
push bx
push cx
push bx
xor  dx, dx                           ; prepare dx:ax for operation
mov  bx, 0x0012
div  bx                               ; calculate
inc  dl                               ; adjust for sector 0
mov  cl, dl
xor  dx, dx                           ; prepare dx:ax for operation
mov  bx, 0x0002
div  bx                               ; calculate
mov  dh, dl
mov  ch, al
pop  bx
mov  ax, bp
xchg ah, al
mov  al, 0x01                         ; amount of sectors
DiskDrive:
mov  dl, [cs:Fat13Drive]              ; drive
int  0x13                             ; invoke BIOS
jnc  SUCCESS                          ; test for RW error
xor  ax, ax                           ; BIOS reset disk
int  0x13                             ; invoke BIOS

push ax             ;progress counter
mov ah, 0x0e
mov al, 'E'
int  0x10
pop ax

dec  di                               ; decrement error counter
pop  cx
pop  bx
pop  ax
jnz  SECTORLOOP                       ; attempt to RW again

mov ah, 0x0e
mov al, 'E'
int  0x10
mov al, 'r'
int  0x10
mov al, 'r'
int  0x10
mov al, 'o'
int  0x10
mov al, 'r'
int  0x10
mov ah, 0
int 0x16
int 0x19

SUCCESS:
pop  cx
pop  bx
pop  ax
add  bx, 512                          ; queue next buffer
inc  ax                               ; queue next sector
loop MAIN                             ; RW next sector

OverOver:

mov ax, word [cs:LoadSegment]
mov ds, ax
mov es, ax
push WORD [cs:LoadSegment]
push WORD [cs:LoadOffset]
retf

rb 0x7c00+512-2-$ 
dw 0xAA55

Org 0x0100
Sector1Buffer:
mov si, SuccessMessage
call ShowStr
mov ah, 0
int 0x16
jmp Sector1Buffer

ShowStr:
lodsb        
cmp  al, 0   
je   Okay
mov  ah, 0x0E
mov  bh, 0x00
int  0x10    
jmp  ShowStr
Okay:
ret

SuccessMessage db "Welcome to your Sector#1", 13, 10, 7, 0

rb 0x0100+1474560-512-1-$  ;Size of Floppy Disk Image
db 0                   ;Pad Floppy Image

;seek drive# sector# amount
;disk drive#
;drive# 0=A: 1=B:
;bp=2/3 (read or write)
;ax=starting sector#
;cx=amount of sectors to read or write
;es:bx=buffer
;call int 13h for FAT12 drive A: or B:

    
[/code]
Post 04 Oct 2012, 01:23
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20340
Location: In your JS exploiting you and your system
revolution 04 Oct 2012, 02:33
Maybe you misunderstand what FAT12 is meant to imply? Your code appears to be just a normal boot loader, I can't see anywhere where you define a file system of any type.
Post 04 Oct 2012, 02:33
View user's profile Send private message Visit poster's website Reply with quote
mbr_tsr



Joined: 03 Apr 2011
Posts: 12092
mbr_tsr 04 Oct 2012, 02:55
i just got it working, it is bare bones, and i wasted a CD disk testing it, finally got it working says welcome to sector 1, i will be adding filenames to it in future versions, and i don't know if it will load 0x7D sectors using Seek, yet i bet $5.00 it will, it is very important for these reasons:

1) It is an entire floppy disk image
2) You don't need a Floppy Drive to use it
3) You can attach any kernel to it
4) You can make a disk image compiler
5) It's a boot sector to have access to an entire floppy image and all it's sectors
6) It is very tiny, to add ROOT and FAT tables

I made it because i don't have a floppy drive, and i needed it to get my OS .ISO working, so don't complain, this is not a normal boot loaded, it has great potential for future testing, and is the only example of it's kind i ever known or could get, where one .ASM file is a whole floppy image, to add 64k chunks of code too.
Post 04 Oct 2012, 02:55
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 04 Oct 2012, 07:31
mbr_tsr wrote:

I made it because i don't have a floppy drive, and i needed it to get my OS .ISO working, so don't complain, this is not a normal boot loaded, it has great potential for future testing, and is the only example of it's kind i ever known or could get, where one .ASM file is a whole floppy image, to add 64k chunks of code too.


Did you announce it on facebook ? Razz
Post 04 Oct 2012, 07:31
View user's profile Send private message Send e-mail Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos 04 Oct 2012, 09:15
Cease to play with toys. Write good FAT or CDFS boot loader.
Post 04 Oct 2012, 09:15
View user's profile Send private message Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC 04 Oct 2012, 23:13
WTF? FAT13? I wasn't aware there was a FAT13.
Post 04 Oct 2012, 23:13
View user's profile Send private message Visit poster's website Reply with quote
mbr_tsr



Joined: 03 Apr 2011
Posts: 12092
mbr_tsr 04 Oct 2012, 23:43
Now you can write a whole floppy disk image in one .ASM file, i am adjusting the header so all the Files on the disk are a single set size, and the first 64K of the image is the ROOT and FAT and will have all the filename's, and i am going to make an injection tool, so any beginner can make an OS, perhaps the first 64K can load a TSR, for all file I/O, i am going to be working on FAT13 a lot in the next few days, and designing the first 64K of the image, and the second 64k is called Alpha9.
Post 04 Oct 2012, 23:43
View user's profile Send private message Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos 05 Oct 2012, 08:28
We could write floppy disk image before as well. I was working on mkfloppy.inc/mkisofs.inc/mkfat12.inc/mkfat16.inc/mkfat32.inc. On our national forum other sources were published (look here for floppy.inc, iso9660.inc). And for info, fasm supports following padding techniques:
Code:
times 2*80*18*512-$ db 0    
Code:
db 2*80*18*512-$ dup 0    


What was your reason to invent new FS? What advantages will it have over existing FSes?
Post 05 Oct 2012, 08:28
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.