flat assembler
Message board for the users of flat assembler.
Index
> Main > Problem with equ and data. |
Author |
|
macomics 05 Jul 2022, 09:07
Code: xyzz dd 20 xyzz equ 10 ;in code match name,xyzz { display `name, 13, 10 } ; display 10 mov ebx,xyzz ;=10 mov eax,[xyzz] ;=[10] Code: xyzz dd 20 ; xyzz equ 10 ;in code match name,xyzz { display `name, 13, 10 } ; display xyzz mov ebx,xyzz ;=xyzz mov eax,[xyzz] ;=[xyzz] |
|||
05 Jul 2022, 09:07 |
|
Roman 05 Jul 2022, 09:10
Quote:
I have 2700 names in my game. match its too much ! |
|||
05 Jul 2022, 09:10 |
|
Roman 05 Jul 2022, 09:12
Now i think do this if equ name:
Code: eq.xyzz EQU 10 or xyzz? EQU 10 or using Code: macro EQU? chName,val { chName#? EQU val } xyzz dd 25 EQU? xyzz,10 mov ebx,xyzz? ;=10 mov eax,[xyzz] ;=[xyzz] Last edited by Roman on 05 Jul 2022, 10:47; edited 4 times in total |
|||
05 Jul 2022, 09:12 |
|
revolution 05 Jul 2022, 09:14
You need a naming convention.
e.g.: Make all equ as uppercase, and all data addresses as lowercase. |
|||
05 Jul 2022, 09:14 |
|
macomics 05 Jul 2022, 09:54
or add the prefix eq to each name if it is specified via equ
|
|||
05 Jul 2022, 09:54 |
|
AsmGuru62 05 Jul 2022, 15:27
Naming convention is a "must have" thing in a large ASM project.
Always go for Object-Oriented approach -- hold on! -- when I say that, I mean that the code should be organized into objects. I do not mean that you need to have virtual methods, if you do not want to. As an example: assume that you need an array of pointers to anything, which dynamically grows as needed (I can't imagine a large project without it). So, you need a structure to hold the data for that object, let us call it: "CVector". Now, you can have two files for that object: Code: CVector.Inc CVector.Asm Now, put your structure into INC file: Code: struct CVector Count dd ? ; # of pointers in 'Array' Reserved dd ? ; # of slots available in 'Array' GrowBy dd ? ; # of slots to grow the 'Array' if room is needed for new items Array dd ? ; pointer to an array of DWORDs, where each DWORD is a pointer to anything else ends Now put your functions which will be working with that object into ASM file. Every function should begin with the name of the object: Code: proc CVector_construct ; ; your code here... ; ret endp proc CVector_add_item ; ; your code here... ; ret endp proc CVector_remove_item ; ; your code here... ; ret endp proc CVector_insert_item ; ; your code here... ; ret endp proc CVector_find_item ; ; your code here... ; ret endp proc CVector_destruct ; ; your code here... ; ret endp Now, you can include these files into other large projects and reduce your development time. Also, if you are not using some functions declared with proc/endp, their code is never included into final EXE file -- a very nice FASM feature! |
|||
05 Jul 2022, 15:27 |
|
Overclick 05 Jul 2022, 23:35
Quote:
Same as macros. |
|||
05 Jul 2022, 23:35 |
|
revolution 06 Jul 2022, 03:54
If you are only using equ for numeric values then change them to use =.
Code: xyzz dd 20 xyzz = 10 ; fasm will show an error if you try to declare it twice. |
|||
06 Jul 2022, 03:54 |
|
ProMiNick 06 Jul 2022, 08:31
for peoples that tractate couse of same symbol in assembly & preproce time as great feature but not as problem(Roman, thanks, thanks, thanks for finding that feature):
Code: hello = 25234 define hello +hello hello=5; "+hello=5"got Illegal instruction error what could help? Code: macro IgnoreSymbolRedefinition statement { tmp equ tmp2 equ irps n,statement \{ match any,tmp \\{ tmp2 equ tmp2 \n \\} ; if 1st symbol already grabbed grab & concantenate the rest with resolving (presense of \ infront of n mean resolving of symbol) match ,tmp \\{ define tmp n\\} \} ; if not grabbed 1st symbol grab it and don`t resolve it (absense of \ infront of n mean absense of resolving) tmp tmp2 } now Code: hello = 25234 define hello +hello IgnoreSymbolRedefinition hello=5; now all OK one more: equ use preproc symbols with same name in definition while define use assembly time symbols by the analogy of IgnoreSymbolRedefinition resolvation filter behavior could be made construction with mixed behavior (some args would be resolved and some not) |
|||
06 Jul 2022, 08:31 |
|
Roman 06 Jul 2022, 11:04
I check define.
Code: define xyz 10 xyz dd 25 ;fasm get error 10 dd 25 |
|||
06 Jul 2022, 11:04 |
|
revolution 06 Jul 2022, 11:11
define is the same as equ. It is a preprocessor text assignment.
Just use =. |
|||
06 Jul 2022, 11:11 |
|
Roman 06 Jul 2022, 13:19
Quote: Just use =. sometime = not help. Code: define hrutt +xmm1,/xmm2,-xmm3 ;ok hrutt = +xmm1,/xmm2,-xmm3 ;fasm error hrutt EQU +xmm1,/xmm2,-xmm3 ;ok |
|||
06 Jul 2022, 13:19 |
|
revolution 06 Jul 2022, 14:01
Okay, then it can't work if you use it like that.
Your initial example showed only numeric values. Then you need a better naming convention. It is confusing to have two things named the same. Save yourself the confusion and name them differently. |
|||
06 Jul 2022, 14:01 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.