8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


Page Last Altered:

BA17 UNTIL

Submitted by Steve Fewell

Description:

Call routine &9D2F to set BASIC text Pointer B to the BASIC text pointer A value and get the result of the expression
pointed to by BASIC text pointer B.

Call routine &9B91 to check for the end of the Statement - if the end of statement (either a ':', '<cr>' or 'ELSE'
character) is not found after the expression then issue 'Syntax error', as the UNTIL statement does not finish correctly.

Call routine &96BC to check the result type of the expression (location &27), and convert the expression result
value to an Integer if it is a Floating-Point value, or issue 'Type mismatch' error if it is a String value.
The IWA now contains the value of the result of the expression.

Load X with the current REPEAT level (from location &24).
If X is zero, then no outstanding REPEAT statements are active, so issue 'No REPEAT' error.

Check the IWA result value - if the IWA contains zero, then the result of the UNTIL expression is false, so [&BA33]
load Y with the LSB of the REPEAT start address from the REPEAT start address stack (&04FF + X (current REPEAT
level)) and load A with the MSB of the REPEAT start address from the REPEAT start address stack (&0513 + X (current
REPEAT level)), and jump to &B732 to set the BASIC text pointer A to the REPEAT start address value (in Y and A) and
jump to &900B to continue executing the program from the REPEAT start address.

Otherwise, the UNTIL expression is true, and we have finished the REPEAT...UNTIL loop, so decrement the current
REPEAT level - so that it is now set to the level before the REPEAT loop began, and jump to &9005 to continue
executing the program, starting with the next program statement after the UNTIL statement.


Disassembly for the UNTIL routine

BA17 / 032 047 157 20 2F 9D JSR &9D2F Ptr B = Ptr A & Get result of expression [PTR B]
BA1A   032 145 155 20 91 9B JSR &9B91 X = A; Check for end of Statement (PTR B)
BA1D   032 188 150 20 BC 96 JSR &96BC Check result type (location &27) - if Float then convert to Integer
BA20 $ 166 036 A6 24 LDX &24
BA22   240 215 F0 D7 BEQ -41 --> &B9FB No REPEAT error
BA24 * 165 042 A5 2A LDA &2A
BA26 + 005 043 05 2B ORA &2B
BA28 , 005 044 05 2C ORA &2C
BA2A - 005 045 05 2D ORA &2D
BA2C   240 005 F0 05 BEQ 5 --> &BA33
BA2E $ 198 036 C6 24 DEC &24
BA30 L 076 005 144 4C 05 90 JMP &9005 Continue running program (execute next statement)
BA33   188 255 004 BC FF 04 LDY &04FF,X
BA36   189 019 005 BD 13 05 LDA &0513,X
BA39 L2 076 050 183 4C 32 B7 JMP &B732 Jump to the address in Y (MSB) and A (LSB) and continue executing the program from this address

 


 Back to 8BS
Or