It's a university assignment, so emu8086 must be used. With no emu8086.inc
Let's say I have
msg db "Hello"
msgend:
msglen1 equ $ - msg
msglen2 db $ - msg
Then:
mov ax, msgend - offset msg ; ax gets the correct length
mov ax, msglen1 ; correct length
mov ax, msglen2 ; correct length
; same names as offsets to make it clear,
; how which parameters would be passed.
; But not the same in real code.
TESTMACRO macro msg msgend msglen1 msglen2
mov ax, msg ; correct offset
mov ax, msgend ; correct offset
mov ax, msgend - offset msg ; zero length
mov ax, msglen1 ; again zero length
mov ax, msglen2 ; correct length, but it used up a word
endm
So. I can't pass the length of the string inside the macro in any way, except by passing the length allocated in a word. But I'm interested, if I can do it with a equ constant.
Use =
to define your equate instead of equ
.
The value of an equ
equate is evaulated at the point of usage, which in your case means that the $
in msglen1
is replaced by the address of the mov ax, msgLen1
instruction.
The value of an =
equate is evaulated at the point of definition, which should give you the value you want in this case.