flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
bubach 12 Nov 2004, 10:01
Hello, i am trying to alter my FAT and directory entrys for a FAT12 floppy.
I have added info in both FAT's and in the directory for a 50kb big file named kernel.sys that will be located at the very beginning of the data area. I have not written the actual file on the floppy yet, but i think it would still show me a "fake" kernel.sys with 50kb size in xp. Instead xp reports that i have used 6kb of the floppy space, but no file exists. This is my code: Code: ;--------------------; ; sector buffer ; ;--------------------; temp_sector: times 512 db 0 ;---------------; ; other ; ;---------------; filename db 'KERNEL SYS' Code: ;-------------; ; reset drive ; ;-------------; reset: xor ax, ax mov dl, 0 int 0x13 jc reset ;---------------; ; read fat 1 ; ;---------------; mov ax, 0x0201 mov bx, temp_sector mov cx, 2 mov dx, 0 int 0x13 jc reset ;--------------; ; change it ; ;--------------; inc bx inc bx inc bx mov byte [bx], 0x03 inc bx mov byte [bx], 0x40 inc bx mov byte [bx], 0x00 inc bx mov byte [bx], 0x05 inc bx mov byte [bx], 0x60 inc bx mov byte [bx], 0x00 inc bx mov byte [bx], 0x07 inc bx mov byte [bx], 0x80 inc bx mov byte [bx], 0x00 ;----------------; ; write it ; ;----------------; mov ax, 0x0301 mov bx, temp_sector mov cx, 2 mov dx, 0 int 0x13 jc reset ;-------------; ; reset drive ; ;-------------; reset2: xor ax, ax mov dl, 0 int 0x13 jc reset2 ;---------------; ; read fat 2 ; ;---------------; mov ax, 0x0201 mov bx, temp_sector mov cx, 10 mov dx, 0 int 0x13 jc reset2 ;--------------; ; change it ; ;--------------; inc bx inc bx inc bx mov byte [bx], 0x03 inc bx mov byte [bx], 0x40 inc bx mov byte [bx], 0x00 inc bx mov byte [bx], 0x05 inc bx mov byte [bx], 0x60 inc bx mov byte [bx], 0x00 inc bx mov byte [bx], 0x07 inc bx mov byte [bx], 0x80 inc bx mov byte [bx], 0x00 ;----------------; ; write it ; ;----------------; mov ax, 0x0301 mov bx, temp_sector mov cx, 10 mov dx, 0 int 0x13 jc reset2 ;-------------; ; reset drive ; ;-------------; reset3: xor ax, ax mov dl, 0 int 0x13 jc reset3 ;---------------------------; ; read directory entry ; ;---------------------------; mov ax, 0x0201 mov bx, temp_sector mov cx, 15 mov dx, 0x0100 int 0x13 jc reset3 ;---------------------------; ; change directory entry ; ;---------------------------; mov cx, 11 mov dx, filename .l1: mov [bx], dx inc bx inc dx loop .l1 ;--------------------; ; file attributes ; ;--------------------; mov byte [bx], 5 inc bx ;---------------------------------------; ; jump over reserved and time/date ; ;---------------------------------------; mov cx, 15 .l2: inc bx loop .l2 ;----------------------------------; ; reversed data area location ; ;----------------------------------; mov byte [bx], 0x02 inc bx mov byte [bx], 0x00 inc bx ;------------------------; ; reversed filesize ; ;------------------------; mov byte [bx], 0x00 inc bx mov byte [bx], 0xC8 ;---------------------------; ; write directory entry ; ;---------------------------; mov ax, 0x0301 mov bx, temp_sector mov cx, 15 mov dx, 0x0100 int 0x13 jc reset3 ;---------------------------------; ; write the file to data area ; ;---------------------------------; ;...... not done yet but it does not work. The info i used for finding out what to write was from this page: http://www.mega-tokyo.com/osfaq2/index.php/FAT12%20document i have used the values for the "example" file PROCESSA.TXT described in the document, as it starts at the beginning of the data area. The things i have changed is the filename and filesize.. Any idea of what i have done wrong? Or a suggestion of a simpler way of doing this? PS: if anything is terrible wrong in this code, i blame it at i did this coding _really_ late at night.. ![]() Thanks in advance... / Christoffer Last edited by bubach on 13 Feb 2012, 14:53; edited 1 time in total |
|||
![]() |
|
mike.dld 12 Nov 2004, 17:48
Look at this http://mikedld.50free.org/files/meosinst.zip as an example
|
|||
![]() |
|
Matrix 12 Nov 2004, 19:04
|
|||
![]() |
|
mike.dld 12 Nov 2004, 19:33
.com-file has addresses from $100, so those $100 bytes from the beginning are used as PSP block. Sorry if I'd mistaken.
|
|||
![]() |
|
Matrix 12 Nov 2004, 19:40
mike.dld wrote: .com-file has addresses from $100, so those $100 bytes from the beginning are used as PSP block. Sorry if I'd mistaken. no , you're right, dos loads it there. while bootprog usually loads @ 7c00h |
|||
![]() |
|
mike.dld 12 Nov 2004, 23:44
ok
![]() so parameters are at offset $80 IIRC |
|||
![]() |
|
bubach 13 Nov 2004, 13:24
Thanks, but i already solved it..
![]() for future forum-searches, here's how i did it: Code: boot db 0 kernel db 0 hyphen db 0 filename db ' ',0 ;-----------------------------------------------; ; read in arguments from the command line... ; ;-----------------------------------------------; mov cl, [ds:0x80] or cl, cl je print_usage mov si, 0x81 mov di, filename mov bx, 0 param_loop: lodsb ; or al, al ; je continue cmp al, 13 je continue cmp al, '-' jne .c1 mov [hyphen], 1 jmp .c5 .c1: cmp [hyphen], 1 jne .c5 cmp [boot], 1 je .c3 cmp [kernel], 1 je .c3 cmp al, 'b' jne .c2 mov [boot], 1 jmp .c5 .c2: cmp al, 'k' jne print_usage mov [kernel], 1 jmp .c5 .c3: cmp al, ' ' je .c5 cmp bx, 11 ja print_usage ; cmp al, '.' ; Old code, becasue i was ; jne .c4 ; thinking wrong. This converts: ; cmp bx, 8 ; FILE.TXT to: ; je .c5 ; FILE TXT ; push cx ; mov cx, 8 ; sub cx, bx ; mov al, ' ' ; rep stosb ; inc bx ; pop cx ; jmp .c5 .c4: stosb inc bx .c5: loop param_loop ;---------------; ; continue.. ; ;---------------; continue: cmp al, 13 jne .next mov al, 0 ; Make the filename ASCIIZ Last edited by bubach on 13 Feb 2012, 15:00; edited 1 time in total |
|||
![]() |
|
bubach 13 Nov 2004, 16:55
Is there a way of finding out a file-size, when using handle not FCB?
/ Christoffer |
|||
![]() |
|
Matrix 13 Nov 2004, 18:17
you're jokeing are you? this is not funny anymore.
|
|||
![]() |
|
bubach 14 Nov 2004, 12:42
Huh?? What is funny about my questions?
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.