Chuck(G)
25k Member
I'm a little fuzzy-minded today, but I can't for the life of me, figure out the answer to this one.
Here's a code snippet (assume MASM 6.13):
Now, clearly, this won't work, as the SEG operator defers resolution until link time. A possible solution to this might be to compare the name of the segment that the variable resides in, but I don't see a MASM pseudo-op that will allow that. You can see the utility of such a facility, as one can move variables between segments and have the correct code generated regardless.
So how does one solve this?
Here's a code snippet (assume MASM 6.13):
Code:
.model small,c
.data
one dw 100 dup 100
.code
two dw 100 dup 100
...
clearit macro what,howmany
mov di,offset what
if seg what EQ @code
push cs
pop es
endif
mov cx,howmany
cld
rep stosw
endm
clearit one
clearit two
end
Now, clearly, this won't work, as the SEG operator defers resolution until link time. A possible solution to this might be to compare the name of the segment that the variable resides in, but I don't see a MASM pseudo-op that will allow that. You can see the utility of such a facility, as one can move variables between segments and have the correct code generated regardless.
So how does one solve this?