×   Main Menu ALL The 8BS News Manuals (New menu) Links Worth a Look Tools Disc and Basic Webring Site Map 8BS Guestbook Old Guest Book Me The Barnsley Rovers   
8-Bit Software

The BBC and Master Computer Public Domain Library

9FDB '/' operator - division

Submitted by Steve Fewell

Description:

Check the value type (in A).
If variable type = 0 (String) then Type Mismatch error [96DD].
If variable type is Integer then Convert to Float [96DD].
Push FWA value to Stack.

Call the expression handler level 6 routine, A012, to get the value of the second
operand (the divisor).
Check the value type (in A).
If variable type = 0 (String) then Type Mismatch error [96DD].
If variable type is Integer then Convert to Float [96DD].
Pop Dividend (first value) from Stack and set argp to point to it.
Call the Floating-Point Divide routine (A5EE), to divide argp by FWA and store
the result in the FWA.

Set A to &FF as we are handling a float value. Store X in &27 and call
&9FDB to check for further *,/,MOD or DIV operators.

Note: The '/' Operator always converts Integer values to Float-Point ones.
The '/' Operator does not call the DIV routine if both of the operands are Integer,
because the result may not be Integer. The Addition, Subtraction and Multiplication
routines need to handle conversion between and use of Integer routines as well as
Floating-Point ones, as the Integer routines are quicker, as we know that integer
operands will usually give an Integer result (unless multiplication of large numbers
is carried out).


Disassembly for the '/' Operator - Division routine

9FDB   168 A8 TAY
9FDC   032 221 150 20 DD 96 JSR &96DD Check Result Type (& If Int, Convert to Float)
9FDF   032 250 187 20 FA BB JSR &BBFA Push FWA to Stack
9FE2   032 018 160 20 12 A0 JSR &A012 Expression handler Level 6 [Skip Spaces, ^]
9FE5 ' 134 039 86 27 STX &27
9FE7   168 A8 TAY
9FE8   032 221 150 20 DD 96 JSR &96DD Check Result Type (& If Int, Convert to Float)
9FEB   032 232 187 20 E8 BB JSR &BBE8 Pop Float to argp
9FEE   032 238 165 20 EE A5 JSR &A5EE Floating-Point Division
9FF1   169 255 A9 FF LDA#&FF
9FF3   128 200 80 C8 BRA -56 --> &9FBD Store X & Check for further *,/,MOD or DIV operators

 


 Back to 8BS
Or