flat assembler
Message board for the users of flat assembler.
Index
> Main > uninitialised structs, |
Author |
|
Tomasz Grysztar 16 Feb 2006, 10:05
The good old trick for doing this is:
Code: struc point x,y { .x db x+0 .y db y+0 } As for your solution, it didn't work because you used value as if it was the name also. You should do it like: Code: macro field n,dz,v { if v eq n dz 0 else n dz v end if } struc point x,y { field .x,db,x field .y,db,y } or maybe: Code: struc Db v { if v eq . db 0 else . db v end if } struc point x,y { .x Db x .y Db y } |
|||
16 Feb 2006, 10:05 |
|
dead_body 16 Feb 2006, 10:06
maybe something like this, but I don't know will it work:
struc point x,y { .x db x+0 .y db y+0 } sorry if it would not work. |
|||
16 Feb 2006, 10:06 |
|
lazer1 16 Feb 2006, 12:52
Tomasz Grysztar wrote: The good old trick for doing this is: this trick looks really neat the other 2 will be useful for understanding how fasm operates, the 3rd technique with the "." is very unusual, I havent yet fully understood this one: say I have: Code:
xyz point 3
after the first expansion of point will this be translated to: Code:
xyz
.x Db 3
.y Db
and then after the second expansion of Db to: Code: xyz .x . db 3 .y . db 0 |
|||
16 Feb 2006, 12:52 |
|
vid 16 Feb 2006, 13:16
nope, after usage of "a point 5,6" it becomes
Code: a.x Db 5 a.y Db 6 eg. structure name ("a") is prepended to all symbols starting with dot (".x" and ".y"), and macro arguments are replaced by theior values ("x" -> 5, "y" ->6) Then also inner macros ("Db") are expanded, "a.x Db 5" becomes Code: if 5 eq a.x db 0 else a.x db 5 end if } eg. "." is replaced with structure name "a.x", and "v" is replaced by it's value "5". Rest is not preprocessing... "if 5 eq " is false condition so "a.x db 5" gets assembled. In case of empty argument condition would be "if eq" which is true, so "a.x db 0" would be assembled |
|||
16 Feb 2006, 13:16 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.