hewlett-packard HP 9835A — 108

108 Communication Between BASIC and Assembly Language By way of example, suppose that you have an ICALL which is being used to call a sort routine and the routine was written in such a way as to require two arguments be passed to it - an array to be sorted and the number of elements to be sorted (in that order). Then the following would be valid calls to that routine - ICALL Sort(Test~~},100) ICALL Sort(Test$(+),Number Upon executing the ICALL statement, execution in a program transfers to the routine named. Upon return from the routine, control is passed to the BASIC statement which follows the ICALL. This is identical in effect to the CALL statement in BASIC.

In executing the statement from the keyboard, the routine named is executed just as if it were used in a program. Upon return from the routine, control is passed back to the keyboard. This is unlike BASIC's CALL statement, which cannot be executed from the keyboard. To execute a routine, whether it be from a program or from the keyboard, its object code must currently reside in the ICOM region. Corresponding Assembly Language Statements When the ICALL is executed, it references a routine in the object code. When the module containing the routine was assembled, it declared that routine name as a "subroutine" entry point.

("Subroutine" and "routine" are synonymous in this context.) This is done with a SUB pseudo-instruction and a label. When a SUB pseudo-instruction appears in the source code, it is a signal to the assembler that a subroutine entry point follows. Then the first machine instruction (or some code-generating pseudo-instruction, such as BSS or DAT) must have a label. That label becomes the routine name. If the label is missing, an error results (assembly-time "SQ" error). For example, in the above examples of ICALL, the Sort routine could have been defined by the sequence - 130URCE SUB except that there are arguments involved.

(That exception is discussed in a moment.) The joint referenceable with an ICALL statement. use of these two statements results in the label "Sort" being identified as a routine name,