flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > [fasmg] ? macro strips spaces |
Author |
|
Tomasz Grysztar 22 Feb 2017, 07:54
Like fasm's preprocessor, fasmg's macro operate on a pre-tokenized text that loses some of the properties of the original - the excess whitespace is stripped, it is not remembered which kind of quotes were used to enclose a quoted string and comments starting with a semicolon are not tokenized at all.
If you need to operate on the raw text, the only option might be to load it with FILE. You could load original text of current source with "file __file__" and count lines to find one with "__line__" number - a bit clunky but might work: Code: macro find_me? virtual at 0 file __file__ counter = 0 repeat $ load a:byte from %-1 if a = 10 | % = %% counter = counter + 1 if counter = __line__ load line_data : %-line_start from line_start display line_data break end if line_start = % end if end repeat end virtual end macro find_me ; here |
|||
22 Feb 2017, 07:54 |
|
zhak 23 Feb 2017, 22:02
Thanks for the hint.
Here's what I got: Code: macro text?! name, terminator local lines, start_line, start_indx, end_indx lines = 0 start_line = 1 macro ?! line& if `line = `terminator virtual at 0 file __file__ ln = 1 start_indx = 0 end_indx = 0 repeat $ load a:byte from % - 1 if a = 10 | % = %% ln = ln + 1 if ln = start_line start_indx = % else if ln = start_line + lines end_indx = % - 1 break end if end if end repeat load name:end_indx - start_indx from start_indx end virtual purge ? else if lines = 0 start_line = __line__ end if lines = lines + 1 end if end macro end macro text myfile, EOF line1 line 2 line3 EOF |
|||
23 Feb 2017, 22:02 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.