Far strings in asm

 BBS: Inland Empire Archive
Date: 12-05-92 (12:05)             Number: 319
From: DIK COATES                   Refer#: NONE
  To: ALL                           Recvd: NO  
Subj: Far strings in asm             Conf: (2) Quik_Bas
I have included a small test program that I am having trouble
with.  As an executable file, the program functions flawlessly,
printing out handle numbers or -ve critical error numbers for
last 2 items (3 and 15 respectively).  The problem is when I run
the program from QBX environment... it locks up the box!
A QLB is created using 'link /q/noe/co fstr.obj+ qbx.lib; and
qbxqlb.lib'.  MASM using only /Zi and LIB using '+fstr.obj&
qbx.lib' to create LIB's and QLB's...The Function is set to run
far strings only...


'This is the test program:

DECLARE FUNCTION FCREATE% (strvar$, BYVAL var%)

temp$ = "Diktest.tst" + CHR$(0)
retval% = FCREATE%(temp$, 0)
PRINT temp$, retval%
temp$ = "Diktest1.tst" + CHR$(0)
retval% = FCREATE%(temp$, 0)
PRINT temp$, retval%
temp$ = "Diktest2.tst" + CHR$(0)
retval% = FCREATE%(temp$, 0)
PRINT temp$, retval%
temp$ = "Dikt?st3.tst" + CHR$(0)
retval% = FCREATE%(temp$, 0)
PRINT temp$, retval%
temp$ = "e:\Diktest4.tst" + CHR$(0)
retval% = FCREATE%(temp$, 0)
PRINT temp$, retval%

and this is the MASM Function that opens the files and either
returns an error value, or a handle number...

.Model Medium, Basic

    Extrn StringAddress:Proc    ;part of PDS
    Extrn StringLength:Proc     ;part of PDS

.Code

; BASIC Far String Function - returns File Handle if successful, and
; DOS Critical Error if fails.  Declare as follows:
;
; DECLARE FUNCTION FCREATE% (filename$, BYVAL attribute%)
;
; ARGS: filename$ - name of file to create
;       attribute%- attribute of file as follows:
;                       0 - normal
;                       1 - read only
;                       2 - hidden
;                       4 - system
; LIB:  FSTRING1.LIB
;
; REV:  92-12-04
;

FCREATE     proc    Uses bx cx dx es ds si, desrptr:dword, attrib:word
            pushf               ;save flags

            lds   si, desrptr

            push es             ;save ES
            push si             ;pass incoming descriptor
            CALL StringAddress  ;call the PDS routine for Segment:Offset

            pop  es             ;retrieve ES for StringLength
            push ax             ;save offset
            push dx             ;save segment

            push si             ;pass incoming descriptor
            CALL StringLength   ;callthe PDS routine for the length
            mov  bx, ax         ;put length in bx

            pop  ds             ;retrieve segment in ds
            pop  dx             ;retrieve offset in dx
            mov  cx, attrib     ;attribute in cx
            mov  ah, 3ch        ;DOS create file
            int  21h
            jnc  @f             ;carry flag clear, ret handle in ax
            neg  ax             ;carry flag not clear, ret -ve crit err in ax
@@:         popf                ;restore flags
            ret
FCREATE     Endp

End


Can anyone out there take a boo and try to help sort this hiccup out...
The routine is part of a suite for creating, opening, closing, reading,
writing, killing, etc.  I am trying to get these to work for far strings
and when completed, will make the suite available to all... Also any speed
improvements would be appreciated.  Regards Dik

... OK, I tried to be serious but it just didn't happen today!
___ Blue Wave/QWK v2.10

--- Maximus 2.00
 * Origin: Durham Systems (ONLINE!) (1:229/110)
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