flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Does the macro preprocessing text ? |
Author |
|
macomics 26 Mar 2023, 19:05
Code: macro getparams a, b { local q, length, c, t, z, ptr virtual at 0 db b ptr = $ length db a params = 0 load q byte from 0 while ptr < $ - length load c byte from ptr if q = c params = params + 1 repeat length - 1 load t byte from % load z byte from (ptr + %) if t <> z params = params - 1 break end if end repeat end if ptr = ptr + 1 end while end virtual } getparams '[%f, %f, %f, %f]', '%f' display params + '0', 13, 10 getparams '[%f, %x, %f, %d]', '%x' display params + '0', 13, 10 getparams '[%i, %i, %i, %i]', '%d' display params + '0', 13, 10 Code: ~ $ fasm -m 1024 main.asm flat assembler version 1.73.30 (1024 kilobytes memory) 4 1 0 1 passes, 0 bytes. Last edited by macomics on 28 Mar 2023, 15:06; edited 2 times in total |
|||
26 Mar 2023, 19:05 |
|
Roman 26 Mar 2023, 19:11
Thanks.
Its awesome ! But I try and get 0, not 4 getparams '[%f, %f, %f, %f]', '%f' display params + '0', 13, 10 Last edited by Roman on 26 Mar 2023, 19:15; edited 1 time in total |
|||
26 Mar 2023, 19:11 |
|
macomics 26 Mar 2023, 19:15
Fixed the error. Updated the text above.
|
|||
26 Mar 2023, 19:15 |
|
Roman 26 Mar 2023, 19:17
Thanks.
Now work. |
|||
26 Mar 2023, 19:17 |
|
Roman 28 Mar 2023, 10:38
macomics
I comment label count at $ - $$ And macro work. Why using this in macro ? Code:
label count at $ - $$ |
|||
28 Mar 2023, 10:38 |
|
macomics 28 Mar 2023, 15:04
I initially counted the number of bytes for virtual without 'at 0'. It 's better to write like this there
Code: label count at $ - length ADD: However, you can completely get rid of it because the same expression is written immediately in the while loop |
|||
28 Mar 2023, 15:04 |
|
Roman 28 Mar 2023, 16:06
I thinked count using as hidden parameter for while or repeat.
|
|||
28 Mar 2023, 16:06 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.