Is it possible to write a macro such as below, to where I can code it in the source as such:



DIM MACRO FO,SIZEE,TYPE
invoke GetProcessHeap
invoke HeapAlloc,eax,HEAP_ZERO_MEMORY,SIZEE*TYPE
mov [FO],eax
endm


to declare:
DIM x(128) AS STRING

instead of
DIM x,128,STRING

yea I know, but I'm a glutton for pwntishment
Posted on 2004-06-04 08:01:55 by drarem
Don't suppose you'r an VB Programmer? ;) I have used that language before.. but that was until i started with Assembly... and i loved the fact that you dont have DIM and other simplicites.. simply because Assembly made me feel in control of the language i was using (wich i dont think C/VB/.NET/ETC. does) But hey.. thats my opinion.. :)

Since im not a macro guru.. i would say that the only method i know would be to use VARARG for macro parameter type, and then parse the text in that param. Should be fun? :)



DIM macro par1:vararg
...
...
...
endm
Posted on 2004-06-04 08:18:19 by fisk
I'm a jack of all languages programmer and i'm just lookin for a little resuability.. instead of cutting and pasting code from one function to another - in the process creating several different functions doing the same thing one of which is actually optimized and works perfectly - I would prefer to keep it global and use some simple method for calling which is easy for me to remember.

Also if I can get my game making going again, set it up like an easy 'engine compiler?' so my buddy could write in it without having to learn assembly.
Posted on 2004-06-04 08:43:06 by drarem


dim macro wha:vararg
local ElementName,ElementType,ElementsNum,CurChar,GettingNum,phase
ElementsNum = 0
GettingNum = 0
phase = 0
ElementName textequ <>
ElementType textequ <>
forc CurChar,<wha>
ifidn <CurChar>,<(>
GettingNum = 1
phase = phase + 1
elseifidn <CurChar>,<)>
GettingNum = 0
phase = phase + 1
elseifidn <CurChar>,< >
if phase lt 4
phase = 4
endif
phase = phase + 1
else
if phase eq 0
ElementName CATSTR ElementName,<CurChar>
elseif phase eq 1
ElementsNum = (ElementsNum * 10) + CurChar
elseif phase eq 6
ElementType CATSTR ElementType,<CurChar>
endif
endif
endm
if ElementsNum eq 0
ElementsNum = 1
endif

invoke GetProcessHeap
invoke HeapAlloc,eax,HEAP_ZERO_MEMORY,ElementsNum * (sizeof ElementType)

endm

[b]Usage:[/b]
dim xx(15) as DWORD
dim var2 as real8

use strictly inside this definition and you won't have problems :)
now, xx and var2 - the actual names , you can use "textequ" to define them, ...
Posted on 2004-06-04 08:48:39 by Ultrano
wow.. there is so much yet to learn..

I get this error:



Assembling: slimedig.asm
slimedig.asm(168) : error A2006: undefined symbol : ??02B3
dim(29): Macro Called From
slimedig.asm(168): Main Line Code
slimedig.asm(168) : error A2006: undefined symbol : ??02B3
dim(34): Macro Called From



dim apptr(300) as DWORD
Posted on 2004-06-04 09:58:13 by drarem
figured it out:

elseifidn <CurChar>,< )>



should be

elseifidn <CurChar>,<)>


not showing up but there shouldn't be an extra space in there.. prob something
to do with this {code} html forum stuff...the macro is great, thanks
Posted on 2004-06-04 10:10:23 by drarem
The message board adds spaces.
It is better to attach file.
I always forget to attach file.
Posted on 2004-06-04 10:29:57 by bitRAKE