flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > How to determine string or number during preprocessing? |
Author |
|
Tomasz Grysztar 22 Sep 2012, 17:49
I think it was discussed before: http://board.flatassembler.net/topic.php?p=90836
|
|||
22 Sep 2012, 17:49 |
|
JohnFound 22 Sep 2012, 18:08
Yes, I just reinvented the wheel and found this solution myself.
Although, it is not working as described. I use following code in order to get it to work: Code: match x, `arg { match x, arg \{ flg equ TRUE \} } EDIT: Never mind, I found the mistake - missing "\". It works now. Last edited by JohnFound on 22 Sep 2012, 18:17; edited 1 time in total |
|||
22 Sep 2012, 18:08 |
|
Tomasz Grysztar 22 Sep 2012, 18:17
What do you mean by "not working as described"? This works correctly for me:
Code: macro tellquoted param { match `param,param \{ display "Yes, it's a quoted string: ",param,13,10 \} } tellquoted 'ABCD' tellquoted abcd tellquoted 1234 |
|||
22 Sep 2012, 18:17 |
|
JohnFound 22 Sep 2012, 18:18
Yes, I found the problem. It was missing "\". Fixed and works now. Thank you for the help.
|
|||
22 Sep 2012, 18:18 |
|
l_inc 22 Sep 2012, 20:24
JohnFound
I'm not really using FreshLib (just took a couple of ideas from there), but if I used it, I'd prefer to have something like this, because it's sometimes very handy to pass a number in the form of 'Hi.' . Besides, it's very useful to be able to pass strings with non-printable characters like 'Hello',13,10,'World!', which would be impossible with your approach. An uncontrollable null-character at the end of such strings is also an unpleasant side-effect of your approach. |
|||
22 Sep 2012, 20:24 |
|
JohnFound 22 Sep 2012, 20:36
l_inc, the exact syntax of the latest macros allows all of described options.
Code: stdcall MyProc, <"Hello", 13, 10, "World!"> The strings that are single and up to dword are pushed directly: Code: stdcall MyProc, '1234' ; will generate: push '1234' ; instead of: push lbl? lbl? text '1234' If you need short strings defined as pointer (rare case) you can use: Code: stdcall MyProc, <'123','4'> What kind of control you need on the terminating character? |
|||
22 Sep 2012, 20:36 |
|
l_inc 22 Sep 2012, 20:42
JohnFound
Quote: the exact syntax of the latest macros allows all of described options. Oh. Sorry. I didn't think, you implemented it. Quote: What kind of control you need on the terminating character? Well... it's presence. If you allowed non-printable characters to be a part of such strings, then it's also reasonable to allow the user to decide, whether he or she wants to add the null-character: Code: stdcall MyProc, <"Hello", 13, 10, "World!", 0> Btw. Do you also allow to pass one string in Unicode and one string in ASCII? |
|||
22 Sep 2012, 20:42 |
|
JohnFound 22 Sep 2012, 21:09
l_inc wrote: Btw. Do you also allow to pass one string in Unicode and one string in ASCII? Yes and No. If you talk about Windows Unicode (UTF-16) - then "No". This is intentional, because you simply can't use UTF-16 with FASM in this moment. I know FASM have "du" directive, but you can define text using only ASCII text - i.e. less than 256 symbols. On the other hand, FreshLib uses only UTF-8, so if you have UTF-8 source, "text" macro will define Unicode string in UTF-8 encoding. Note, that FASM can compile UTF-8. Also, the future Fresh IDE 3.0 will be equipped with fine Unicode source editor. _________________ Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9 |
|||
22 Sep 2012, 21:09 |
|
l_inc 22 Sep 2012, 21:21
JohnFound
Quote: I know FASM have "du" directive, but you can define text using only ASCII text - i.e. less than 256 symbols. The du directive is redefined by the standard encoding macros, which convert zero-extended ASCII-characters into Unicode using the corresponding code tables. Therefore fasm does support definition of UTF-16 strings. And it would be useful to be able to specify, that I'd like to use the du directive to define a string. In the previously linked example this looks as follows: Code: invoke MessageBox,NULL,<ustring "Hello, world!",0>,<ustring "Title",0>,MB_OK Both strings would be defined in Unicode, and I could use Cyrillic as well. |
|||
22 Sep 2012, 21:21 |
|
JohnFound 22 Sep 2012, 21:36
You can use Cyrillic, only if your editor is configured to use Cyrillic font.
But you can't use "Cyrillic" and "Japan" in the same time, while using UTF-8, it is possible. FreshLib has some examples using several languages at once: |
|||
22 Sep 2012, 21:36 |
|
l_inc 22 Sep 2012, 21:44
JohnFound
Quote: But you can't use "Cyrillic" and "Japan" in the same time, while using UTF-8, it is possible. That's true. But how about using Unicode functions with Roman? Do understand it right, that the following will display trash with your macros? Code: invoke MessageBoxW ,NULL,"Hello, world!","Title",MB_OK |
|||
22 Sep 2012, 21:44 |
|
JohnFound 22 Sep 2012, 21:56
Yes, it will.
But note, that FreshLib is not intended to be used this way (although it is not forbidden) because the programs written with FreshLib are intended to be portable. So, you should not use "MessageBoxW", but: Code: stdcall ShowMessage, [parent], smiInformation, 'Title', 'Message text.', smbOK The above procedure needs UTF-8 encoding and will be compiled properly for Windows and Linux with every language you want. |
|||
22 Sep 2012, 21:56 |
|
l_inc 22 Sep 2012, 22:07
JohnFound
Quote: The above procedure needs UTF-8 encoding and will be compiled properly for Windows and Linux with every language you want. Sounds really cool. But also requires really much support. Then last question regarding this fact. Let's say, I'd like to open an image saved in BMP, draw some text above it and save it in PNG format. I'd use GDI+ for that, which requires Roman in Unicode at some places. Would it be possible to do the same using the portable features of FreshLib only? |
|||
22 Sep 2012, 22:07 |
|
JohnFound 22 Sep 2012, 22:34
l_inc wrote: Would it be possible to do the same using the portable features of FreshLib only? Not in this moment, but definitely it will be possible one day. For now, FreshLib has limited features, because I can't write everything as quick as I want. In this very moment you can open .gif image, write some text ( UTF-8 ) and display it on some window. Of course you can draw the text directly on the window as well. .png support is planned but not implemented yet. _________________ Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9 Last edited by JohnFound on 22 Sep 2012, 22:47; edited 2 times in total |
|||
22 Sep 2012, 22:34 |
|
l_inc 22 Sep 2012, 22:40
JohnFound
Thank you for the answers. Now I have at least more understanding of the FreshLib motivation. But converting fasm into java sounds to me too laborious. |
|||
22 Sep 2012, 22:40 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.