×   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

92BE CALL

Submitted by Steve Fewell

Description:

Call routine &9D2F to get the result of the expression at the BASIC Text pointer A location. This value should be the
CALL address.
Call routine &96BC to convert the result to an Integer value (if Float, or issue 'Type mismatch' error if it is a
String value).

Push the Integer call address value (IWA) to the BASIC stack.
Store zero in location &0600 (the parameter block used to pass parameters to the machine code routine - &0600
contains the number of variables in the parameter block, which is initalised to 0).
Set Y to 0 (the last used location in the machine code call parameter block).
[&92CC] Store Y on the 6502 stack.
Get the next non-space character from BASIC text pointer B location.

If the next character was a comma ',', a (or another) parameter value is present (and is required to be stored in the
machine code call parameter block (&0600). This is done as follows:
* Set Y to &1B (the BASIC Text pointer B offset)
* Call routine &9901 to store Y to &1B (Text pointer B offset), skip any space characters and return the
    address or the value of the variable denoted by the variable name (located after the comma)
* If routine &9901 returns with the zero flag set then issue 'No such variable' error as a variable name was not
    found
* Retrieve Y from the 6502 stack, and increment Y (to point to the next free location in the parameter block)
* Store the variable address (from location &2A-&2B) and type (from location &2C) details in the next 3
    locations in the machine code call parameter block (starting at offset Y) and increment Y twice
* Increment &0600 (the number of variables in the machine code call parameter block)
* Jump back to &92CC to check for further variable parameters
[&92F1] Otherwise (no comma found), there are no (or no further) variable paremeter details to store in the machine
code call parameter block (located at &0600-&06FF).

Retrieve Y from the 6502 stack (it's value can now be discarded).
Decrement the BASIC Text pointer B offset (&1B) to point to the character after the CALL address (or after the last
variable parameter value) and call routine &9B96 to check that the statement is terminated correctly with either a
':', '<cr>' or 'ELSE-token' character ('Syntax error' is issued if the statement is not correctly terminated).

Retrieve the CALL Address value from the BASIC stack (and store the value in the IWA).
Call the &9304 subroutine to execute the machinbe code routine as follows:
* Set A to &040C (the LSB of the C% variable) and shift the bits right 1 place, so that the carry flag is
    set to the value of the first bit (bit 0) of the &040C value.
* Set A to &0404 (the LSB byte of the A% variable)
* Set X to &0460 (the LSB byte of the X% variable)
* Set Y to &0464 (the LSB byte of the Y% variable)
* jump to the machine code address pointed to by IWA bytes &2A-&2B. The machine code routine will provide
    the return instruction to return from the &9304 subroutine.
[&92FD] After the routine &9304 has been executed, and the machine code routine has been run, the decimal flag
is cleared (as BASIC requires the decimal flag to be clear - otherwise its calculations will be incorrect) and jumps
to &9005 to execute the next statement in the BASIC program/command line input.


Disassembly for the CALL routine

92BE / 032 047 157 20 2F 9D JSR &9D2F Ptr B = Ptr A & Get result of expression
92C1   032 188 150 20 BC 96 JSR &96BC Check result type (location &27) - if Float then convert to Integer
92C4 & 032 038 188 20 26 BC JSR &BC26 Push IWA value to the BASIC Stack [pushi]
92C7   156 000 006 9C 00 06 STZ &0600
92CA   160 000 A0 00 LDY#&00
92CC Z 090 5A PHY
92CD   032 235 142 20 EB 8E JSR &8EEB Get next non-space char (PTR B) & compare with ','
92D0   208 031 D0 1F BNE 31 --> &92F1
92D2   164 027 A4 1B LDY &1B
92D4   032 001 153 20 01 99 JSR &9901 Store Y to &1B, skip spaces & Evaluate variable/array name & return the address of the value
92D7 ( 240 040 F0 28 BEQ 40 --> &9301   'No such variable' error
92D9 z 122 7A PLY
92DA   200 C8 INY
92DB * 165 042 A5 2A LDA &2A
92DD   153 000 006 99 00 06 STA &0600,Y
92E0   200 C8 INY
92E1 + 165 043 A5 2B LDA &2B
92E3   153 000 006 99 00 06 STA &0600,Y
92E6   200 C8 INY
92E7 , 165 044 A5 2C LDA &2C
92E9   153 000 006 99 00 06 STA &0600,Y
92EC   238 000 006 EE 00 06 INC &0600
92EF   128 219 80 DB BRA -37 --> &92CC
92F1 z 122 7A PLY
92F2   198 027 C6 1B DEC &1B
92F4   032 150 155 20 96 9B JSR &9B96 Check for end of Statement (PTR B)
92F7   032 230 188 20 E6 BC JSR &BCE6 Retrieve IWA value from the BASIC Stack [popi]
92FA   032 004 147 20 04 93 JSR &9304 Execute the machine code routine pointed to by the IWA (&2A-&2B)
92FD   216 D8 CLD
92FE L 076 005 144 4C 05 90 JMP &9005 Continue running program (execute next statement)
9301 L 076 140 173 4C 8C AD BNE 12 --> &AD8C No such variable error
9304   173 012 004 AD 0C 04 LDA &040C
9307 J 074 4A LSR A
9308   173 004 004 AD 04 04 LDA &0404
930B ` 174 096 004 AE 60 04 LDX &0460
930E d 172 100 004 AC 64 04 LDY &0464
9311 l* 108 042 000 6C 2A 00 JMP (&002A)

 


 Back to 8BS
Or