8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


Page Last Altered:

9241 (PRINT) TAB(

Submitted by Steve Fewell

Description:

Get the Integer result of the expression after the 'TAB(' keyword.
If the result is a Float then convert it to an Integer, if the result is a string then generate 'Type mismatch' error.

Get the next non-space character, if it is a "," then the TAB function call has two arguments so jump to &922D to
do the following:
* Push the first argument (&2A) to the Stack.
* Get the Integer result of the expression after the ','. If the result is a Floating-Point value then convert to an Integer,
if the result is a string then generate 'Type mismatch' error.
* If the next non-space character is not ')' then generate 'Missing )' error.
* Send #&1F to the Operating System output character routine (&FFEE) to start a VDU 31 command.
* Pop the first argument from the stack and send it to the Operating System output character routine (&FFEE).
* Call routine &9840 to send &2A (the second argument) to the Operating System output character vector (&020E).
* Now, the cursor should be in the required position (as VDU 31 command with 2 arguments moves the cursor to
the specified location).
* Jump to &926A: (Clear carry, Set PTR A Offset to PTR B Offset & exit (back to the PRINT routine).
Otherwise, the TAB function has only one argument so continue with &9249 and do the following:
* Check whether next character is a ')', if it isn't then generate 'Missing ,' error.
* Subtract COUNT (&1E) from the 1-byte Integer result (&2A).
* If the subtraction result is zero then jump to &926A: (Clear carry, Set &0A (PTR A Offset) to &1B (PTR B Offset)
and exit (back to the PRINT routine).
* If the subtraction result was positive (carry flag still set) then set X to the subtraction result and
jump to &9262 to output X number of spaces (and then Clear carry, Set &0A (PTR A Offset) to &1B (PTR B Offset),
and exit (back to the PRINT routine).
* If the subtraction result was negative (carry flag is clear) then call &BA92 to output a new line and set
COUNT (&1E) to zero and jump to &925E to Set X to &2A and output X number of spaces (and then Clear carry,
Set &0A (PTR A Offset) to &1B (PTR B Offset), and exit (back to the PRINT routine).


Disassembly for the (PRINT) TAB( routine

922A L 076 246 142 4C F6 8E JMP &8EF6 'Missing ,' error
922D * 165 042 A5 2A LDA &2A
922F H 072 48 PHA
9230   032 167 150 20 A7 96 JSR &96A7 Extract Integer result of expression and check for closing bracket
9233   169 031 A9 1F LDA#&1F
9235   032 238 255 20 EE FF JSR &FFEE OSWRCH (Write character)
9238 h 104 68 PLA
9239   032 238 255 20 EE FF JSR &FFEE OSWRCH (Write character)
923C @ 032 064 152 20 40 98 JSR &9840 Send ?&2A to the OS output vector
923F ) 128 041 80 29 BRA 41 --> &926A Clear carry flag, Set PTR A offset = PTR B offset and exit
9241   032 175 150 20 AF 96 JSR &96AF Get Integer result of expression
9244   032 235 142 20 EB 8E JSR &8EEB Get next non-space character (PTR B) and compare with ','
9247   240 228 F0 E4 BEQ -28 --> &922D
9249 ) 201 041 C9 29 CMP#&29 ')'
924B   208 221 D0 DD BNE -35 --> &922A
924D * 165 042 A5 2A LDA &2A
924F   229 030 E5 1E SBC &1E (COUNT)
9251   240 023 F0 17 BEQ 23 --> &926A Clear carry flag, Set PTR A offset = PTR B offset and exit
9253   170 AA TAX
9254   176 012 B0 0C BCS 12 --> &9262 Output X number of spaces, clr carry, PTR A=PTR B & exit
9256   032 146 186 20 92 BA JSR &BA92 Start new output line
9259   128 003 80 03 BRA 3 --> &925E Output ?&2A number of spaces, clr carry, PTR A=PTR B & exit

9840 Send character in ?&2A to the Output vector

9840 * 165 042 A5 2A LDA &2A
9842 l 108 014 002 6C 0E 02 JMP (&020E) OS Output character vector (WRCHV)

 


 Back to 8BS
Or