[Info-vax] BASIC and AST routines
Dave Froble
davef at tsoft-inc.com
Fri Nov 19 12:45:18 EST 2021
On 11/19/2021 6:43 AM, Bob Gezelter wrote:
> On Friday, November 19, 2021 at 12:35:24 AM UTC-5, Dave Froble wrote:
>> On 11/18/2021 10:49 PM, Bob Gezelter wrote:
>>> On Thursday, November 18, 2021 at 8:08:47 PM UTC-5, Chris Townley wrote:
>>>> On 18/11/2021 23:31, Bob Gezelter wrote:
>>>>> On Wednesday, November 17, 2021 at 6:14:30 PM UTC-5, John Doppke wrote:
>>>>>> So I've been playing with writing AST routines (stubbornly) in BASIC. They work ok, but I've found I have to declare the routine as having 5 'standard' parameters - "function long AST long (p1, p2, p3, p4, p5)". I'm not sure what the 5 parameters are, but doing anything with them is usually a bad idea. I communicate with my main program using common or event flags.
>>>>>>
>>>>>> Now I need an AST for a call that requires a parameter - SMG$ENABLE_UNSOLICITED_INPUT. I've tried adding a parameter in my usual list in different ways but I can't get it to work. Every time it's called I get a reserved opcode exception. (A DCLAST call with my AST works ok).
>>>>>>
>>>>>> Can anyone shed some light on what the parameters are that BASIC is getting? I'll probably end up writing this one in MACRO, but I want to understand what is happening.
>>>>>>
>>>>>> -John
>>>>> John,
>>>>>
>>>>> Been there, done that (for a client whose entire codebase was written in BASIC).
>>>>>
>>>>> As VAXman and Dave Froble noted, the five parameters are passed are, and I quote from David's posting:
>>>>>
>>>>> "From the 7.3 docs:
>>>>>
>>>>> Table 8–3 AST Arguments for VAX Systems and Alpha Systems
>>>>> VAX System Arguments Alpha System Arguments
>>>>> AST parameter AST parameter
>>>>> R0 R0
>>>>> R1 R1
>>>>> PC PC
>>>>> PSL PS "
>>>>>
>>>>> One will notice that the correct number of parameters restriction does not appear in all languages. C , FORTRAN, and others have looser restrictions on parameter lists, as well as variable-sized parameter lists. BASIC does not. BASIC requires that the parameter lists match in size and type AND enforces that restriction at the called routine interface. In the OpenVMS DOC set, I have seen examples which presume that the parameter count restriction is not enforced. They are a bit misleading in the case of BASIC.
>>>>>
>>>>> Many library routines can be called from both normal thread and AST contexts, but since many of the library routines are not- re-entrant, one cannot generally call library routines from both AST and process threads. However, most OpenVMS general library routines and system services are reentrant, and can be invoked without excessive difficulty from BASIC. While many define their own prototypes I highly recommending the include files from the BASIC text library in SYS$LIBRARY. If those are out of date, write your own versions with correct parameter list definitions, correctly implemented definitions save a lot of fighting with debugging.
>>>>>
>>>>> As to what is the AST parameter, my general practice is to use a data structure for each file, and pass a pointer to that file as the AST parameter. That allows storage of useful information beyond the file number/handle.
>>>>>
>>>>> - Bob Gezelter, http://wwww.rlgsc.com
>>>>>
>>>> IIRC Basic can handle variable number of parameters when calling a
>>>> sub/function, but you cannot write them in Basic
>>>>
>>>>
>>>> --
>>>> Chris
>>> Chris,
>>>
>>> Not relevant. I the case referenced, the AST, written in BASIC, is the CALLED routine. As to what can be called from BASIC, I suggest reading the reference manual. As I recall, the original header files had no parameter definitions, so it was possible to easily fall into the trap. Later versions allowed more precision, but the older form was preserved for backward compatibility.
>>>
>>> Of course, more than a few people did not pick up the change and continued the earlier approach, which leads to problems.
>>>
>>> - Bob Gezelter, http://www.rlgsc.com
>>>
>> I'm going to confess to curiosity. Why are R0, R1, SP, and PC passed to an AST
>> routine?
>> --
>> David Froble Tel: 724-529-0450
>> Dave Froble Enterprises, Inc. E-Mail: da... at tsoft-inc.com
>> DFE Ultralights, Inc.
>> 170 Grimplin Road
>> Vanderbilt, PA 15486
> David,
>
> Am rather busy this morning, but the IDSM has a full description of the dispatching process for an AST.
>
> - Bob Gezelter, http://www.rlgsc.com
>
Oh, you mean that big book on the bookshelf gathering dust?
Got to now consider how curious I really am.
--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. E-Mail: davef at tsoft-inc.com
DFE Ultralights, Inc.
170 Grimplin Road
Vanderbilt, PA 15486
More information about the Info-vax
mailing list