2025-06-15 Sun (cottage/home):
Problem (REF_L%) get parameter via a3 (NOT CA.GTSTR!)
Technical Guide says A3 points to the first parameter (my function
is using just the first parameter, all others are ignored). So I get
the first parameter with:
move.w 0(a6,a3.l),d5
into register D5 (this seems to work).
Then I make a test if parameter is preceeded by hash (#); I will perhaps
later allow an hash for an extension, so for now it's forbidden.
Now I test for if parameter is a string (type $0201 aka ntString).
Yes it is :‑)
Then there is my problem. Technical Guide says:
A3 points to the entry of the Name Table entry of the first parameter. The
Name Table entry is 8 bytes, first word is the type of the parameter. That's
ok, it is $0201 :-), second word is the pointer to the name in the Name List.
This pointer is -1 if there is no name for the parameter in the Name List,
this is also okay (it's FFFF which is -1 in decimal). Technical guide says
the last long word of the name table entry is the offset of the value in the
SuperBASIC Variables Value Area (BV.VVBAS). Offset means it's not a direct
pointer to the value, but the offset into BV.VVBAS from start of BV.VVBAS (which
you IMHO should always get with 28(a6); BTW: If not explicitly noted all values
are of course in hex.
So I think you should get the value of the parameter (a pointer to a string
in my case) with the code between:
;BEGIN Supervisor Mode
and
;END Supervisor Mode
into register a0.
(IMHO the code would run in 99.9% without the switch into SV-Mode, but if
a new job will be started, SuperBASIC (A6) may move, so I be careful.)
Unfortunately it does not work. What's my fault?
NOTE: I do NOT want to use CA.GTSTR to fetch the parameter via the RI-Stack!
In my machine code function I just need the value of the parameter (a normal
QDOS-string) to compare it with another QDOS-string. So I want to avoid
CA.GTSTR (which requires to adjust the RI-Stack and some other things). The
string is there (pointed to via A3 into the Name Table), why should I put it
on the RI-Stack (which must be reset before returning to the caller).
Here is the assembler code (not assemblable[!], the labels, definitions like
equ are missing):
Code: Select all
;Example (not working) for getting string value of a parameter which is
;NOT fetched with the vector CA.GTSTR:
cmpa.l a3,a5 ;Are there any parameters?
beq errBadParameter ;No
move.w 0(a6,a3.l),d5 ;Load type info of parameter
btst #bcHash,d5 ;Parameter preceeded by hash?
bne.s errBadParameter ;Yes
cmp.w #ntString,d5 ;Parameter is string? (We mustn't
bne.s errBadParameter ; currently care about separator
; as hash not allowed and it's
; the first parameter)
move.l ntValPtr(a6,a3.l),d7 ;d7=offset of string para. in VVA
;BEGIN Supervisor Mode:
trap #0 ;Switch into Supervisor Mode
move.l BV_VVBAS(a6),a4 ;Get base of variables values area
move.l 8(a4,d7.l),a0 ;a0 should now point (absolute!) to
;string parameter in VVA
sub.l a6,a0 ;make a0 ptr relative to a6
andi.w #endSV,sr ;Clear Supervisor Flag
;END Supervisor Mode
move.w 0(a6,a0.l),d5 ;d5 should now hold length of string
;
; What am I doing wrong?
; (After LRESPRing this _cde file the following statement outputs 0
; (I think it should output the length of the string, i.e. 1 for the
; example below):
;
; PRINT REF_L%('x')
;preliminary for debugging, we always return 32767 (i. e. stop prog)
move.l #32767,d4 ;DEBUG: Return max. allowed line no.
;Following are debugging statements only, to get value in d5:
;and.w #wRmHash,d5 ;Just for testing, remove eventual hash
move.w d5,d4 ;Just for testing, what's in d5?
move.w BV_CHRIX,a0 ;We need space on RI stack
moveq #2,d0 ;2 bytes required for line number
move.l BV_RIP(a6),a1 ;Per: Only QDOS needs this move
jsr (a0)
;Per Witte (thank you): We must correct the stack pointer with:
subq.l #2,BV_RIP(a6) ;This i where the real stack top is so
;here's where we need to take the space
move.l BV_RIP(a6),a1 ;Restore RI stack pointer
move.w d4,0(a6,a1.l) ;Push line no. (short int) ...
moveq #QINT,d4 ;... set return type (integer [short])
moveq #0,d0 ;No error
rts ;Return to SuperBASIC
errBadParameter
moveq #ERR_BP,d0
rts