flat assembler
Message board for the users of flat assembler.

Index > Main > FASM Standard library: macroinstructions

Thread Post new topic Reply to topic

Joined: 11 Sep 2003
Posts: 1092
Location: Poland
Macroinstruction library is very important in FASM Std Lib. Well designed macros will make writing programs easier, that's obvious. Macro library that is included in FASMW package should be used as a base, we will only extend it in some aspects. I mean extended version of win32a.inc file, only with some "patents" from win32ax.inc.
How program using StdLib should look? I have some suggestion, of course it needs some changes:

; simple program that calculates GCD
format PE console 4.0
include '%fasmlib%/fasmlib.inc'
use_dll kernel32,crtdll

        ; read numbers
        cinvoke printf, _prompt
        cinvoke scanf, _read_pattern,a,b

        ; calculate GCD
        mov     eax,[a]
        mov     edx,[b]
        mov     [pt.x],eax
        mov     ebx,[pt.x]

        cmp     eax,edx
        jae     substract
        xchg    eax,edx
        sub     eax,edx
        jnz     compare

        cinvoke printf, _result, [a],[b],edx
        invoke  ExitProcess,0


  _prompt db 'Enter two numbers: ', 0
  _read_pattern db '%d%d', 0
  _result db 'GCD (%d,%d)=%d', 0

  a dd ?
  b dd ?
  pt POINT


use_dll and .idata macros will automatically include files with needed equates and import functions (just with some better name).
Additionaly (not present in this example) iglobal/uglobal macros will be used for declaring variables in multi-file projects.

That's my suggestion, proably have to be modified. What's your opinion about it?
Post 15 Jun 2005, 13:35
View user's profile Send private message Visit poster's website Reply with quote
Verbosity in development

Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
i would take another approach.

1. I suggest writing library from scrap, privalov's macrolibrary IMO isn't standardized in way we should want. We also may need to change some definitions. And we sholdn't leave developing of basic macrolibrary on privalov

2. macros starting with ".", we shouldn't definitively use these, they cause trouble at defining struc member ".data" for example etc. And I thought we agreed on "word_word" name form.

3. macro library shouldn't be one big file, i think it should be set of "macro packs" in independent files, and basically user should include them all himself. Of course later we can make include-all-files, but i think this should be left on user. In bigger project you only need to write such file once, and it's worth knowing what you really include and also decrease preprocessing time.

I post my idea at Main -> Fasm Standard Library concept by vid, take a look at it.
Post 16 Jun 2005, 08:35
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number 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-2020, Tomasz Grysztar.

Powered by rwasa.