flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > interesting tweak Goto page 1, 2 Next |
Author |
|
crc 28 Jul 2004, 10:43
Very cool -- now it's pretty close to the syntax I'm using in the assembler I'm writing for use with RetroForth
|
|||
28 Jul 2004, 10:43 |
|
fasm9 28 Jul 2004, 10:59
awesome!
-- PS: In VIM, you can change it like this. debian:~/fasm/source# vi assemble.inc :329s/extra_characters_on_line/assemble_line :wq debian:~/fasm/source# _ |
|||
28 Jul 2004, 10:59 |
|
crc 28 Jul 2004, 12:05
Any chance of being able to use macros with this? I use a bunch of macros that don't take arguments and would love to be able to string them together with assembly code
|
|||
28 Jul 2004, 12:05 |
|
Tomasz Grysztar 28 Jul 2004, 17:06
I'm afraid preprocessor cannot be tweaked so simply.
|
|||
28 Jul 2004, 17:06 |
|
Joshua 28 Jul 2004, 17:31
Well if you could get this to work on preprocessor too, it would solve our multiline fix problem!
Thanks, and keep at it... PS i hope this tweak (and the preproccor part) can make it in the official version, although i still think a specific character for allowing this would be better |
|||
28 Jul 2004, 17:31 |
|
Tommy 28 Jul 2004, 17:35
I agree Joshua...
|
|||
28 Jul 2004, 17:35 |
|
Tomasz Grysztar 28 Jul 2004, 18:19
I'm not going to include it in official releases, too confusing trick. That's why I only posted it here as a kind of curiosity.
But for your problem Joshua, here's another, a bit more complex modification, which I may include in next official version. All modifications have to be made in PREPROCE.INC 1) find "preprocess_line" label (line 248), after: Code: push [struc_name] push ecx esi put new label: Code: preprocess_current_line: 2) find "skip_macro_block" label (line 960), before the "skip_macro_symbol" you have the instructions: Code: lods byte [esi] or al,al jnz extra_characters_on_line and [macro_status],0F0h jmp line_preprocessed Change them to: Code: and [macro_status],0F0h lods byte [esi] or al,al jz line_preprocessed dec esi mov ecx,edi sub ecx,esi lea esi,[esi+ecx-1] lea edi,[edi+1+16] mov ebx,edi dec edi std rep movs byte [edi],[esi] cld sub edi,16-1 mov byte [edi-1],0 mov esi,[current_line] mov [current_line],edi mov ecx,4 rep movs dword [edi],[esi] mov edi,ebx jmp preprocess_current_line skip_macro_symbol: movzx eax,byte [esi] inc esi add esi,eax jmp skip_macro_block skip_macro_string: lods dword [esi] add esi,eax jmp skip_macro_block This allows putting any instruction or directive in the line after the } symbol ending macro definition. Example of possible usage: Code: macro struct name { common name@struct fix name struc name { } macro struct_helper name { virtual at 0 name name sizeof.#name = $ - name name equ sizeof.#name end virtual } ends fix } struct_helper name@struct ; And now some nice definition: struct RECT .left dd ? .top dd ? .right dd ? .bottom dd ? ends |
|||
28 Jul 2004, 18:19 |
|
crc 28 Jul 2004, 23:23
Quote: I'm not going to include it in official releases, too confusing trick. That's why I only posted it here as a kind of curiosity. I can understand that. Even so, I think I'll keep the hack in my copy of FASM |
|||
28 Jul 2004, 23:23 |
|
Tomasz Grysztar 29 Jul 2004, 09:53
Question to everyone: would you want/accept this second change (allowing instructions/directives after macro ending character) in official releases?
|
|||
29 Jul 2004, 09:53 |
|
decard 29 Jul 2004, 10:08
Of course, as it would make FASM preprocessor more powerful
|
|||
29 Jul 2004, 10:08 |
|
Tommy 29 Jul 2004, 10:22
Yes! That would be great, Privalov!
|
|||
29 Jul 2004, 10:22 |
|
crc 29 Jul 2004, 10:49
Sure, keep the second change in the official releases. It doesn't hurt anything from what I've seen, and actually makes some things easier
|
|||
29 Jul 2004, 10:49 |
|
Tomasz Grysztar 29 Jul 2004, 11:27
OK, I will also replace the "struct" macro in the standard includes with this version - it makes the includes much more elegant.
|
|||
29 Jul 2004, 11:27 |
|
Tomasz Grysztar 29 Jul 2004, 12:57
One side-effect of this feature is that you can define multiple macros in the same line, like:
Code: macro alpha {db 1} macro beta {db 2} macro gamma {db 3} |
|||
29 Jul 2004, 12:57 |
|
pelaillo 29 Jul 2004, 13:03
Very good!
Even the first tweak could be in the official release as long as it didn't become an habit to write such kind of code. In other words, compiler has the power but programmers the good sense to write readable code, given that even without the tweax exist the possibility to write obfuscated code |
|||
29 Jul 2004, 13:03 |
|
Imagist 29 Jul 2004, 14:49
If bad programmers start abusing the powers you add to FASM, you can just remove the changes from the next version of FASM.
Ugh, I can't imagine the horror of wading through a FASM program written on one line. I've done it with a C program that had been reverse compiled and posted on a site (the guy's program wasn't programmed to add white space) and that was miserable, but at least then I had semicolons to tell me where the statements ended. I like FASM the way it is. There's no point adding stuff that no good programmer will ever use. But it's like I said, if it becomes a problem you can always take it out. |
|||
29 Jul 2004, 14:49 |
|
vid 29 Jul 2004, 18:23
i like second one (commands behind "}"), unless it little bit "unsyntactical" it solves few problems so it's OK.
First one, of course, no. |
|||
29 Jul 2004, 18:23 |
|
Tomasz Grysztar 29 Jul 2004, 18:32
vid: so we agree.
|
|||
29 Jul 2004, 18:32 |
|
Joshua 29 Jul 2004, 18:35
Thanks priv! This is all i needed...
Now for the next question: When will the new official fasm version (with this feature in it) be released? |
|||
29 Jul 2004, 18:35 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.