flat assembler
Message board for the users of flat assembler.
Index
> Main > flat assembler 1.69.13 Goto page 1, 2 Next |
Author |
|
baldr 11 Apr 2010, 05:54
Tomasz Grysztar,
These are more like suggestions than fix requests, but nevertheless: 1. Can macro operators in macro arguments be properly backslashed during macro expansion? Here is the example: Code: macro iterate_cc [cc_var*, template*] { ;;; invokes template with all condition code mnemonics (valid for jcc) in cc_var irp cc_prefix,,n \{ irp cc_suffix,,e \\{ irps cc_mnemonic, a b g l \\\{ match cc_var,cc_prefix\\\#cc_mnemonic\\\#cc_suffix \\\\{ template; I propose \\\\template syntax, see below \\\\} \\\} \\} irps cc_mnemonic, c e o p s z \\{ match cc_var,cc_prefix\\#cc_mnemonic \\\{ template; \\\template here \\\} \\} \} irps cc_var, pe po cxz ecxz rcxz \{ template; \template \} } iterate_cc cc, jnn#cc equ j#cc 2. When macro is invoked with more actual arguments than formal arguments declared, FASM throws the error "invalid macro arguments". Can this behavior be changed to vararg-like? I.e. last formal argument gets all the rest of actual arguments. I know about [] and common trick, I thought about possibility of "implicit match" between formal and actual arguments: Code: macro @ x,y { add x, y } @ ebx,eax; this will act as the following: match x=,y, ebx,eax { add x, y }; all symbol characters in formal arguments are escaped with = macro ! x+=y { add x, y }; silly, I know ! eax += ebx; this is the same as match x=+==y,eax += ebx { add x, y } macro ! x-=y { sub x, y } ! ecx += edx; current definition won't match, using previous ! eax -= ebx; now current definition matches macro for (element =in list) instruction { irp element, list \{ \instruction \}; backslash escape as proposed above } for (suffix in tsc, pmc) rd#suffix match =(element =in list =) instruction, (suffix in tsc, pmc) rd\#suffix {; I need that backslash... irp element, list \{ instruction \}; to compile this with current FASM (see 1. above) } macro comment endcomment { macro ^ anything \{; This special «^» macro name matches start of line (hello, regexps! ) match =endcomment, anything \\{ purge ^ \\} ; so any line before «endcomment» occurrence is dropped as a whole \} } |
|||
11 Apr 2010, 05:54 |
|
Tomasz Grysztar 11 Apr 2010, 10:58
Ad 1. There's no such thing as "the proper number of backslashes". Preprocessor simply replaces the arguments with their values in the macro text, it doesn't know anything about whether this text itself will become another macro definition or not. And all the possible numbers of backslashes may be useful to macro write - that's why there's such mechanism in the first place (see examples in the Understanding fasm article.
I think that any modification in direction of "automated" escaping would actually make it worse. Ad 2. Since you already know about [] and COMMON, which are there exactly for this purpose - why cannot you use them? |
|||
11 Apr 2010, 10:58 |
|
Tomasz Grysztar 11 Apr 2010, 11:10
Here's a quickly breeded example of how you can make the first one work. Though myself I'd perhaps prefer to define a custom syntax for templates that wouldn't use fasm's reserved operators at all.
Code: macro iterate_cc [cc_var*, template*] { ;;; invokes template with all condition code mnemonics (valid for jcc) in cc_var define _template template irp cc_prefix,,n \{ irp cc_suffix,,e \\{ irps cc_mnemonic, a b g l \\\{ match cc_template,_template \\\\{ match cc_var,cc_prefix\\\#cc_mnemonic\\\#cc_suffix \\\\\{ cc_template \\\\\} \\\\} \\\} \\} irps cc_mnemonic, c e o p s z \\{ match cc_template,_template \\\{ match cc_var,cc_prefix\\#cc_mnemonic \\\\{ cc_template \\\\} \\\} \\} \} match cc_template,_template \{ irps cc_var, pe po cxz ecxz rcxz \\{ cc_template \\} \} } iterate_cc cc, jnn\\#cc equ j\\#cc |
|||
11 Apr 2010, 11:10 |
|
baldr 11 Apr 2010, 12:40
Tomasz Grysztar,
Escaping is not "automated", it's kinda "propagated". I mean that occurrence of «\template» (given that actual template argument passed to macro is «jnn#cc equ j#cc») will be replaced with «\jnn\#\cc \equ \j\#\cc». This feature will give finer control of macro operators' context and argument replacement (if actual argument contains escaped symbols, they will be escaped more). Vararg arguments are already partially implemented: you can pass less arguments than declared. [] and common looks like workaround (it works, but source became slightly less readable: you need to examine entire macro to decide whether this argument is indeed iterated in forward block or just "from here to the end" kind). I'll try to implement these features to see if they're as useful as I think. Implicit match is entirely different issue, it requires good consideration (and alot of coding, I suppose). Special "caret" macro to process entire line? Hmmm… maybe. Your example is analogous to my workaround #2 (thanks for efforts!), only I've used equ instead of define. First workaround was to implement template as separate macro (macro def_jnncc cc { jnn#cc equ j#cc }, then iterate_cc cc, def_jnncc cc). |
|||
11 Apr 2010, 12:40 |
|
Tomasz Grysztar 11 Apr 2010, 13:03
baldr wrote: Escaping is not "automated", it's kinda "propagated". I mean that occurrence of «\template» (given that actual template argument passed to macro is «jnn#cc equ j#cc») will be replaced with «\jnn\#\cc \equ \j\#\cc». The "\template" is currently not replaced by preprocessor at all - it just strips the backslash and the result is left in text, and MAY be later interpreted again by another macro constructor - that's how the escaping works. If you change this behavior, you're going to break some of the existing macros (including the one from "Understanding fasm" I pointed out to you). baldr wrote: Vararg arguments are already partially implemented: you can pass less arguments than declared. This has nothing to do with varargs, you simply can omit a few arguments and they have an empty value then. baldr wrote: [] and common looks like workaround (it works, but source became slightly less readable: you need to examine entire macro to decide whether this argument is indeed iterated in forward block or just "from here to the end" kind). |
|||
11 Apr 2010, 13:03 |
|
baldr 11 Apr 2010, 13:30
Tomasz Grysztar,
Do you mean Defx and Parent / Child examples? Formal arguments are just placeholders, aren't those "name conflicts" artificial? I understand, they're written the way they are to demonstrate concept of backslash escape, but in real life I'd better name them differently if they have different purpose/context/whatever. "Workaround" reference is related to only single case: when macro should accept arbitrary number of arguments and not going to iterate through them but use them as a whole. common and forward / reverse are unique features of FASM and I love them. I'm not trying to convince you that those ideas are good or worth something. I'll give them a try and decide. |
|||
11 Apr 2010, 13:30 |
|
edemko 12 Apr 2010, 05:32
I'm not strong in macro so... how about FileAssociations dialog in fasmw.exe.
For you to be easy i did not improve it to the end i.e. there will be nothing stored to the registry and you will get appropriate messages only('%type% reg- istered', '%type% unregistered'). While writing it i was wondering a directive over fix one: Code: chunk patch1{ mov eax,2 db 'lalala',\ 'oops ops etc' ;etc } chunk patch2{ ;etc etc } ... patch1 ... patch2 Well, all the patches to 'fasmw.asm' marked with ';;'. Use \menu Options\Asserts...\ to see what they do. Code: 1173: ;; cmp eax,IDD_ASSERTS je asserts ;; 3162: \;; IDD_ASSERTS,0,idd_asserts,\ \;; 3312: ;; menuitem 'A&sserts...',IDD_ASSERTS ;; 3489: ;; IDD_ASSERTS = 0 dialog idd_asserts,'',0,0,250,18,WS_CAPTION+WS_SYSMENU;,,,'Courier New',8 dialogitem 'edit' ,'' ,ID_EXPRESSION ,3,3,200,12 ,WS_VISIBLE+WS_TABSTOP+ES_AUTOHSCROLL+WS_BORDER dialogitem 'button' ,'ok' ,IDOK ,216,3,30,12 ,WS_VISIBLE+WS_TABSTOP ,WS_EX_STATICEDGE enddialog asserts: invoke DialogBoxParam,[hinstance],IDD_ASSERTS,dword[ebp+8],.wndproc,0 jmp finish .asserts db 'asserts',0 .def_asserts db 'to* bundle* a* type* end*it*with* & vice-versa',0 .szASSERTS = 4096 .wndproc:;wnd,msg,wParam,lParam push ebx ebp esi edi lea ebp,[esp+20] cmp dword[ebp+4],WM_CLOSE je .wm_close cmp dword[ebp+4],WM_INITDIALOG je .wm_initdialog cmp dword[ebp+4],WM_COMMAND jne .exit cmp dword[ebp+8],IDOK jne .exit ;START ok button pressed sub esp,.szASSERTS invoke SendDlgItemMessage,dword[ebp],ID_EXPRESSION,WM_GETTEXT,.szASSERTS,esp mov esi,esp push eax invoke WritePrivateProfileString,_section_options,.asserts,esi,ini_path cld pop ecx inc ecx mov edi,esi .load: lodsb cmp al,' ' jne .not_space .space: lea edx,[edi+1] neg edx add edx,esi cmovz edi,esi jz .start_updated ;< cmp al,'*' mov eax,_key_compiler_passes ;'passes' mov edx,_priority_settings ;'idle' cmovne eax,edx push ecx mov byte[esi-1],0 invoke MessageBox,dword[ebp],edi,eax,0 pop ecx mov edi,esi ;if al='*' then %ASSIGN% else %UNASSIGN% ;restore ecx ;edi = esi ;< jmp .start_updated .not_space: test al,al jz .space cmp al,9 je .space cmp al,10 je .space cmp al,13 je .space cmp al,'*' je .space .start_updated: loop .load .done: add esp,.szASSERTS jmp .wm_close ;END ok button pressed .wm_initdialog: invoke SendMessage,dword[ebp],WM_SETTEXT,0,.asserts sub esp,.szASSERTS mov eax,esp invoke GetPrivateProfileString,_section_options,.asserts,.def_asserts,eax,.szASSERTS,ini_path invoke SendDlgItemMessage,dword[ebp],ID_EXPRESSION,WM_SETTEXT,0,esp add esp,.szASSERTS jmp .exit .wm_close: invoke EndDialog,dword[ebp],'cool' .exit: xor eax,eax pop edi esi ebp ebx ret 16 ;;
|
|||||||||||
12 Apr 2010, 05:32 |
|
edemko 24 Apr 2010, 06:02
Like a baby i am:)
-eager active line highlight; fasm is a default *.txt,*.ini,*.inf etc reader in our system and taking a rest makes tired searching for a line; of course we can make selection before -some ini-option could be included "Allow nested comments", plea-ea-ea-ea-ea-ea-ea-ea-ea-sss-eeeeeee :\ ok, here is my nipple(we are studying on Saturdays) |
|||
24 Apr 2010, 06:02 |
|
Picnic 27 Apr 2010, 17:27
version 1.69.14 (Apr 26, 2001) <--
[-] Fixed corruption of stored state of nested structures in case when they were closed out of order. |
|||
27 Apr 2010, 17:27 |
|
edfed 27 Apr 2010, 17:50
it doesn't compile correctlly shell.asm http://board.flatassembler.net/download.php?id=4910
but 1.68 does. when comparing both files, it appears a lot of differences. maybe due to alignment... |
|||
27 Apr 2010, 17:50 |
|
baldr 28 Apr 2010, 05:16
edfed,
Both don't, because included "crypt001.txt" is missing. With it (empty) they compile to almost identical binaries, except (I skip incidental differences, like rel8 in jcc changed due to those listed):
Hell, man, aren't you curious enough to look into those differences yourself? It's your code! |
|||
28 Apr 2010, 05:16 |
|
edfed 28 Apr 2010, 07:39
ok, i see the thing.
but it means something i don't understand. what should be the prefix? corrected with call near eXx, still don't work. Last edited by edfed on 28 Apr 2010, 07:46; edited 1 time in total |
|||
28 Apr 2010, 07:39 |
|
revolution 28 Apr 2010, 07:44
edfed: It is not the 'near' that you need, it is the opsize prefix '0x66'.
Without the opsize prefix the instruction is 'call ax'. So previously fasm was generating the wrong instruction. Change all your 'call eXx' to 'call Xx' and you will get back your original binary. |
|||
28 Apr 2010, 07:44 |
|
baldr 28 Apr 2010, 07:46
Have anyone detected silent update to 1.69.14?
|
|||
28 Apr 2010, 07:46 |
|
edfed 28 Apr 2010, 07:47
ok, that was that point that leaved me in error state.
i correct this right now then. |
|||
28 Apr 2010, 07:47 |
|
revolution 28 Apr 2010, 07:49
baldr wrote: Have anyone detected silent update to 1.69.14? http://board.flatassembler.net/topic.php?t=11413 And here: http://board.flatassembler.net/topic.php?t=11471 And here: http://board.flatassembler.net/topic.php?t=11466 |
|||
28 Apr 2010, 07:49 |
|
edfed 28 Apr 2010, 07:55
ok, got it right now.
i was very far to think about a missing prefix as i debug with Hxd to see the labels where error occurs, but there was no error, nothing worked at all. then, let's upadate to 1.69.14 and use rss |
|||
28 Apr 2010, 07:55 |
|
edemko 10 May 2010, 17:58
Tomasz, (hi) make display dialog with a mono-width font please: eyes tired.
= Thanks |
|||
10 May 2010, 17:58 |
|
Tomasz Grysztar 10 May 2010, 18:45
edemko wrote: Tomasz, (hi) make display dialog with a mono-width font please: eyes tired. |
|||
10 May 2010, 18:45 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.