Re: Help

 BBS: Inland Empire Archive
Date: 09-24-92 (15:03)             Number: 213
From: TONY ELLIOTT                 Refer#: NONE
  To: MARTIN BOUCHARD               Recvd: NO  
Subj: Re: Help                       Conf: (2) Quik_Bas

 MB> I'm writing an ASM library using the shareware A86 assembler. The
 MB> problem is that I don't know how to handle PDS FARSTRING.
 MB> Could someone post me a simple code in .ASM that show me how to access

I don't have A86, but here's how you get the address of a far string
using MASM:

'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%

; ------------- 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

;--- Asm code ends here.....

I didn't test this, but it should be pretty close.


... SENILE.COM found . . . Out Of Memory . . .
--- Blue Wave/Max v2.10 [NR]
 * Origin: Oakland BBS - McDonough, GA - (404) 954-0071 (1:133/706.0)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET