'=========================================================================== ' Subject: FAR STRING ADDRESS Date: 09-24-92 (15:03) ' Author: Tony Elliott Code: ASM, QB, PDS ' Keys: FAR,STRING,ADDRESS Packet: TEXT.ABC '=========================================================================== 'From Basic DECLARE SUB FarStringInfo (A$, Segment%, Offset%, Length%) A$ = "Xyz123" CALL FarStringInfo(A$, Segment%, Offset%, Length%) PRINT "String's address: "; HEX$(Segment%); ":"; HEX$(Offset%) PRINT " Length:"; Length% END ; ------------- Asm code here.... .Model Medium ;I'll avoid the simplified ",BASIC" since ; it's doubtful that A86 supports it. Extrn StringLength :Far ;A PDS/VBDOS API function call Extrn StringAddress:Far ;Ditto .Code ;Code segment begins here Public FarStringInfo FarStringInfo proc far AString equ [bp+0ch] ;We'll use equates to reference our parameters. Segm equ [bp+0ah] ;This just makes the code easier to read and Ofs equ [bp+8] ; maintain (should we add or remove parameters Leng equ [bp+6] ; in the future, we just need to change the Params = 8 ; assignments here). push BP mov bp,sp ;Set up a stack frame push ds ;Save critical registers (even though in this push si ; example we don't change them). push di mov ax,AString ;Pointer to near descriptor into ax push ax ;Push two copies; 1 for StringLength and push ax ; another to StringAddress call StringLength ;Returns length of A$ in AX mov bx,Leng ;Pointer to Length% into BX mov [bx],ax ;Plug string length into Length% call StringAddress ;Returns far address to string data in dx: AX mov bx,Segm ;Pointer to Segment% into bx mov [bx],dx ;String segment into Segment% mov bx,Ofs ;Pointer to Offset% into bx mov [bx],ax ;String offset into Offset% pop di ;Restore the registers we saved above pop si pop ds pop bp ;Restoring BP removes the "frame" ret Params ;Return to BASIC, popping parameters off of ; the stack. FarStringInfo endp END