8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


BASIC IV ROM Routines
Page Last Altered:


99AE '!' and '?' address modifier operators

Submitted by Steve Fewell

Routine:addrmodify
Name: '!' and '?' address modifier operators
Starting Address: &99AE (for '!') or &99B0 with A=0 (for '?')
Entry criteria: &2A and &2B point to the contents of the variable.
The Text Pointer B points to the next character of the program line.
Exit:(&2A, &2B) contain the adjusted address (variable value + modifier value).
&2C contains the return type (of the value to obtain from the new address).

Description:

Store the return value type on the stack (0 for 1-byte Integer or 4 for 4-byte Integer).
Store back the offset in &1B, as we have correctly evaluated the variable address.
Load the variable value to obtain the base-memory address to modify.
If the variable is a string, then it is not a Memory address so generate a Type mismatch error.

Store the Integer base-address MSB (&2B) on the Stack.
Store the Integer base-address LSB (&2A) on the Stack.
Get the Integer value at PTR B. This provides the value to modify the base-address by.

Add the Integer value to the Base memory address (from the Stack). Now (&2A, &2B) contain
the modified address.
Exit with Carry clear and A = #&FF (meaning that the routine ended sucessfully).


Disassembly for the '!' and '?' address modifier operators routine

99AE   169 004 A9 04 LDA#&04
99B0 H 072 48 PHA
99B1   200 C8 INY
99B2   132 027 84 1B STY &1B
99B4   032 160 177 20 A0 B1 JSR &B1A0 Load Variable
99B7   032 191 150 20 BF 96 JSR &96BF Check if Integer and Convert if Float
99BA + 165 043 A5 2B LDA &2B
99BC H 072 48 PHA
99BD * 165 042 A5 2A LDA &2A
99BF H 072 48 PHA
99C0   032 180 150 20 B4 96 JSR &96B4 Get Integer value at PTR B
99C3   024 18 CLC
99C4 h 104 68 PLA
99C5 e* 101 042 65 2A ADC &2A
99C7 * 133 042 85 2A STA &2A
99C9 h 104 68 PLA
99CA e+ 101 043 65 2B ADC &2B
99CC + 133 043 85 2B STA &2B
99CE h 104 68 PLA
99CF , 133 044 85 2C STA &2C
99D1   024 18 CLC
99D2   169 255 A9 FF LDA#&FF
99D4 ` 096 60 RTS

 


 Back to 8BS
Or