A statement to call a machine code subroutine.
CALL Muldiv,A,B,C,D CALL &FFE3 CALL 12340,A$,M,J$
CALL sets up a table in RAM containing details of the parameters; the processor's IX register is set to the address of this parameter table. The other processor registers are initialised as follows:
- A is initialised to the least significant byte of A%
- B is initialised to the least significant byte of B%
- C is initialised to the least significant byte of C%
- D is initialised to the least significant byte of D%
- E is initialised to the least significant byte of E%
- F is initialised to the least significant byte of F%
- H is initialised to the least significant byte of H%
- L is initialised to the least significant byte of L%
The parameter types are:
|Code No.||Parameter Type||Example|
|0||Byte (8 bits)||?A%|
|4||Word (32 bits)||!A% or A%|
|5||Real (40 bits)||A|
On entry to the subroutine the parameter table contains the following values:
- Number of parameters 1 byte (at IX+0).
- Parameter type 1 byte (at IX+1).
- Parameter address 2 bytes (at IX+2, IX+3, LSB first).
- Parameter type 1 byte (repeated as often as necessary).
- Parameter address 2 bytes (repeated often as necessary).
Except in the case of a movable string (normal string variable), the parameter address given is the absolute address at which the item is stored. In the case of movable strings (type 129) it is the address of a 4-byte parameter block containing the current length, the maximum length and the start address of the string (LSB first) in that order.
Integer variables are stored in twos complement form with their least significant byte first.
Fixed strings are stored as the characters of the string followed by a carriage return (&0D).
Floating point variables are stored in binary floating point format with their least significant byte first; the fifth byte is the exponent. The mantissa is stored as a binary fraction in sign and magnitude format. Bit 7 of the most significant byte is the sign bit and, for the purposes of calculating the magnitude of the number, this bit is assumed to be set to one. The exponent is stored as an integer in excess 127 format (to find the exponent subtract 127 from the value in the fifth byte).
If the exponent byte of a floating point number is zero, the number is an integer stored in integer format in the mantissa bytes. Thus an integer can be represented in two different ways in a real variable. For example the value +5 can be stored as:
05 00 00 00 00 Integer 5 00 00 00 20 82 (0.5 + 0.125) * 2^3
Here is an example assembly program routine that allows you to find the upper bound of an array.
10 DIM UBOUND 40 20 P%=UBOUND 30 [ 40 OPT 0 50 LD A,(IX+0) 60 CP 2:RET NZ 70 LD A,(IX+4) 80 CP 4:RET NZ 90 LD L,(IX+2):LD H,(IX+3) 100 DEC HL:LD D,(HL) 110 DEC HL:LD E,(HL) 120 DEC DE 130 LD L,(IX+5):LD H,(IX+6) 140 LD (HL),E:INC HL 150 LD (HL),D:INC HL 160 LD (HL),0:INC HL 170 LD (HL),0 180 RET 190 ]
It expects there to be two arguments - an array element (input) and an integer to receive the upper bound (size). You could then invoke it like this:
DIM array$(12) CALL UBOUND,array$(0),ub% PRINT ub%
which would output '12'.
See the Format of Program and Variables in Memory or Assembler sections for more information.