flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > String directives for manipulating text |
Author |
|
Vortex 14 Nov 2003, 19:13
Is it possible to code some Masm string manipulation directives for Fasm?
The directives are: Code: SUBSTR Assigns part of string to a new symbol. INSTR Searches for one string within another. SIZESTR Determines the size of a string. CATSTR Concatenates one or more strings to a single string. More detailed explanation at Masm programmer's guide / Chapter 9 - String Directives and Predefined Functions : http://webster.cs.ucr.edu/Page_TechDocs/MASMDoc/ProgrammersGuide/Chap_09.htm _________________ Code it... That's all... |
|||
14 Nov 2003, 19:13 |
|
Vortex 06 Dec 2003, 09:36
Hi Privalov,
How can I build the CATSTR macro with the "virtual" and "load" directives? _________________ Code it... That's all... |
|||
06 Dec 2003, 09:36 |
|
Tomasz Grysztar 06 Dec 2003, 13:08
This one is done with # operator in latest fasm.
|
|||
06 Dec 2003, 13:08 |
|
Vortex 07 Dec 2003, 19:59
Hi Privalov,
Thanks for your help. I am trying to build a kind of substr macro: Code: macro substr param { virtual at 0 string db param load a0 byte from 0 load a1 byte from 1 load a2 byte from 2 load a3 byte from 3 load a4 byte from 4 end virtual } param is a quoted string like 'mystring' In this macro,I can get the first five characters;but how can I define a symbolic constant containing the first x characters of param? Or is it possible to extend the load directive for symbolic constants? Example: Code: load mystr <byte number> from 0 Here,mystr is a symbolic constant and the byte number is any integer number for the load directive. _________________ Code it... That's all... |
|||
07 Dec 2003, 19:59 |
|
Tomasz Grysztar 07 Dec 2003, 20:36
It's impossible, because directives operating on numbers, like "load" processed at assembly time, and symbolic constants (and macros) are processed by preprocessor.
But please tell for what purpose do you need such thing, so we can think about some other solution. |
|||
07 Dec 2003, 20:36 |
|
Vortex 08 Dec 2003, 11:12
Hi Privalov,
The substr ( + strcat) macro like in masm would be very usefull for fasm. For example,finding the last character of a macro parameter to determine if it's an ANSI function: Code: MessageBoxA I want to improve my scan and inc2inc tools, that's why I need these two macros. Implementing these macros would enhance a lot Fasm. _________________ Code it... That's all... |
|||
08 Dec 2003, 11:12 |
|
Tomasz Grysztar 08 Dec 2003, 13:51
For such purpose this should be sufficient:
Code: macro test apiname { virtual at 0 db apiname load last byte from $-1 end virtual if last = 'A' | last = 'W' display apiname,' is an ANSI function.',13,10 else display apiname,' is not an ANSI function.',13,10 end if } test 'ExitProcess' test 'MessageBoxA' I mean that you can always find a solution using the existing features - they are just a bit different, and the macros have to be designed the other way, but they are powerful, too. |
|||
08 Dec 2003, 13:51 |
|
Vortex 08 Dec 2003, 18:11
Privalov,
Thanks for the example. I hope I will find a way to build the substr macro _________________ Code it... That's all... |
|||
08 Dec 2003, 18:11 |
|
Tomasz Grysztar 08 Dec 2003, 19:39
Finding a way is not the main problem, the main problem is to convince me that it would really be neccessary to implement it, as I believe that every such problem can be solved actually by using the features fasm already has. You just have to design your macros using completely different methods - the "fasm way of thinking". And I don't like the idea of littering the fasm's syntax with new complicated constructs that are not really neccessary. When I implement some new feature into fasm, I try to solve as many problems as possible with very few, universal syntax extensions. This way I want to keep fasm simple and consistent, but powerful at the same time. That's why it sometimes takes me very long time before I decide to implement some new feature, as I'm always trying to invent the most simple and universal solution - hopefully I haven't failed yet...
And, BTW, when I was implementing the "load" directive with ability to load from already generated code, I also had in mind the method of doing all such operations on strings. And I thought it was enough - I was even able to make nice UTF-8 to Unicode conversion macro this way (look here). |
|||
08 Dec 2003, 19:39 |
|
Vortex 23 Mar 2004, 10:59
Hi Privalov,
With the new directive "store" added to Fasm pre-release 1.52, have I chance to code the string manipulation directives above? _________________ Code it... That's all... |
|||
23 Mar 2004, 10:59 |
|
Tomasz Grysztar 23 Mar 2004, 12:14
Depends on what do you want to achieve. Remember that the "virtual", "load" and "store" are all assembly-time mechanism, and they involve a "philosophy of usage", which is a bit different from the one used in macros for MASM.
|
|||
23 Mar 2004, 12:14 |
|
Vortex 01 Apr 2004, 10:13
Hi Privalov,
Is it possible to have a new instruction assigning virtual strings to symbolic constants? For example: Code: virtual at 0 db 'Flat assembler',0 end virtual mystr assign 0 Here, the assign statement assigns the virtual string "Flat assembler" to the symbol constant mystr. The zero means that the strings starts at virtual address 0 Or because of technical reasons, instead of using symbolic constants, maybe we can think about creating some new type of variables accepting this style of assignment. _________________ Code it... That's all... |
|||
01 Apr 2004, 10:13 |
|
Tomasz Grysztar 01 Apr 2004, 10:54
Impossible again for the reason that virtual blocks are processed by assembler, and symbolic constant by preprocessor.
Keep in mind that preprocessor is string-based only, and the assembler is value-based. |
|||
01 Apr 2004, 10:54 |
|
revolution 31 Aug 2004, 07:26
In my mind this is something that FASM really needs to be truly powerful and flexible. I have become so used the the TASM and MASM ability to do whatever I want with symbols and string manipulation that it has been a real headache to try to convert these programs to FASM style.
But all the same I still choose to use FASM and my assembler of choice because of the other features I can coax it to do. I do not know enough of the FASM internals to properly understand the difficulty but could something like the ofllowing be possible: Step 1: do normal preprocessing etc. before actual assembly. Step 2: during assembly if we encounter command/directive/construct that requires assigning a string like the above we flag all points in the file with appropriate values and restart the preprocess at Step 1. Once all stings/etc. have been assigned then do the normal assemble and we're done. Sorry if this seems naive or stupid but with many people wanting such a feature it might be worth considering how to solve this. |
|||
31 Aug 2004, 07:26 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.