flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
revolution 21 Apr 2008, 18:46
You can easily join string together with the hash (#), no need for %C.
What does this do? "match =. , =name[0]" |
|||
![]() |
|
AsmER 21 Apr 2008, 19:25
@revolution
You are right that by using # we can join strings. Lets try Code: EQU1 equ TEXT EQU2 equ CONNECTED EQU3 equ EQU1 # EQU2 ; RESULT (EQU3): ; TEXT#CONNECTED macro connect { EQU3 equ EQU1 # EQU2 } connect ; RESULT (EQU3): ; EQU1EQU2 macro connect2 { EQU3 equ `EQU1 # `EQU2 } ; RESULT (EQU3): ; 'EQU1EQU2' Well, it does work, but not the way I was talking about. Where: Code: EQU1 equ TEXT EQU2 equ CONNECTED EQU3 equ EQU1 %C EQU2 ; RESULT (EQU3): ; TEXTCONNECTED macro connect { EQU3 equ EQU1 %C EQU2 } connect ; RESULT (EQU3): ; TEXTCONNECTED As for: Quote:
Example: Code: TEST_EQU equ abcdef match any, =TEST_EQU[0] { ... } If Mr Grysztar would implement what I am talking about: any would be matched to a if instead of =TEST_EQU[0] we would write =TEST_EQU[1] any would be matched to b by writing =TEST_EQU[5] any would be equal to f Thanks for your question and interest. Please ask all the questions you have, I'm happy to answer |
|||
![]() |
|
revolution 22 Apr 2008, 02:30
With the "EQU3 equ EQU1 # EQU2" you just put it inside a match to do the text translation.
Code: match a b,EQU1 EQU2 { EQU3 equ a#b } |
|||
![]() |
|
AsmER 22 Apr 2008, 11:43
As for the %C and match matter I must admit that I was pretty confident that the # operator works the same way in macros and matches. However that is working the way I wanted, I still think that the %C (or any other, doing same thing) would simplify the source code (imagine a macro where you need loads of such string connecting operations... what will be easier to read? lets say 20 lines of XXX equ XX %C X, or 20 lines of: match a b, XX X \{ XXX equ a#b \} (optionally with more '\' characters depending on position)or 60 lines when I put it my style- match ..., { next line, ... next line, } next line. Surelly, in this case someone may say: why the heck do you put everything in separate lines? but then I may ask why some people put comments on every single line of code, use HLL structures etc? -thats just how I want it to look like. Our exaple is a very basic one, you should put attention that some macros may need way advanced and by that longer instructions).
Conserning the idea of completly new keyword (selectb, as you sugested) I have been thinking about such option, but again I decided that not using it would be simplier and more readable. For my idea all you need to do is to add additional check on symbols being matched with the 'match' pattern. So: Code: TXT_EQU equ Something index = 3 ; ----- new generation match x] ------ match any, =TXT_EQU[index] { ; 'any' is matched to 'e' letter which is on the offset specified } ; ----- old school match -- ------------- match any, = TXT_EQU[index] { ; 'any' is matched traditional way, therefore equals '=Something[3]' } Additional keyword, which I belive should work somehow like match (creating temporary names of matched symbols) would require construction like: Code: TXT_EQU equ Something selectb char, TXT_EQU, 3 { match =e, char \{ ; actual match goes here in traditional way, 'char' equals 'e' like before \} } As for question about whenever I need it at preprocesor or assembly stage: - This is my idea how to make 'match' more useful and flexible. I know about using virtual, load and store but like vid said (and he seems to be very respected here) "thing about "`", "load" and "store". that is the ugly way." (@ http://board.flatassembler.net/topic.php?t=6577 I found this post today) It realy got me to thinking about the new feature and actually it could be even more powerful. Let me visualize it: Code: TXT_EQU equ SOMETEXT index = 2 length = 5 match any, =TXT_EQU[index:length] { ; 'any' would be matched to 'METEX' } So the idea is to add indexing to set position of start and length to inform how many bytes we want. I really know that it may be pain to code it (depends from how the code handling 'match' is wrote) but think about the power the directive will gain! For example, look at the post I referenced to above. With such functionality it will be a really trivial task: Code: txt_e equ library.procedure index = 0 repeat 0xFF ;say we only wanna test first 256 bytes match =. , =txt_e[index] { break } index = index + 1 end repeat end_offset = 0 repeat 0xFF match =0, =txt_e[end_offset] { break } end_offset = end_offset + 1 end repeat match lib proc, =txt_e[0:index-1] =txt_e[index+1:end_offset-index+1] { ; check it out! ; 'lib' matched to 'library' ; 'proc' to 'procedure' } ; Well in case of =XXX[X:XX] expression, something like 'END' would be cool too. ; We could avoid one 'repeat' loop & second match would be just: match lib proc, =txt_e[0:index-1] =txt_e[index+1:END-index+1] ; or artenatively to have 'END' mean that we want everything up to the end of data ;] so it would be even simplier then: ; match lib proc, =txt_e[0:index-1] =txt_e[index+1:END] Thanks for reply. Of course there will be no such situation where everybody will be 100% happy, therefore I will leave the final and concluding word to Mr Grysztar as he knows what will be best for his assembler (if he notices the topic hehe). [Damn, I'm sooo good at making ideas that are hard to realise ![]() ![]() |
|||
![]() |
|
revolution 22 Apr 2008, 11:52
A lot of your ideas mix the assembler stage and preprocessor stage.
AsmER wrote:
|
|||
![]() |
|
revolution 22 Apr 2008, 12:02
You may be interested in this topic, it shows how the preprocessor can be used to do basic arithmetic and may also help you to see why the assembler and preprocessor can't be used in the way you suggest. You need a different solution.
|
|||
![]() |
|
AsmER 22 Apr 2008, 12:26
Quote:
You didnt read my post carefully, did you? ![]() anyways, there you go: http://board.flatassembler.net/topic.php?t=6577 first post in the topic? (even that it doesnt points at it directly) |
|||
![]() |
|
revolution 22 Apr 2008, 12:36
I saw the link but what I don't see is where you need to do this? MichaelH's example is solvable by simply putting in a colon (:) instead of a dot (.)
|
|||
![]() |
|
AsmER 22 Apr 2008, 12:49
Yeah, the example with a . was showing how to make one's life harder
![]() Since I have forgoten that 'repeat' and 'match' have different priority (or shall I say: are not 'executed' at same stage) the idea doesnt seem that cool anymore (now we would need additional kind of repeat instruction working at preprocessor stage...) I guess the idea itself is pretty good but somehow impossible to realise at the current state of how fasm work (dont worry I'm not going to force Tomasz to rewrite entire code just to have this working (n_n) - i know when to give up ![]() One way or another, I would still like to hear what fasm creator has to say about this matter - maybe he can think of something that will be a solution without need to change anything (or rather: that much :] ) Regards |
|||
![]() |
|
revolution 22 Apr 2008, 12:57
Maybe a 'split', 'find', 'search' or 'extract' preprocessor directive?
|
|||
![]() |
|
AsmER 22 Apr 2008, 13:33
Whatsoever. From my experience the only way to get results you want, is to do things yourself... So as I said, there is idea- how its going to be implemented, I'm not bothered as long as it actually accomplish the task.
Btw, you know the solution with 'virtual' you sugested. I have been trying to see if it works for me, and I faced a problem.. as you definately have better knowledge of fasm macros maybe you could help? I'm trying to get the first letter (yep, no more twisted ideas for today) of whats in equate. i thought that it would be simply to use virtual directive, define bytes string inside it and get first one using 'load'. But the problem is I'm not too sure how to make definition like: match name rest, args { virtual at 0 db name ;< problem here to get 'name' surrounded by quotation marks load my_var byte from 0 end virtual ... } Or am I doing it completly wrong? Tried ` operator but get 'name' instead of actual value of 'name' in between ' characters. Any idea to get 'label_name' when 'name' equals it? |
|||
![]() |
|
revolution 22 Apr 2008, 13:45
Works for me:
Code: match name rest, test_label_junk nothing { virtual at 0 db `name x=0 while x < $ load my_var byte from x display my_var x=x+1 end while end virtual } |
|||
![]() |
|
vid 22 Apr 2008, 13:48
` operator has bigger priority than replacing equates. Do it like this:
Code: match x, name { db `x } |
|||
![]() |
|
vid 22 Apr 2008, 13:50
sorry, i missed that you already have "match" there... next time use [code] tag around code
![]() |
|||
![]() |
|
revolution 22 Apr 2008, 14:31
Maybe irpc would be suitable. We already have irp and irps so one more would be kind of nice.
|
|||
![]() |
|
AsmER 22 Apr 2008, 14:35
Thanks for help guys, but I get a little problem... (why there is always something goin wrong
![]() ok Code: test_label_junk equ .MY_LABEL DWORD match name rest, test_label_junk { virtual at 0 db `name load my_var byte from 0 end virtual display my_var } ; Pretty much revolution's example, just reading first byte as I wanted Displays dot (.) in messages window Code: macro label [args*] { match name rest, args \{ virtual at 0 db `name load label.firstb byte from 0 end virtual display label.firstb \} } label .MY_LABEL DWORD Displays n letter... ![]() Why is second version working differently? |
|||
![]() |
|
revolution 22 Apr 2008, 14:39
You have to "escape" the "`", that is like this
Code: macro label [args*] { match name rest, args \{ virtual at 0 db \`name ;<-- backslash here load label.firstb byte from 0 end virtual display label.firstb \} } label .MY_LABEL DWORD |
|||
![]() |
|
revolution 22 Apr 2008, 14:40
Also, don't forget about 'common', 'forward' and 'reverse' in your macro.
Last edited by revolution on 22 Apr 2008, 16:25; edited 1 time in total |
|||
![]() |
|
AsmER 22 Apr 2008, 14:42
those macros are really complex...
I didnt have as many problems to learn asm language itself (even masm syntax which is weird for some ppl) Thank you for fast reply |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.