Book on Assembly - The constants are substituted for their defined values during the assembly process. As such, a constant is not assigned a memory location. So how and where constants are stored in memory?
<name> equ <value>
Book on Assembly - The constants are substituted for their defined values during the assembly process. As such, a constant is not assigned a memory location. So how and where constants are stored in memory?
<name> equ <value>
In code compiled into machine code, many constants are replicated as needed — if one constant is used in two different lines of code (whether in different functions or not), it is likely replicated. Often, this is visible in the assembly language, if that is the source or an intermediate for the machine code.
Constants are often found within immediate fields of machine code instructions.
So how and where constants are stored in memory?
As programs (modulo the cache which caches memory) are too large to fit in the processor, a program's machine code program instructions are stored in memory, so in theory, we can identify where in memory (what address or addresses) copies of these constants occur encoded in machine code instructions.
The construct name equ value
does not consume any locations for that alone, it is the use of name
in other assembly instructions that causes the value
(or some adjustment of that) to be encoded in their machine code translations.