hewlett-packard HP 9835A — 116

116 Communication Between BASIC and Assembly Language The array information returned by the Get_info utility is used for accessing elements in arrays passed as arguments. It is used by the element-retrieval utilities described in a later section of this chapter. Once retrieved, the information is usable any number of times for accessing the array associated with it. It is not necessary to retrieve the information every time you access an array, as long as you have not altered the information (except the pointer) between accesses. The seventeenth word of the array information (word 16 on the chart) is reserved to hold the offset from the start of the array of the element to be accessed.

Therefore, it is permissible (indeed, it is necessary) to alter the contents of that location to indicate which element in the array you wish to retrieve. None of the other words returned by the utility should be changed. In making multiple accesses with the same information, caution should be taken when an array is involved. If a REDIM statement is executed upon the array between accesses, the information may not reflect the true structure of the array. This potentiality can be addressed in one of two ways- • Advise the BASIC user against using a REDIM on the array between executions of the routine or routines involved . • Call the Get_info utility each time the array is accessed.

Similar problems exist when a BASIC subprogram is called recursively, and the subprogram uses a local array as an argument in an ICALL, or when a subprogram calls a routine and later exits (causing its local arrays to disappear). Retrieving the Value of an Argument At some point during execution of your assembly language routine, you may want to retrieve the value of an argument so that you can use it in your processing. By doing so, you accomplish the assembly language routine from BASIC. one of the methods of communicating with assembly language - namely, passing a value TO There are a number of utilities for this purpose. The one to use is dependent upon the type of argument passed.

The utilities available are - Name Used For Get value Simple variables, expressions, individual elements of arrays passed as arguments, and file numbers Elements (from arrays passed as arguments) Get element Get_bytes Substrings of strings passed as arguments either as simple string variables, expressions, or individual elements of arrays passed as arguments Substrings of individual elements (from string arrays passed as arguments) Get _ elem _ bytes