whats wrong with my FAT/root code: 
Author Message
 whats wrong with my FAT/root code:

The program I have attached (assembled using NASM) creates some weird
results...
    The program assumes you have a drive D... If you do not and want to
change it to C do this: whenever you see an INT 25h call make the AL
parameter equal 2 not 3...
    Here is the code... if you cannot understand it and need an
explanation I can give you one if u let me know...

; FAT and Root Project
; Assembled using NASM v0.97 (Assemble as a flat binary file and run it
as a .COM)

section .text

main:
        call    save_bootsect
        call    save_root
        call    exit

save_bootsect:
        mov     al,     3               ; Drive... A = 0, B = 1, C = 2
        mov     cx,     1               ; Number of sectors to read
        xor     dx,     dx              ; Sector 0
        mov     bx,     boot_buffer     ; Buffer to write 512 bytes of
data to
        int     25h

        pop     dx                      ; DOS error -- extra word on
stack

        jc      bootsect_l32            ; Maybe disk > 32mb... try for
32+ mb

        ret

bootsect_l32:
        mov     word [read_packet + 4], boot_buffer     ; Address of
                                                        ; boot_buffer in
int
                                                        ; 25h data
packet
        mov     word [read_packet + 5], ds              ; Address of
data seg
        mov     word [read_packet + 2], 1               ; 1st sector
        mov     word [read_packet + 3], 1               ; Read 1 sector
        mov     al,     3                               ; Drive C
        mov     cx,     0ffffh                          ; Indicates disk

Quote:
> 32mb

        mov     bx,     read_packet                     ; Packet address

        int     25h

        pop     dx

        jc      error

        ret

save_root:
        mov     ah,     byte [boot_buffer + 22]         ; FAT size (high
byte)
        mov     al,     byte [boot_buffer + 23]         ; FAT size (low
byte)
        mov     cl,     byte [boot_buffer + 16]         ; Number of FATs

        xor     ch,     ch
        mul     cl

        mov     bh,     byte [boot_buffer + 14]         ; Reserved
sectors
        mov     bl,     byte [boot_buffer + 15]

        add     bx,     ax                              ; BX = Sector of
root

        mov     ah,     byte [boot_buffer + 17]         ; Root entry
size
        mov     al,     byte [boot_buffer + 18]

        mov     cx,     32
        mul     cx

        mov     ch,     byte [boot_buffer + 11]         ; Sector size
        mov     cl,     byte [boot_buffer + 12]

        div     cx

        mov     cx,     ax                              ; Root length in
sec
        mov     dx,     bx                              ; DX = first
sector
        mov     al,     3
        mov     bx,     root_buffer

        int     25h

        pop     dx

        jc      root_l32

        ret

root_l32:
        mov     word [read_packet + 4], root_buffer     ; Address of
                                                        ; boot_buffer in
int
                                                        ; 25h data
packet
        mov     word [read_packet + 5], ds              ; Address of
data seg
        mov     word [read_packet + 2], dx              ; 1st sector of
root
        mov     word [read_packet + 3], cx              ; Read (CX)
sectors
        mov     al,     3
        mov     cx,     0ffffh                          ; Indicates disk

Quote:
> 32mb

        mov     bx,     read_packet                     ; Packet address

        int     25h

        pop     dx

        jc      error

        ret

error:
        mov     ah,     09
        mov     dx,     error_msg
        int     21h

        call    exit

exit:
        mov     ah,     4ch
        int     21h

section .data

        read_packet     dw      0, 0, 0, 0, 0
        boot_buffer     times 512       db      0
        root_buffer     times 16384     db      0

        error_msg       db      "Error!$"



Fri, 06 Jul 2001 03:00:00 GMT  
 whats wrong with my FAT/root code:

Quote:

> The program I have attached (assembled using NASM) creates some weird
> results...
> ; Assembled using NASM v0.97 (Assemble as a flat binary file and run it
> as a .COM)

  If you run it as a .COM, you need "ORG 0x100".  Otherwise every
offset used will be off by 0x100.
--
http://www.erols.com/johnfine/
http://www.geocities.com/SiliconValley/Peaks/8600/


Fri, 06 Jul 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. whats wrong with my FAT/root code:

2. Newbie - Whats Wrong with my code.

3. Whats wrong with this code?

4. Whats wrong with this code?

5. Whats wrong with p-code ???

6. Whats wrong with p-code ???

7. Whats wrong in this code??? (ftn77)

8. Whats wrong with this code?

9. Whats wrong with my scrollable checkbutton-list code ?

10. how to deal with FAT/root? whats wrong w/ my SRC?

11. how to deal with FAT/root? whats wrong w/ my SRC?

12. Information on FAT/root needed

 

 
Powered by phpBB® Forum Software