Well... QB, basically uses three segments: The code segment, the data segment and an extra segment for arrays.
If you're passing an array, you could always pass it as a far address, 'cause: cs, will be pointing to code seg, ds will be pointing to data seg.
Anyway, you don't know the actual segment for the arrays, so you'd have to pass the variable as a far address, like seg:[off], so you know where to get it's value(s) from.
Okay, in order to pass far addresses you'd use the SEG keyword in the parameters declaration.
like:
CALL ABSOLUTE (SEG Array(Index), SADD$(Routine$))
(CALL ABSOLUTE is explained in the above messages)
So, that way, what'll be put on stack will be, not only the array's offset, but the array's segment as well. let's suppose you use the above command, so your stack would be like:
sp + 08: Array's Segment
sp + 06: Array's Offset
sp + 04: Return Segment
sp + 02: Return Offset
sp: bp
So, you can now easily address the array, just getting it's address, which will be: [sp + 08]:[sp + 06].
Remember to ALWAYS preserve ds and bp... sp also, but that one cannot be changed anyway (unless you're using esp, but leave that alone for a while... hehe)...
lkt153
www.lkt153.cjb.net
ICQ: 27901426 |