8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


Page Last Altered:

B2EC ENVELOPE

Submitted by Steve Fewell

Description:

Get the result of the expression at BASIC Text Pointer A and convert the result to Integer (if Float), or issue a
'Type mismatch' error (if String value found).
Set X to 13 (as we have 14 parameters to obtain).

Loop for X number of times. For each loop:
* Push the Integer result (next parameter) LSB (&2A) to the Stack.
* Temporarily push X to the stack
* Check for "," (comma) charater (issue "Missing ," error if not found), and get the Integer result of expression at
     BASIC Text pointer B.
* Retrieve X from the stack.
* Decrement X value.
* If X is not 0 yet then loop again.
Now, we have the first 13 parameters on the stack and the last parameter in the IWA (&2A).

Call routine &9B96 to check that the Statement terminates correctly (if not, then a 'Syntax' error is issued).
Store the last parameter (IWA location &2A) in location &44.
Set X to 12 (Number of parameters left - 1).
Set Y to 8 (OSWORD call number for ENVELOPE).

[&B307] Pop the last Byte from the stack and store in location (&37 + X), i.e. location &43 for the 13th parameter).
Decrement X and keep repeating from &B307 until X is negative.

Now location &37 to location &37 + Original X value + 1 (i.e. &44 for ENVELOPE parameter block) contain the
OSWORD call parameters.
Set A to Y value (the number of the OSWORD call).
Set X to #&37 and Y to #&00 (as the start of the parameter block is &0037).
Call the Operating System OSWORD routine (&FFF1) to perform the required operation.
Jump to &9005 to start processing the next Statement (if any).


Disassembly for the ENVELOPE routine

B2EC o 032 111 146 20 6F 92 JSR &926F Evaluate Expression at BASIC Text pointer A & convert result to integer
B2EF   162 013 A2 0D LDX#&0D
B2F1 * 165 042 A5 2A LDA &2A
B2F3 H 072 48 PHA
B2F4   218 DA PHX
B2F5   032 172 150 20 AC 96 JSR &96AC Check for ',', get result of expression and convert result to Integer
B2F8   250 FA PLX
B2F9   202 CA DEX
B2FA   208 245 D0 F5 BNE -11 --> &B2F1
B2FC   032 150 155 20 96 9B JSR &9B96 Check for end of Statement (PTR B)
B2FF * 165 042 A5 2A LDA &2A
B301 D 133 068 85 44 STA &44
B303   162 012 A2 0C LDX#&0C
B305   160 008 A0 08 LDY#&08
B307 h 104 68 PLA
B308 7 149 055 95 37 STA &37,X
B30A   202 CA DEX
B30B   016 250 10 FA BPL -6 --> &B307
B30D   152 98 TYA
B30E 7 162 055 A2 37 LDX#&37
B310   160 000 A0 00 LDY#&00
B312   032 241 255 20 F1 FF JSR &FFF1 OSWORD
B315   128 011 80 0B BRA 11 --> &B322 [JMP &9005] Continue with next Statement

 


 Back to 8BS
Or