flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Tomasz Grysztar 09 Jul 2018, 17:01
This feature is present in fasmg with $% symbol. In fasm 1 there is not way to reliably provide such value because of how the formatter works.
It might, however, be possible to back-port $% into fasm 1 restricted only to "format binary" output. I may consider it. |
|||
![]() |
|
DimonSoft 09 Jul 2018, 20:40
Wouldn’t it break the feature that allows saving generated data into multiple files? I mean, should we count all the bytes or bytes of a specific addressing space?
The original problem is nearly always solved by replacing the said $$$ with ($ – $$) since it’s pretty difficult to put code running from another memory location to the boot sector if you play fairly and read FAT12 without implying the secondary bootloader is the first file written to disk and stuff like that. |
|||
![]() |
|
Tomasz Grysztar 09 Jul 2018, 21:13
DimonSoft wrote: Wouldn’t it break the feature that allows saving generated data into multiple files? I mean, should we count all the bytes or bytes of a specific addressing space? |
|||
![]() |
|
DimonSoft 09 Jul 2018, 22:35
I would think about all the possible variations at once since it won’t take long for people to ask more and further (consistent from language point of view) improvements might become more difficult by that time. A language constantly extended with features that are just easy to implement approaches C++ as the number of such features approaches infinity.
|
|||
![]() |
|
Tomasz Grysztar 09 Jul 2018, 22:54
DimonSoft wrote: I would think about all the possible variations at once since it won’t take long for people to ask more and further (consistent from language point of view) improvements might become more difficult by that time. A language constantly extended with features that are just easy to implement approaches C++ as the number of such features approaches infinity. fasmg was designed mostly to be a sum of all the things requested for fasm 1 over the years that were not always possible within the old framework. How it ended up? Actually, for several years I believed this design was impossible, since many of the goals were conflicting. I finally started working on it in 2014 when I found a way to put all these things together in a way that did not make them fall apart immediately. And it seems to work, at least I'm happy with how it works. But because it was so hard to find not a self-contradicting solution in the first place, it is also not so trivial to extend it further. Features that may look simple and consistent with the rest of language at first look, may show multiple problems upon closer inspection. This is also a reason why I prefer to have things implemented through macros and simpler features whenever possible. When something is "just a macro", it is easier to forgive some of the rough edges it might have. But when something has to be a part of underlying language, it should work well with the rest of it, and in case of design like fasmg this is not an easy task. |
|||
![]() |
|
Jin X 20 Aug 2018, 09:56
Tomasz, I like many fasm 1 features but some "things implemented through macros" really irritate.
For instance it's very uncomfortable to add WinAPI function definition in source if it absent in standard inc-files. E.g. I need to use this in the end of source to add only one printf function: Code: section '.idata' import data readable library kernel32, 'kernel32.dll',\ msvcrt, 'msvcrt.dll' import_kernel32 all_api import msvcrt,\ printf, 'printf' Code: section '.idata' import data readable library kernel32, 'kernel32.dll' import kernel32,\ CreateFileA, 'CreateFileA',\ CloseHandle, 'CloseHandle',\ ExitProcess, 'ExitProcess',\ . . . GetFirmwareEnvironmentVariableA, 'GetFirmwareEnvironmentVariableA' api CreateFile api GetFirmwareEnvironmentVariable |
|||
![]() |
|
revolution 20 Aug 2018, 10:49
I can't answer for Tomasz, but if you need to include other DLL files in your code then it is probably a good idea to make a new macro file for each DLL and then add those files as includes to your custom version of win32*.inc.
|
|||
![]() |
|
Tomasz Grysztar 20 Aug 2018, 19:03
These import macros are ancient, dating back to 2000, and their syntax was never re-designed to make use of more modern macro features. It was the backward compatibility that was holding them back and their syntax was made in times when fasm's preprocessor was very simple.
However, even if you wouldn't like to create a different set of import macros, with the features of new fasm versions it should be possible to create some kind of "wrapper" macros around the old syntax. A simple example I made on the spot: Code: macro simport library_label*,label*,string { match ,string \{ define library_label#.collection label,`label \} match any, string \{ define library_label#.collection label,string \} } macro import library_label*,list*& { common local all define all , irpv a ,library_label#.collection \{ all equ all a, \} match alist, all \{ import library_label alist list \} } Code: simport kernel32,GetFirmwareEnvironmentVariableA
api GetFirmwareEnvironmentVariable |
|||
![]() |
|
Jin X 20 Aug 2018, 19:14
Maybe Tomasz can make some macros that will help to add new functions and new dlls?
Something like this: Code: impapi kernel32,\ GetFirmwareEnvironmentVariableA, 'GetFirmwareEnvironmentVariableA' implib msvcrt,'msvcrt.dll' impapi msvcrt,\ printf, 'printf',\ scanf, 'scanf' |
|||
![]() |
|
Tomasz Grysztar 20 Aug 2018, 19:38
Jin X wrote: Maybe Tomasz can make some macros that will help to add new functions and new dlls? |
|||
![]() |
|
Jin X 21 Aug 2018, 09:44
Tomasz, great, thanks!
But how can I add new library using macros like this? E.g. printf from msvcrt. p.s. Please add these macros to fasm 1 includes. |
|||
![]() |
|
Tomasz Grysztar 21 Aug 2018, 21:32
Jin X wrote: Tomasz, great, thanks! Code: macro simport library_label*,label*,string { match ,string \{ define library_label#.collection label,`label \} match any, string \{ define library_label#.collection label,string \} } macro import library_label*,list& { common local all define all irpv a ,library_label#.collection \{ all equ all , a \} match a, list \{ all equ , list all \} match complete, all \{ import library_label complete \} } macro slibrary library_label*,string { match ,string \{ define import_library library_label,`library_label#'.DLL' \} match any, string \{ define import_library library_label,string \} } macro library list& { common local all define all irpv a, import_library \{ all equ all , a \} match complete, list all \{ library complete \} irpv a, import_library \{ match library_label=,string, a \\{ import library_label \\} \} } Code: slibrary msvcrt
simport msvcrt,sprintf |
|||
![]() |
|
Jin X 24 Aug 2018, 05:28
Thanks a lot !!!
|
|||
![]() |
|
Jin X 24 Aug 2018, 05:59
So, if we define simport as:
Code: macro simport library_label*, [label*, string] Code: simport msvcrt, printf,, getch,'_getch', scanf ![]() Last edited by Jin X on 24 Aug 2018, 06:03; edited 2 times in total |
|||
![]() |
|
Jin X 24 Aug 2018, 06:02
Can we convert a string to uppercase to generate 'MSVCRT.DLL' string (instead of 'msvcrt.DLL') on slibrary msvcrt call?
|
|||
![]() |
|
revolution 24 Aug 2018, 06:42
Jin X wrote: Can we convert a string to uppercase to generate 'MSVCRT.DLL' string (instead of 'msvcrt.DLL') on slibrary msvcrt call? Code: slibrary msvcrt,'MSVCRT.DLL' |
|||
![]() |
|
Jin X 24 Aug 2018, 07:03
revolution wrote: Looking at the macro it appears as though you can do this: |
|||
![]() |
|
revolution 24 Aug 2018, 07:14
Jin X wrote: Therefore I thought that it would be great if dll name string converted to upper case automatically. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.