Message board for the users of flat assembler.
> Main > IS this correct?(aligning things and getting file size)
Hi, I'm generating my own floppy disk images, because I am using a custom FS..
now what I want is to import the contents of a file(using the file directive) and then get the size of this file so that I can align it on a 512 byte sector...like if the file is 580 bytes, I want it to round up to 1024 on the next file I make..
here is my code:(it's a bit messy)
;this is just a file taking advantage of FASM and this makes a simple ;StoopidFS filesystem..this generates a complete raw bianry image.. image_start: boot_sector: file 'boot.bin' ;it's already aligned! first_file: db 0x3C ;file verification byte dw (((first_file_end-first_file)/512)+1) ;calculate the size of the .fname: db "kernel.bin" ;the filename string times 16-($-.fname) db 0 ;fill in the rest of the 16bytes for the filename dd 0x00000000 ;actual filesize(unused) db 0x0 ;attribute byte ;;;;Actual File;;;;; file 'kernel.bin' first_file_end: times ((((first_file_end-first_file)/512)+1)*512) -($-first_file) ;this should fill in the rest of the sector with 0s to align it for adding more files ;hopefully it works.. times 1474560- ($-image_start) db 0 ;this makes sure our generated image file is exactly 1.44mb
x86 CPU Emulation library: http://sourceforge.net/projects/x86lib
|06 Jun 2007, 20:33||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar.
Powered by rwasa.