flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
bitRAKE 08 Mar 2025, 00:13
I'd like a complete example to understand better.
If you have a problem with recognition of the whole (i.e. the assembler 'seeing' the tokens as separate) then switch to using #, imho. Code: calminstruction dis_play A*,B* local var,val arrange var,A#B arrange val,var 10,'dis_play',10 assemble val stringify var display var end calminstruction dis_play dis,play |
|||
![]() |
|
Tomasz Grysztar 08 Mar 2025, 08:56
fasmg, like fasm, operates on tokenized text, but while fasm is dropping all the whitespace, fasmg includes whitespace as special tokens in the stream. This allows it to recognize presence of the whitespace when needed, while fasm was unable to do so.
Normally it is not possible to have consecutive name tokens in the stream without a whitespace token in between, because these names needed to be separated somehow in the text before tokenization. But it is possible to artificially produce such sequence of tokens, a fasm1-like sequence, one might say. I believe it was first made possible when I introduced the feature of identifiers starting with "?". It is a trick, though, and may have various side effects, like making debugging harder, because converting such token sequence back to text is going to blend the two name tokens together, as there was no whitespace token between them, but they were two separate tokens nonetheless. |
|||
![]() |
|
Tomasz Grysztar 08 Mar 2025, 16:43
PS. I prepared a simple demonstration of the trick:
Code: define a alpha define b beta tightly_packed equ ?a.?b match tokens, tightly_packed display `tokens, 13,10 ; "alphabeta" (misleading, as there are still two separate tokens) end match match =alphabeta, tightly_packed display "one token?", 13,10 end match match =alpha =beta, tightly_packed display "two tokens!", 13,10 end match match =alpha= =beta, tightly_packed display "two tokens and whitespace", 13,10 end match ![]() |
|||
![]() |
|
m_stery 08 Mar 2025, 20:21
Sorry, I'm using a machine translator to English ...
In calminstructions, local symbols are not visible, but I can have references and still access them. But working with them just as references is quite limiting, so I wanted a command that would replace the references with symbols directly. And that's what this command does. Actually, it greatly simplifies the processing of a line that should only differ by replacing references with its symbol. I know there are other ways, like having the symbols used in a different namespace, I like to play with the language CALM. Very simple example (nested block like directive, this only computing a depth): Code: calminstruction example?! local shared,depth init depth initsym shared,shared initsym shared.level,depth ;make a link to variable pt pt shared compute depth,depth+1 end calminstruction calminstruction end?.example?! pt check <<?>.level> gt 0 ;=> check depth > 0 (gt as comparator '>') jno unexpected pt compute <<?>.level>,<<?>.level>-1 ;=> compute depth,depth-1 exit unexpected: err 'Unexpected instruction' pt end calminstruction Edit: Transformed lines by 'pt' in comment |
|||
![]() |
|
bitRAKE 09 Mar 2025, 01:25
m_stery wrote: Sorry, I'm using a machine translator to English ... ![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.