flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Array of structs in a struct

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
ouadji,

Second variant emulates times control directive behavior (it expands % symbol in the rest of line with the number of current iteration):
Code:
points times 10 POINT %, %*%
;the same as
;points    POINT 1, 1
;points_2  POINT 2, 3
;points_3  POINT 3, 9
;points_4  POINT 4, 14
;...
;points_9  POINT 9, 81
;points_10 POINT 10, 100    
Better yet, since it's macro, you can use macro operators # and ` (backquote/backtick) in data definition
Code:
points_1 = points; this is needed because subscript names was generated starting with second POINT instance
ppoints times 10 dd points_\\#%; imagine they're noncontiguous and randomly spaced
npoints times 10 db "points_", \\`%, 0; surely can be done with interpretive layer, but isn't this simpler?    
to generate (for example) array of pointers to those structs, and strings (just don't forget to protect them with backslashes enough, so they won't trigger earlier than needed).

Usefulness of this is questionable; they can't be nested currently (a times 3 times % db % don't expand second times but replaces both %s); no check for count<=0 is done (it fails differently for count<0 and count==0). Quick'n'dirty hack as it is — and I like it. Wink
Post 09 Feb 2010, 19:14
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji
Quote:

Second variant emulates times control directive behavior
(it expands % symbol in the rest of line with the number of current iteration)

Better yet,
since it's macro, you can use macro operators # and ` in data definition <-- great !

ok, I understood this time Razz
thank you a lot baldr, that's kind of you.

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 09 Feb 2010, 19:46
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.