Tandy 1000 Basic Reference Manual page 356

Hide thumbs Also See for 1000:
Table of Contents

Advertisement

Chapter 11 I Technical Information
When the CALL statement is executed, the operating system
loads the CS (code segment) register with the value specified in
the last DEF SEG statement. If you are CALLing a subroutine
within BASIC's work area, and no DEF SEG is required, the CS
register is loaded with the address of BASIC's work area. This
address
is
shifted left
4 bits;
in
other words, which is the same
as multiplying it by 16 decimal (10 hexadecimal). Then, the off-
set of the subroutine is added to the segment address.
Example
1 7 1 0 0
+
0 0 2 0
=
1 7 1 2 0
17120 is the absolute address of the first instruction in the
subroutine.
Technical Functions
The called routine may destroy the previous contents of all regis-
ters. If you want to save the contents of the registers, the first
instructions in the subroutine must be a PUSH for each register,
and the last instructions in the subroutine must be a POP to re-
store the registers to their original value. You must execute a
POP for every PUSH to maintain stack integrity.
The subroutine may refer to the passed parameters as positive
offsets to the Base Pointer (BPI. The CALLed routine must
PUSH BP on the stack and then move the current stack pointer
into BP. BP should be the first register you PUSH so that the
parameters may be referenced as an offset t o BP. The first 4
bytes of the stack contain the IP and CS register values that
BASIC saves when the CALL is executed.
To calculate the pa-
rameters offset from the BP, use this equation:
2
*
(total parameters
-
parameter position)
+
6
=
offset
For example, the address of parameter 1 is a t 10(BP), parameter
2 is a t S(BP), and parameter 3 is a t 6(BP).
354

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents