flat assembler
Message board for the users of flat assembler.

Index > Main > Writing 16bit libraries

Author
Thread Post new topic Reply to topic
me239



Joined: 06 Jan 2011
Posts: 200
me239 16 Jan 2011, 00:21
Hello everyone, I was wondering two things lately. 1: is it possible to write a library (.dll kind of thing) for DOS programs with functions that can be called. 2: How do you use a FASM structure. I've read the documentation on it, but I still don't fully understand how they're used and how the 'virtual' directive plays a role.
Post 16 Jan 2011, 00:21
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 16 Jan 2011, 03:21
1. Research TSRs and how to patch the IVT. Basically, the only type of library you can make for DOS is one that sets up its own interrupts, then terminates while staying resident(TSR).
Post 16 Jan 2011, 03:21
View user's profile Send private message Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239 16 Jan 2011, 05:19
Tyler wrote:
1. Research TSRs and how to patch the IVT. Basically, the only type of library you can make for DOS is one that sets up its own interrupts, then terminates while staying resident(TSR).

I've had quite a bit of experience in DOS and TSR's. What I wanted was a non IVT based library that can be called during runtime using DOS functions. The closet I've come to making this is a program I wrote that loads another program in the slack space after the code and hands it parameters. What I want is to be able to call other functions at other locations in the file.
Post 16 Jan 2011, 05:19
View user's profile Send private message Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239 18 Jan 2011, 05:48
I made a working example! This program finds and loads a library in the current file and executes the programmed functions. I don't know how useful this is, but it's seems pretty neat.
main program:
Code:
org 100h
;jmp start
start:
        mov     ah, 4eh
        xor     cx, cx
        mov     dx, filen
        int     21h
        jc      error
        mov     ax, 3d02h
        mov     dx, 9eh
        int     21h
        xchg    ax, bx
        mov     ah, 3fh
        mov     dx, buffer
        mov     cx, 9eh
        int     21h
        mov     si, msg
        call    printf
        mov     ax, 451d
        call    dec2str
        mov     al, 41h
        call    pchar
        int     20h
error:
        mov     dx, emsg
        mov     ah, 09h
        int     21h
        int     20h
emsg    db      "ERROR: File not found. Please ensure that the library is in the current directory$"
msg     db      "Hello!", 0
filen   db      "library.bin", 0
dec2str = buffer
printf = buffer+2
pchar  = buffer+4
buffer:
    

library code:
Code:
org 0
start:
        jmp     dec2str
        jmp     printf
        jmp     pchar
dec2str:
        mov     bx, 10d
        xor     cx, cx
@@:
        xor     dx, dx
        div     bx
        push    dx
        cmp     ax, 0
        je      @f
        inc     cx
        jmp     @b
@@:
        pop     dx
        add     dl, 30h
        mov     al, dl
        mov     ah, 0eh
        int     10h
        cmp     cx, 0
        je      func_ret
        dec     cx
        jmp     @b
printf:
        lodsb
        cmp     al, 0
        je      func_ret
        mov     ah, 0eh
        int     10h
        jmp     printf
pchar:
        mov     ah, 0eh
        int     10h
func_ret:
        ret
    
Post 18 Jan 2011, 05:48
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 20 Jan 2011, 00:49
Causeway? HX? DXE? DJELF? TP6? And there are several more I can't remember (but could probably find) off the top of my head.
Post 20 Jan 2011, 00:49
View user's profile Send private message Visit poster's website 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.