For example, if we were writing a simple hello world type program, the .data section might contain something like:
section .data msg db 'Enter something: ' len equ $ - msg
What does the $ in this example represent, and why does $ - msg
equal the length of the string?
A label can be placed at the beginning of a statement. During assembly, the label is assigned the current value of the active location counter and serves as an instruction operand. There are two types of lables: symbolic and numeric.
This is AT&T syntax for x86. In AT&T % generally denotes a register while $ is reserved for immediates. If you omit th $ the assembler would interpret the 48 as an address.
The dollar $ sign simply means the value after it is given in hex. No dollar would mean it is in decimal. i.e. lda #$ff. is the same as.
In the x86 assembly language, the JMP instruction performs an unconditional jump. Such an instruction transfers the flow of execution by changing the program counter.
In this case, the $ means the current address according to the assembler. $ - msg is the current address of the assembler minus the address of msg, which would be the length of the string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With