So as far as I remember, $
means the current address. But in this question below in the picture, it says ($-array1)/2
and there is array2
in between too so I am confused what the value of a_size will be.
Asked
Active
Viewed 23 times
0

Peter Cordes
- 328,167
- 45
- 605
- 847

Noorain
- 1
-
2Please post code as text in the body of the question, [properly formatted as a code block](https://stackoverflow.com/help/formatting). [Please do not post code as images](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question/285557#285557). – Nate Eldredge Jan 04 '22 at 18:27
-
4It might be a mistake. If it was `($-array2)/2` then it would be the size of array2 in words, which would make sense. As it stands, it is the combined size of the two arrays, then divided by two to convert to size in words, but array1 is an odd number of bytes so the result will round down. It's not clear why that would be useful for anything. – Nate Eldredge Jan 04 '22 at 18:29
-
@NateEldredge okay, thanks! – Noorain Jan 04 '22 at 19:18
-
1If the used assembler (some do) applies automatic padding for dw and the data segment starts at an even address, it could be the combined size of both arrays in words after all. But the code looks more like examples than production code. – Sebastian Jan 04 '22 at 21:32
-
Not exactly a duplicate since this isn't NASM; but probably something where `$` works the same way. Perhaps MASM which uses `=` that way? Or FASM? Or perhaps Keil ARMasm? Anyway, [How does $ work in NASM, exactly?](https://stackoverflow.com/q/47494744) and [In NASM labels next to each other in memory are printing both strings instead of first one](https://stackoverflow.com/q/26897633) explains that you're correct, that will get the size of both arrays. That may be intended. – Peter Cordes Jan 04 '22 at 22:44