flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
bitRAKE 30 Jun 2013, 19:30
Short answer is, No.
Long answer is that these sections can be wrapped in a macro, which the main source file instances in the proper section. Okay, it's not that long of an answer because I didn't include an example. |
|||
![]() |
|
bitRAKE 30 Jun 2013, 19:39
All the auxiliary files would have something like:
Code: macro code1.inc section { match =CODE,section \{ <some code> \} match =DATA,section \{ <some data> \} } Code: FILES fix code1.inc,code2.inc,... irp T,FILES { include `T } Last edited by bitRAKE on 02 Jul 2013, 02:02; edited 1 time in total |
|||
![]() |
|
typedef 30 Jun 2013, 21:16
"Flat" Assembler
![]() ![]() |
|||
![]() |
|
revolution 30 Jun 2013, 23:57
SokilOff wrote: So here's the question: is there a way to tell fasm just to merge sections with the same names from different files ? |
|||
![]() |
|
SokilOff 01 Jul 2013, 15:09
bitRAKE wrote: All the auxiliary files would have something like: Thank you for your answer ! Atm I'm trying to create simple example using your suggestion. The problem is it cannot see external procedure from .inc It looks like this: main.asm Code: format PE GUI 4.0 entry start include 'win32ax.inc' include 'code1.inc' IDD_MainDlg = 1 FILES fix code1.inc .code irp T,FILES { T CODE } start: invoke GetModuleHandle, 0 invoke DialogBoxParam, eax,IDD_MainDlg, HWND_DESKTOP, DialogProc, 0 invoke ExitProcess,0 proc DialogProc hwnddlg, msg, wParam, lParam push ebx esi edi cmp [msg], WM_COMMAND je .wmcmd cmp [msg], WM_CLOSE je .wmclose xor eax, eax jmp .finish .wmcmd: cmp [wParam], BN_CLICKED shl 16 + IDOK jne @f invoke MessageBox,HWND_DESKTOP, msg_ok, caption_ok, MB_ICONINFORMATION jmp .done @@: cmp [wParam], BN_CLICKED shl 16 + IDCANCEL jne .done stdcall ExternalProc ; <--- procedure call from code1.inc jmp .done .wmclose: invoke EndDialog,[hwnddlg],0 .done: mov eax, 1 .finish: pop edi esi ebx ret endp .data irp T,FILES { T DATA } msg_ok db 'Message from OK button', 0 caption_ok db 'Caption from OK button', 0 section '.idata' import data readable writeable library kernel,'KERNEL32.DLL',\ user,'USER32.DLL' import kernel,\ GetModuleHandle,'GetModuleHandleA',\ ExitProcess,'ExitProcess' import user,\ DialogBoxParam,'DialogBoxParamA',\ MessageBox,'MessageBoxA',\ EndDialog,'EndDialog' section '.rsrc' resource data readable directory RT_DIALOG,dialogs resource dialogs,\ IDD_MainDlg,LANG_ENGLISH+SUBLANG_DEFAULT,demo dialog demo,'Create message box',70,70,140,35,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME dialogitem 'BUTTON','OK',IDOK,15,10,45,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON dialogitem 'BUTTON','C&ancel',IDCANCEL,75,10,45,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON enddialog code1.inc Code: macro code1.inc section { match =code,section \{ proc ExternalProc invoke MessageBox, HWND_DESKTOP, msg_cancel, caption_cancel, MB_ICONINFORMATION ret endp \} match =data,section \{ msg_cancel db 'Message from Cancel button', 0 caption_cancel db 'Caption from Cancel button', 0 \} } |
|||
![]() |
|
bitRAKE 01 Jul 2013, 16:53
MATCH is case sensitive. "=code" will not work if you use "CODE" in the main file.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
![]() |
|
SokilOff 01 Jul 2013, 17:40
bitRAKE wrote: MATCH is case sensitive. Indeed, it did the trick. I should have read manual without skipping some parts ![]() Quote: It's important to note that all macroinstructions, as opposed to internal directives of flat assembler, are case sensitive Thanks a lot, bitRAKE ! Hopefully it will help to someone else in the future. |
|||
![]() |
|
SokilOff 02 Oct 2013, 11:58
Another small question.
If I add any local variable to procedure from auxiliary .inc like this: Code: match =code,section \{ proc ExternalProc local var_1:DWORD ; <------ invoke MessageBox, HWND_DESKTOP, msg_cancel, caption_cancel, MB_ICONINFORMATION ret endp \} I get "Error: extra characters on line". Why ? And how to fix it ? |
|||
![]() |
|
Tomasz Grysztar 02 Oct 2013, 13:17
The "local" inside a macro (and "match" block is also a kind of macro) has a different meaning, it is a directive that defines local symbols inside a macro, and it expects the parameters to be a simple list of comma-separated names - that's why it signalizes an error when it enounters ":".
To avoid "local" being interpreted by macro processor you have to escape it, in this case twice - once for the outer macro, and once for the inner "match": Code: match =code,section \{ proc ExternalProc \\local var_1:DWORD invoke MessageBox, HWND_DESKTOP, msg_cancel, caption_cancel, MB_ICONINFORMATION ret endp \} The other solution would be to use the "fix" directive to redefine the "local" keyword, to get rid of the conflict at all. |
|||
![]() |
|
SokilOff 02 Oct 2013, 16:30
Thank you, Tomasz, for detailed explanation. Those nested macro are tricky sometimes.
Do you have any plans for FASM 2.0 to simplify code merging/separation in cases like this ? |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.