flat assembler
Message board for the users of flat assembler.
Index
> Main > How do you track register usage in your source code? |
| Author |
|
|
AsmGuru62 15 Jan 2026, 12:47
So, the register renaming is done to improve readability of code?
I name my registers as EAX, EBX, etc. -- just as Intel named them. I also design my functions to be short -- well, 95% of them. So, it is not a big deal to see how register is used. In addition the IDE has the ability to track usage of a token: - I right click on a register name, say: "r8d" and select a menu item "Find token in procedure". - IDE looks if the caret line is within "proc"/"endp" lines, and if so: - IDE lists (in a search panel) all lines where "r8","r8w","r8d","r8b" shows up. |
|||
|
|
sylware 15 Jan 2026, 15:05
@AsmGuru62, you went the "very short" function way. In other words, "a lot of functions" way. Then you track what does your program mostly with function names and their parameter names, I see.
If I were to port my code from my side to yours, I guess most "code sections" would become "very short functions". That said, do you have "your own internal ABI"? Because following an official ABI with a reasonably deep call graph will imply significantly more register saving on the stack. Or you do things another way? |
|||
|
|
AsmGuru62 15 Jan 2026, 16:58
I do not have an ABI, wait... what is ABI?
Lot of functions are Okay, because everything is an object, and every object has functions to work with its internal data, below is an example. Imagine you have a structure like this: Code: ; --------------------------------------------------------------------------- ; FILE: String.Inc ; DATE: January 15, 2026 ; --------------------------------------------------------------------------- struct CStr Flags db ? Length db ? Buffer rb 254 ends And then, you have a set of functions which prefixed with the name, identifying the object: Code: ; --------------------------------------------------------------------------- ; FILE: String.Asm ; DATE: January 15, 2026 ; --------------------------------------------------------------------------- align 16 proc String_Init pChar:DWORD ; --------------------------------------------------------------------------- ; Input: ; ebx = pointer to CStr object ; --------------------------------------------------------------------------- ret endp align 16 proc String_InitWithLen pChar:DWORD, Length:DWORD ; --------------------------------------------------------------------------- ; Input: ; ebx = pointer to CStr object ; --------------------------------------------------------------------------- ret endp align 16 proc String_Concatenate uses esi edi, pCStr:DWORD ; --------------------------------------------------------------------------- ; Input: ; ebx = pointer to CStr object ; --------------------------------------------------------------------------- ret endp And, then, you have another object: Code: ; --------------------------------------------------------------------------- ; FILE: Vector.Inc ; DATE: January 15, 2026 ; --------------------------------------------------------------------------- struct CVector Count dd ? ; # of items stored into 'Array' Room dd ? ; # of items reserved in 'Array' GrowBy dd ? ; # of items to grow in 'Array' if 'Count' is about to exceed 'Room' Array dd ? ; array of DWORD values (pointers, values, etc.) ends And, now, I will reuse the names used in CStr object: Code: ; --------------------------------------------------------------------------- ; FILE: Vector.Asm ; DATE: January 15, 2026 ; --------------------------------------------------------------------------- align 16 proc Vector_Init nGrow:DWORD ; --------------------------------------------------------------------------- ; Input: ; ebx = pointer to CVector object ; --------------------------------------------------------------------------- ret endp align 16 proc Vector_Add item:DWORD ; --------------------------------------------------------------------------- ; Input: ; ebx = pointer to CVector object ; --------------------------------------------------------------------------- ret endp align 16 proc Vector_Concatenate pCVector:DWORD ; --------------------------------------------------------------------------- ; Input: ; ebx = pointer to CVector object ; --------------------------------------------------------------------------- ret endp Having a lot of small functions is a good thing if they are properly named. |
|||
|
|
revolution 15 Jan 2026, 17:03
Quote:
|
|||
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.