QDOS: To LRESPR or not

By | 2018-08-08

Update: the old code had a bug if the EXE was made resident using the HOT_RES keyword (thanks to Jan Bredenbeek for pointing it out), updated code below.

Today I’ve had a short discussion about creating a QDOS executable that can both be LRESPRed (to install a thing) and EXecuted (to, erm, execute it). One important detail is that LRESPR must only work in the main BASIC, as otherwise the system will crash once the daughter BASIC is terminated. There are several ways to do it, but I’d like to share mine:

base    bra.s   start
        dc.w    $4AFB
        dc.w    4
        dc.b    'Test'

; Trick: on an EXE call a6 must point to either a BRA ($60) or JMP ($4E).
; both have bit 6 set ($40). On Basic a6 points to the MSB of sb_buffb.
; Bit 6 will never be set as long as QLs have less than 1GB of RAM :-)
        btst    #6,(a6)
        beq.s   lrespr                  ; Definitely LRESPR
        cmp.w   #$4afb,6(a6)            ; This check is somewhat optional...
        beq.s   job_start               ; but in case QLs ever have >1GB... :)

        moveq   #sms.info,d0
        trap    #1
        tst.l   d1                      ; Job ID = main BASIC
        beq.s   basic_start

; LRESPRed from daughter SBASIC/MultiBasic
        moveq   #err.nimp,d0

; LRESPred from main BASIC
;       ...
        moveq   #0,d0

; EXECed as normal job
;       ...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.