Routines |
Prev: 11563 | Up: Map | Next: 11599 |
This subroutine returns a 'last value' on the calculator stack that is the result of converting an integer in a BASIC line, i.e. the integer part of the decimal number or the line number, to its floating-point form.
Repeated calls to CH_ADD_1 fetch each digit of the integer in turn. An exit is made when a code that does not represent a digit has been fetched.
|
||||||||||||
INT_TO_FP | 11579 | PUSH AF | Save the first digit - in A. | |||||||||
11580 | RST 40 | Use the calculator. | ||||||||||
11581 | DEFB 160 | stk_zero: (the 'last value' is now zero) | ||||||||||
11582 | DEFB 56 | end_calc | ||||||||||
11583 | POP AF | Restore the first digit. | ||||||||||
Now a loop is set up. As long as the code represents a digit then the floating-point form is found and stacked under the 'last value' (V, initially zero). V is then multiplied by 10 and added to the 'digit' to form a new 'last value' which is carried back to the start of the loop.
|
||||||||||||
NXT_DGT_2 | 11584 | CALL STK_DIGIT | If the code represents a digit (D) then stack the floating-point form; otherwise return. | |||||||||
11587 | RET C | |||||||||||
11588 | RST 40 | Use the calculator. | ||||||||||
11589 | DEFB 1 | exchange: D, V | ||||||||||
11590 | DEFB 164 | stk_ten: D, V, 10 | ||||||||||
11591 | DEFB 4 | multiply: D, 10*V | ||||||||||
11592 | DEFB 15 | addition: D+10*V | ||||||||||
11593 | DEFB 56 | end_calc: D+10*V (this is 'V' for the next pass through the loop) | ||||||||||
11594 | CALL CH_ADD_1 | The next code goes into A. | ||||||||||
11597 | JR NXT_DGT_2 | Loop back with this code. |
Prev: 11563 | Up: Map | Next: 11599 |