flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Executing Programs help

Author
Thread Post new topic Reply to topic
me239



Joined: 06 Jan 2011
Posts: 200
me239 06 Jun 2011, 06:41
Hello everybody! I just got done writing some more code to execute another program under my OS, but I keep running into the same problem. The code is identical to my bootloader. What's wrong with it?
Code:
progornot:
    mov ax, 0003
    int 10h
    mov         si, buff
    mov         di, filen
    call        parsefat
    xor     cx, cx
        xor     dx, dx
        mov     ax, 20h
        mul     word[RootEntries]
        div     word[BytesPerSector]
        xchg    cx, ax
        mov     al, byte[NumberofFATs]
        mul     word[SectorsPerFAT]
        add     ax, word[ReservedSectors]
        mov     word[datasector], ax
        add     word[datasector], cx
        mov     bx, 0x0200
        push    0
        pop     es
        call    ReadSectors
        mov     ax, 0e32h
        int     10h
        mov     cx, word[RootEntries]
        mov     di, 200h
loop1:
        push    cx
        mov     cx, 11
        mov     si, filen
        push    di
        rep     cmpsb
        pop     di
        jz      LoadFat
        add     di, 32d
        loop    loop1
        jmp     fail
LoadFat:
        mov     ax, 0e32h
        int     10h
        mov     dx, word[di+1ah]
        mov     word[cluster], dx
        xor     ax, ax
        mov     al, [NumberofFATs]
        mul     word[SectorsPerFAT]
        mov     cx, ax
        mov     ax, word[ReservedSectors]
        mov     bx, 200h
        call    ReadSectors
        mov     ax, 0e33h
        int     10h
        mov     ax, 500h
        mov     es, ax
        xor     bx, bx
        push    bx
LoadImage:
        mov     ax, word[cluster]
        pop     bx
        call    ClusterLBA
        xor     cx, cx
        mov     cl, byte[SectorsPerCluster]
        call    ReadSectors
        push    bx
        mov     ax, word[cluster]
        mov     cx, ax
        mov     dx, ax
        shr     dx, 1
        add     cx, dx
        mov     bx, 200h
        add     bx, cx
        mov     dx, word[bx]
        test    ax, 1
        jnz     odd_cluster
even_cluster:
        and     dx, 0000111111111111b
        jmp     done2
odd_cluster:
        shr     dx, 4
done2:
        mov     word[cluster], dx
        cmp     dx, 0ff0h
        jb      LoadImage
exectute:
        push    500h
        push    0
        retf
fail:
        ;clc
        ret
        ;mov     ax, 0e46h
        ;int     10h
        ;xor     ax, ax
        ;int     16h
        ;hlt
        ;jmp     $
ReadSectors:
        mov     di, 5
sectloop:
        push    ax
        push    bx
        push    cx
        call    LBACHS
        mov     ah, 02
        mov     al, 1
        mov     ch, byte[absolutetrack]
        mov     cl, byte[absolutesector]
        mov     dh, byte[absolutehead]
        mov     dl, byte[DriveNumber]
        int     13h
        jnc     success
        xor     ax, ax
        int     13h
        dec     di
        pop     cx
        pop     bx
        pop     ax
        jnz     sectloop
        int     18h
success:
        mov     al, 'S'
        mov     ah, 0eh
        int     10h
        pop     cx bx ax
        add     bx, word[BytesPerSector]
        inc     ax
        loop    ReadSectors
        ret
ClusterLBA:
        sub     ax, 2
        xor     cx, cx
        mov     cl, byte[SectorsPerCluster]
        mul     cx
        add     ax, word[datasector]
        ret
LBACHS:
        xor     dx, dx
        div     word[SectorsPerTrack]
        inc     dl
        mov     byte[absolutesector], dl
        xor     dx, dx
        div     word[HeadsPerCylinder]
        mov     byte[absolutehead], dl
        mov     byte[absolutetrack], al
        ret    
Post 06 Jun 2011, 06:41
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.