Announcement

Collapse
No announcement yet.

XMS for Powerbasic ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hans Ruegg
    replied
    Hello,

    I was not on this forum quite a long time, and it took me some time
    to dig out my old XMS code; but here it is:

    Code:
    DEFINT A-Z
    
    TYPE EMM           'these are the parameters passed to the XMS Manager
      bytes   AS LONG
      sHandle AS WORD
      sOffset AS DWORD
      dHandle AS WORD
      dOffset AS DWORD
    END TYPE
    
    DECLARE FUNCTION XMSinit (avail??, total??)
    DECLARE FUNCTION XMSalloc(BYVAL KB, handle)
    DECLARE FUNCTION XMSMove (e AS EMM)
    DECLARE FUNCTION XMSfree (BYVAL handle)
    DECLARE FUNCTION XMSredim (BYVAL handle, BYVAL KB)
    
    '=========================================================
    '===      Test Program             =======================
    '=========================================================
    
    CLS
    erro = XMSinit (avail??, total??)
    PRINT "XMSinit: Return Code "; STR$(erro)
    PRINT "Largest available XMS block (KB): "; STR$(avail??)
    PRINT "Total available XMS (KB): "; STR$(total??)
    IF erro THEN END
    
    DIM e AS EMM
    erro = XMSalloc(1, handle)
    PRINT "XMSalloc: Return code "; STR$(erro)
    PRINT "Block handle: "; STR$(handle)
    IF erro THEN END
    
    'Copy part of a test string into XMS:
    test$ = "abcdefghijklmnopqrstuvwxyz0123456789"
    e.bytes = (LEN(test$)+1)\2*2 'Number of bytes must be even; else an error occurs.
    e.sHandle = 0                'Source of move: DOS memory
    e.sOffset = STRPTR32(test$)  'Source ptr: Seg./Offs. ptr into DOS memory
    e.dHandle = handle           'Destination of move: our XMS block
    e.dOffset = 0                'Destination ptr: Offset into XMS block
    erro = XMSMove(e)
    PRINT "Copying string to XMS: Return Code "; STR$(erro)
    
    'Change our test string:
    test$ = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    'Overwrite 12 bytes of it with what was stored in XMS:
    e.bytes = 12                 'Number of bytes to move
    e.dHandle = 0                'Destination of move: DOS memory
    e.dOffset = STRPTR32(test$)  'Destination ptr: Seg./Offs. of destination
    e.sHandle = handle           'Source of move: our XMS block
    e.sOffset = 4                'Source ptr: Offset into XMS block
    erro = XMSMove(e)
    PRINT "Copying string from XMS: Return Code "; STR$(erro)
    PRINT "Result string: "; test$
    PRINT "XMSFree: Return code "; STR$(XMSFree(handle))
    END
    
    '=========================================================
    '===      XMS Functions            =======================
    '=========================================================
    
    XMSManager:    'Code Segment Variable: 32-bit pointer to XMS Manager
    !	DW 0
    !	DW 0
    
    
    ' XMSinit:  Check for the presence of XMS and get manager address
    ' Returns errorcode, or zero for success
    FUNCTION XMSinit (avail??, total??) PUBLIC
    ! push ax
    ! push bx
    ! push DX
    ! push es
    ! PUSH DI
    
    'XMS Installation Check (should return AL = &H80)
    ! mov ax, &H4300
    ! int &H2F
    ! CMP al, &H080
    ! JNE XMSnotInstalled
    
    'Get XMS Handler Address
    ! mov ax, &H4310
    ! int &H2F
    ! MOV CS:XMSManager, BX
    ! mov CS:XMSManager[2], ES
    
    'Get Handler Version
    '! mov ax, 0
    '! call DWORD CS:XMSManager
    '! LES DI, version??
    '! MOV ES:[DI], AX
    
    'Request amount of free XMS
    ! mov ax, &H0800
    ! mov BX, 0
    ! CALL DWORD CS:XMSManager
    ! LES DI, avail??
    ! MOV ES:[DI], AX             ; largest avail. block in KB
    ! LES DI, total??
    ! MOV ES:[DI], DX             ; total XMS in KB
    
    ! MOV FUNCTION, BL                ; errorcode
    ! JMP InstallCheckEnd
    
    XMSnotInstalled:
    ! LES DI, avail??
    ! MOV WORD ES:[DI], &HFFFF
    ! MOV FUNCTION, -1
    InstallCheckEnd:
    ! POP DI
    ! POP ES
    ! POP DX
    ! POP BX
    ! POP AX
    END FUNCTION
    
    'Allocate XMS block
    FUNCTION XMSalloc(BYVAL KB, handle) PUBLIC
    ! PUSH AX
    ! PUSH BX
    ! PUSH DX
    ! PUSH ES
    
    ! mov ax, &H0900
    ! mov dx, KB                   ; size in KB
    ! CALL DWORD CS:XMSManager
    ! CMP AX, 0
    ! JE Failure2
    ! LES BX, handle
    ! MOV ES:[BX], DX
    ! MOV FUNCTION, 0
    ! JMP End2
    Failure2:
    ! MOV FUNCTION, BL
    End2:
    ! POP ES
    ! POP DX
    ! POP BX
    ! POP AX
    END FUNCTION
    
    'Free XMS block
    FUNCTION XMSfree (BYVAL handle) PUBLIC
    ! PUSH AX
    ! PUSH BX
    ! PUSH DX
    ! mov ax, &H0A00
    ! mov dx, handle
    ! CALL DWORD CS:XMSManager
    ! CMP AX, 0
    ! JE Failure3
    ! MOV FUNCTION, 0
    ! JMP End3
    Failure3:
    ! MOV FUNCTION, BL
    End3:
    ! pop DX
    ! pop bx
    ! POP AX
    END FUNCTION
    
    'Move any XMS Block (EMM structure must already be filled)
    FUNCTION XMSMove (e AS EMM) PUBLIC
    ! PUSH AX
    ! PUSH BX
    ! PUSH SI
    ! PUSH DS
    
    ! mov ax, &H0B00
    ! LDS SI, e
    ! CALL DWORD CS:XMSManager
    ! CMP AX, 0
    ! JE Failure4
    ! mov FUNCTION, 0
    ! JMP End4
    Failure4:
    ! mov FUNCTION, BL
    End4:
    ! POP DS
    ! POP SI
    ! POP BX
    ! POP AX
    END FUNCTION
    
    'Resize XMS Block            '? NOT YET TESTED
    FUNCTION XMSredim (BYVAL handle, BYVAL KB) PUBLIC
    ! PUSH AX
    ! PUSH BX
    ! PUSH DX
    
    ! MOV AX, &H0F00
    ! MOV DX, handle
    ! MOV BX, KB
    ! CALL DWORD CS:XMSManager
    ! CMP AX, 0
    ! JE Failure5
    ! mov FUNCTION, 0
    ! JMP End5
    Failure5:
    ! mov FUNCTION, BL
    End5:
    ! POP DX
    ! POP BX
    ! POP AX
    END FUNCTION
    I hope the comments are sufficient to explain how it works.

    With kind regards,

    Hans Ruegg

    Leave a comment:


  • Donald Darden
    replied
    I'm assuming that if you are unning PB/DOS and want to use XMS,
    and mention a 286, that yes, you probably are using a desktop
    system. Not many portables came out with a 286 at heart, most
    were heavy luggables, and the first one of real value came from
    Compaq as I recall, using a 386.

    As to cash registers or whatever, those were certainly not main-
    stream, and what guts they had or software/hardware features they
    offered is outside my experience.

    ------------------
    Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

    Leave a comment:


  • Frank Cox
    replied
    > the leap from 286 to 386 was a big one, so at the very least, I
    > recommend getting off of 286 altogether and adopting at least a
    > 386 machine.

    You're making the common assumption that every computer is a desktop machine.

    There are many "portables" for inventory control and such, not to mention smart cash registers, survey equipment, and other industrial stuff. A lot of that is built like the proverbial brick you-know-what, and would be extremely expensive to replace with "modern technology".

    ------------------
    PB/DOS 3.5 on Fedora Linux

    Leave a comment:


  • Donald Darden
    replied
    I realize that not everyone can choose what computer they have to
    work with, but 286 and 386 are both old technology now, and yet
    the leap from 286 to 386 was a big one, so at the very least, I
    recommend getting off of 286 altogether and adopting at least a
    386 machine.

    There were significant and important changes with the 386, and
    so the go-back limit is usually set at nothing before the 386.
    A big change was in the way additional memory could be installed,
    recognized, and used. The 286 also lacked a direct way to return
    to Real mode, which was a problem, and the floating point unit
    (FPU) was radically changed bwtween the 286 and 386, The moves
    from the 386 on up were more of a refinement and providing added
    features nature, much of which is outside the DOS environment and
    of no concern or real interest to DOS programmers. The increase
    in speed, improvements in caching and lookahead technology,
    multiple instruction pipes, and other gains, still permit the
    programmer to write programs that rely on underlying attributes
    that have been preserved from one CPU generation to the next.
    If you are not going to use XMS or EMS, then the 286 still may
    serve your needs. Otherwise, you need to plan on moving up in
    the computer architecture that you require.

    ------------------
    Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

    Leave a comment:


  • Donald Darden
    replied
    I used MAXLIB version 12C, which I think is the latest version,
    for a large project a few years back.I found out that the only
    array that can be redimentioned is the last one created - the
    progam did not reallocate memory properly for any of the arrays
    created first. For me, that was not a problem.

    However, I was using a 2-bit flag structure to represent three
    possible circuit conditions (0=normal use, 1=flagged on transmit
    end, 2=flagged on receive end), mapping these over fixed length
    strings that made up the array, and I found a situation where,
    on occasion, some bits changed without without warning. I walked
    the same code over and over, and I could see exactly where they
    would change between two close points in the program, but there
    were no statements there making the change. I could never resolve
    that problem, but it was obvious that the XMS code was somehow
    causing this to happen. So I had to abandon that approach.

    Of course with PB/CC or PB/Win, possible array size is extremely
    large, but you obviously want a PB/DOS solution. I don't know
    if MAXLIB will reach out and bite you, but it comes without any
    warrantees, sort of like Beta code. I would suggest you consider
    setting up a large RAM drive in XMS and handle it through regular
    file operations. That way you get most of the speed, and of
    course you can always write the file directly to hard drive or
    read it back using just a file copy command. A good backup
    insurance.

    ------------------
    Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

    Leave a comment:


  • Markus Maussner
    replied
    Hello

    Thanks for the fast reply!

    >> i am looking for a solution to use powerbasic and xms.
    >> i am using fdxms286 from the freedos project.

    >Have a look to "http://www.pbhq.de/filebase/", Markus.

    all i found was limited to 386 or up (as i said i have a 286) or
    are just demos with no real lib included (shareware which u need to
    register first).
    Two gave me some kind of errors (sorry dont remeber since i write that
    from home) i think that might come from some kind of 3.2 and 3.5 incompatibility
    (also wrote about this on my first post)

    well theres 3 left to have a closer look at
    (the ones who didnt stated allready in the readme that they require a 386)

    many thanks for the link. i allready found a lot of interesting
    stuff there. spend allmost the whole afternoon on that site

    have a nice day

    Markus

    ------------------

    Leave a comment:


  • Thomas Gohel
    replied

    On 22 Sep 05, Markus Maussner wrote:

    Hello Markus,

    > i am looking for a solution to use powerbasic and xms.
    > i am using fdxms286 from the freedos project.

    Have a look to "http://www.pbhq.de/filebase/", Markus.

    PS: "http://www.pbhq.de/cgi/pbsearch.exe?description=xms"

    Regards,

    --------------
    / h o m a s
    ------------------
    email : [email protected] / mailto:[email protected][email protected]</A> (PGP-Key available)
    www : http://www.gohel.de / http://www.pbhq.de (PowerBASIC)
    chat : irc://irc.pbhq.de/#pbhq.cafe (Online-Chat for PB users only!)
    bbs : telnet://bbs.pbhq.de (historical access to the PBSOUND HQ BBS)
    ## CrossPoint/Agent R/C2478, via PBNEWS v0.64g (news.pbhq.de)

    Leave a comment:


  • Markus Maussner
    started a topic XMS for Powerbasic ?

    XMS for Powerbasic ?

    Hi

    i am looking for a solution to use powerbasic and xms.
    i am using fdxms286 from the freedos project.
    On the website of powerbasic theres some libs but most of them
    require a 386 or better wich wont work in my case since i am writing
    for the 286 platform.
    theres still Brian McLaughlin's MAXLIB -- MAX12C.ZIP but it seems
    its not running with pb3.5 and i dont have 3.2 or so.

    anny help/tips would be greate

    markus

    ------------------
Working...
X