flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution 03 Oct 2010, 16:08
Easy:
Code: data1 = 1 data2 = 2 data3 = 3 ![]() But seriously: Code: macro enum [stuff] { common local x x=0 forward x=x+1 stuff = x } enum data1, data2, data3 display data1+'0',data2+'0',data3+'0' |
|||
![]() |
|
typedef 03 Oct 2010, 16:19
Thank you so much...It worked..Love you man (No hommo)
![]() |
|||
![]() |
|
typedef 03 Oct 2010, 16:25
Wait, hold on a sec. Fasm wont let me declare it in a struct, or even a variable. Here's my code
Code: enum MEDIA_TYPE,\ data1,\ data2 struct DISK_GEOMETRY .MediaType MEDIA_TYPE ? ends Help ! Help ! I get an error there...How can i pass |
|||
![]() |
|
revolution 03 Oct 2010, 16:36
You can do this:
Code: include 'win32ax.inc' macro enum var,[stuff] { common local x x=0 struc var \{. dd ?\} forward x=x+1 stuff = x } enum MEDIA_TYPE,\ data1,\ data2 struct DISK_GEOMETRY MediaType MEDIA_TYPE ends |
|||
![]() |
|
typedef 03 Oct 2010, 19:33
yop
Last edited by typedef on 12 Oct 2013, 04:38; edited 1 time in total |
|||
![]() |
|
mindcooler 04 Oct 2010, 08:46
Code: macro enum start,step,[items] { common local count count=start forward items=count count=count+step } enum $0,1,\ T_INT,T_VOID,T_IF,T_WHILE,T_DO,T_ELSE,T_WRITE,T_READ,T_RETURN,T_ERR,T_EOT enum $10,1,\ T_COMMA,T_MUL,T_LPAR,T_RPAR,T_LBRA,T_RBRA,T_PLUS,T_MINUS,T_SEMICOLON,T_LTE,T_GTE,T_NEQ,T_EQ enum $20,1,\ T_LT,T_GT,T_NOT,T_ASSIGN,T_NUM,T_ID,T_DIV _________________ This is a block of text that can be added to posts you make. |
|||
![]() |
|
ouadji 04 Oct 2010, 12:43
macro,macro,macro ... ![]() Why do you want absolutely create high-level language directives in assembler ? Why not build procedures in assembler to carry out all that ! Why this "madness" of converting all with macros ? I use no macros, and I do everything i want, all in assembler. (just my view, nothing else) |
|||
![]() |
|
mindcooler 04 Oct 2010, 12:50
Why would you want to enum at runtime?
|
|||
![]() |
|
ouadji 04 Oct 2010, 13:58
I was not referring specifically about "enum", but about many messages about macros, and more broadly about the general interest for macros. I don't like the using of macros, for me this way is not really the assembly language. I think anything can be carried out without macros. For me, the use of macros is really the opposite of a real assembly language programming. Again, it's just my view, ... and sorry, i'm off topic (sticky opinion ? ![]() (sorry for my bad english, i do my best, it's not easy for me) |
|||
![]() |
|
typedef 04 Oct 2010, 18:24
ouadji wrote:
Well, IMO, Imagine running all that code that has been created as a macro, at run time. How big would your file be? here's an example of what i mean. Code: macro export dllname,[label,string] { common local module,addresses,names,ordinal,count count = 0 forward count = count+1 common dd 0,0,0,RVA module,1 dd count,count,RVA addresses,RVA names,RVA ordinal addresses: forward dd RVA label common names: forward local name dd RVA name common ordinal: count = 0 forward dw count count = count+1 common module db dllname,0 forward name db string,0 common local x,y,z,str1,str2,v1,v2 x = count shr 1 while x > 0 y = x while y < count z = y while z-x >= 0 load v1 dword from names+z*4 str1=($-RVA $)+v1 load v2 dword from names+(z-x)*4 str2=($-RVA $)+v2 while v1 > 0 load v1 from str1+%-1 load v2 from str2+%-1 if v1 <> v2 break end if end while if v1<v2 load v1 dword from names+z*4 load v2 dword from names+(z-x)*4 store dword v1 at names+(z-x)*4 store dword v2 at names+z*4 load v1 word from ordinal+z*2 load v2 word from ordinal+(z-x)*2 store word v1 at ordinal+(z-x)*2 store word v2 at ordinal+z*2 else break end if z = z-x end while y = y+1 end while x = x shr 1 end while } Thats a code to export a function from a DLL. Imagine you were making a DLL, Kernel32.DLL, would you go writing that over and over again? Its OK though, Its your opinion, and this is my thread ![]() I feel you. Anyways. My problem has already been solved. Thanks to you all with your contribs.Cheers |
|||
![]() |
|
bitRAKE 05 Oct 2010, 06:04
ouadji wrote: Why do you want absolutely create high-level language directives in assembler ? The downside is, of course, the learning curve for people reading the code -- they must first understand the local language created for the task. Ideally, the language should fit the task in a way which makes this very easy. ![]() IMHO, this would be a great topic for the Heap. There are purists which shun use of macros - I certainly do when it comes to optimization for execution speed. Once I get better with macros I might optimize for my own time, or with regard to the project continuity. |
|||
![]() |
|
ouadji 05 Oct 2010, 07:58
Quote:
Only one exception, the macro "struct", I sometimes use this macro. This is a macro which I define as "static", it doesn't create any code, just an easy way to access to a data set ... otherwise, nothing else. Quote: A) I might optimize for my own time, or with regard to the project continuity. A) 100% agree with you. (but despite that, I hate macros) B) "optimization" for execution time a faster code using macros ? macro_language still faster than the assembly language ??? |
|||
![]() |
|
bitRAKE 05 Oct 2010, 16:08
B) In context it is a more complete thought.
Quote: There are purists which shun use of macros - I certainly do [shun] when it comes to optimization for execution speed. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.