Apple ii Battery Charger User Manual


 
Parameter (W), passed to a subroutine by USR(W), will be converted to floating-point accumulator
located at $A9. The floating-point accumulator has the following format:
ADDRESS CONTENT
$A9 Exponent + $81 ($80 if mantissa = 00)
$AA-$AD Mantissa, normalized so that Bit 7 of MSB is set.
$AA is MSB, $AD is LSB.
$AE Sign of mantissa
A parameter passed to an assembly language subroutine from BASIC can be truncated by the sub-
routine to a 2-byte integer and deposited in $AC (MSB) and $AD (LSB). If the parameter is
greater than 32767 or less than -32768, an FC error will result. The address of the subroutine
that converts a floating-point number to an integer is located in $B006, $B007.
A parameter passed to BASIC from an assembly language subroutine will be converted to floating-
point. The address of the subroutine that performs this conversion is in $B008, $B009. The
integer MSB ($AC) must be in the accumulator; the integer LSB ($AD) must be in the Y register.
Prior to executing USR, the starting address of the assembly language subroutine must be stored
in locations $04 (LSB) and $05 (MSB). This is generally performed using the POKE command.
Note that more than one assembly language subroutine may be called from a BASIC program,
by changing the starting address in $04 and $05.
Figure F-1 is the listing for a BASIC program that calls an assembly language subroutine located at
$A00. Here's what the BASIC program does:
* Line 10 - Stores the starting address of the assembly language subroutine ($A00) into
locations $04 and $05, using POKE.
* Line 20 - Asks for a number "N".
* Line 30 - Calls the subroutine, with N as the parameter.
* Line 40 - Upon return from the subroutine, the BASIC program prints X, the parameter
passed from the subroutine to the BASIC program.
* Line 50 - Loops back to get a new N
ROCKWELL AIM 65
<5>
MEMORY SIZE? 2048
WIDTH?
1518 BYTES FREE
AIM 65 BASIC V1.1
OK
10 POKE 04,0: POKE 05
,10
20 INPUT"NUMBER";N
30 X=USR(N)
40 PRINTX
50 GOTO 20
Figure F-1. BASIC Program That Calls Assembly Language Subroutine
The assembly language subroutine (Figure F-2) performs these operations:
* Prints the floating-point accumulator ($A9-$AE), using Monitor subroutines NUMA
($EA46), BLANK ($E83E) and CRLF ($E9F0),
* Converts the floating-point accumulator to an integer, using the subroutine at $BF00.
The address $BF00 was found in locations $B006, $B007. (Address $BF00 may vary
with different versions of BASIC. Be sure to check locations $B006 and $B007 for the
correct address.)
* After conversion, the program again prints the floating point accumulator,