flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
Tomasz Grysztar
Recently I've been working on a set of basic compatibility macros for fasmg that would allow to assemble sources written for fasm with its standard Windows headers, with as few changes as possible. I have now completed a version that assembles most of the Win32/Win64 examples from fasm package and I'm attaching it here.
Note that I do think that any such headers for fasmg (or fasm 2, if such ever arrives) could make better use of the macro capabilities of the new engine, therefore I think that developing some entirely new macros with new and improved syntax could be a good direction. But converting the standard fasm's includes is an important first step. Not every behavior of fasm's macros is preserved - for example, as I explained in the other thread, "proc" macro I prepared for fasmg creates a separate namespace for every procedure - because this is how it should have always been working, and it was only because of the limitations of fasm's macro engine that its "proc" did not really work like that (though it at least kept the local data labels limited in scope). This means that local labels inside "proc" no longer need to start with dot. The "struct" and "union" macros I used are the plain ones I created for fasmg, and they do not reproduce the complete behavior of fasm's "struct". This should change later - I still plan to write a variant more compatible with fasm's one for the inclusion in this package, though in general I prefer the new one, for its simplicity and flexibility. Using the new version required some changes of syntax in fasm's examples, because this variant of "union" needs to end with "endu" and the values to initialize fields in structure need to be labeled instead of providing them in original order. When converting the resource macros I was really amazed how old and fossilized they are, with weird syntax choices that date back to the time when fasm had only very basic macro abilities, and implementations that have not been touched in ages. I converted them all, preserving the compatibility, but I think that their syntax really could use some renewal. The same can be said about import macros. Attachment removed. For the latest version of headers please visit the official GitHub repository. Last edited by Tomasz Grysztar on 05 Feb 2019, 15:02; edited 3 times in total |
|||
![]() |
|
uor99
Well done !
|
|||
![]() |
|
uor99
I also hope fasmg can replace fasm in time. It's a pity that some of my written apps fail to compile.
|
|||
![]() |
|
Tomasz Grysztar
I have updated the package with converted Win64 headers and examples.
|
|||
![]() |
|
VEG
Maybe it is better to use ":=" in the equates to ensure that these values will not be changed by accident.
|
|||
![]() |
|
Tomasz Grysztar
VEG wrote: Maybe it is better to use ":=" in the equates to ensure that these values will not be changed by accident. |
|||
![]() |
|
VEG
Code: section '.rsrc' resource data readable directory \ RT_GROUP_ICON, icon_group_list, \ RT_ICON, icon_data_list resource icon_group_list, \ 200, LANG_NEUTRAL, main_icon_group resource icon_data_list, \ 100, LANG_NEUTRAL, main_icon_16_data, \ 101, LANG_NEUTRAL, main_icon_32_data icon main_icon_group, \ main_icon_16_data, '16.ico', \ main_icon_32_data, '32.ico' Code: flat assembler version g.hs4p0 examples\dialog\dialog.asm [120]: icon main_icon_group, \ main_icon_16_data, '16.ico', \ main_icon_32_data, '32.ico' macro icon [9]: data file icon_file:position,size Processed: data file '32.ico':position,size Error: definition in conflict with already defined symbol. Also I propose to add an additional "align 4" in the versioninfo macro (market with +): Code: macro vdata name,value local vs_data,vs_size,value_data,value_size align 4 vs_data dw vs_size,value_size/2 du 1,name,0 align 4 value_data du value,0 value_size = $ - value_data align 4 ; + this one vs_size = $ - vs_data end macro |
|||
![]() |
|
Tomasz Grysztar
VEG wrote: The icon macros tries to redefine the "data" label when there are more than one sources of icons are provided. |
|||
![]() |
|
VEG
resource.h has this line: "started = 1". But this variable isn't used anywhere and it is even not local. It seems that it is a leftover from some other algorithm and can be removed safely.
|
|||
![]() |
|
Tomasz Grysztar
I have added the Challenger Interpreter to the examples, to demonstrate a bit more complex one assembling correctly. And I think that it is oddly fitting into a general theme of fasmg packages.
I found and fixed a couple of bugs in macros when assembling it for the first time. |
|||
![]() |
|
kolpakchi
How can i change the macros to declare proc with no "declaration"?
Code: include 'win32w.inc' format PE GUI 4.0 entry start start: stdcall someProc retn proc someProc ret endp Code: E:\fas>fasmg src.asm src.exe flat assembler version g.hy7gy src.asm [8]: stdcall someProc macro stdcall [48] macro call [1] macro parse_jump_operand [11] macro parse_oper and [10] macro parse_operand_value [31]: ns.imm = +op Processed: @dest.imm = +someProc Error: symbol 'someProc' is undefined or out of scope. There is no error when i append something like "uses ebx" . It caused because no match in proc32.inc , right? Code:
match name declaration, statement
|
|||
![]() |
|
Tomasz Grysztar
This has been fixed in the mean time. Please make sure you have downloaded the latest version (I have started adding the "update date" next to the file).
|
|||
![]() |
|
Kenneth Zheng
Hi, Thomasz:
There is one bug in the fastcall macro. The fastcall macro can't accept immediater >= 0x8000000 parameters. Please see below code in the examples\win64\template.asm: Code: examples\win64\template.asm: CW_USEDEFAULT = 80000000h invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,CW_USEDEFAULT,128,256,192,NULL,NULL,[wc.hInstance],NULL C:\fasmg\examples\x86\examples\win64>fasmg template.asm flat assembler version g.hykpg template.asm [25]: invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,CW_USEDEFAULT,128,256,192,NULL,NULL,[wc.hInstance],NULL macro invoke [1] macro fastcall [116] macro mov [92] macro store_instruction [86] macro simm32 [15] Custom error: immediate value out of signed range. The reason is that the CW_USEDEFAULT = 80000000h, so it will beyond the macro x86.simm32 imm size. Thanks. _________________ Pure Assembly Language Funs |
|||
![]() |
|
Tomasz Grysztar
Thanks, I'm updating the file.
|
|||
![]() |
|
Kenneth Zheng
Hi, Thomasz:
It's okay with the newest fasm_win.zip. Thank you a lot ![]() And please see this file: Code: examples\win64\dll\writemsg.asm: proc DllEntryPoint hinstDLL,fdwReason,lpvReserved mov eax,TRUE ret endp I think that it should use "rax" to instead of "eax" as the returned value. Code: proc DllEntryPoint hinstDLL,fdwReason,lpvReserved mov rax,TRUE ret endp The reason is that it's one 64bit DLL, not 32bit DLL. Are you agree it? Thanks. _________________ Pure Assembly Language Funs |
|||
![]() |
|
revolution
IIRC TRUE == 1, so using either EAX or RAX will still put 1 into RAX, because the top dword of RAX is cleared to zero whenever EAX is written.
Perhaps ideally the code should look like this: Code: if TRUE shr 32 = 0 mov eax,TRUE else mov rax,TRUE end if |
|||
![]() |
|
Tomasz Grysztar
revolution wrote: Perhaps ideally the code should look like this: Code: assert TRUE shr 32 = 0 mov eax,TRUE |
|||
![]() |
|
revolution
It might also be worth noting for anyone not currently aware, and wondering why there is the extra complication, that using EAX instead of RAX produces a smaller code footprint because there is no REX prefix needed.
|
|||
![]() |
|
Tomasz Grysztar
One could also write a MOV macro that would do this additional optimization automatically, similarly to the TEST optimization that was once discussed. Since in case of fasmg instructions are just macros anyway, we could add a package of such optimizations as an optional variant that would not have much overhead compared to the basic ones.
|
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.