×   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

9E58 '+' operator - addition

Submitted by Steve Fewell

Description:

Check the value type (in A).
If variable type = 0 then goto the String Addition routine.

If variable type is negative then the first value is a Float, so jump to &9E94, which
does the following:
* Push FWA to Stack
* Get the second value from the expression handler (level 5)
* If second value is a String then generate a Type Mismatch error.
* If second value is an Integer then convert it to a Float
* Pop the first Float value from Stack to argp (&4A, &4B)
* Call the Floating-Point Addition routine to add the values (&A68D)
* Jump to 9E4F (Expression handler level 4) to check for further + or - operators.

Otherwise, the value is Integer, so push the first value to the stack and call the
Expression Handler level 5 routine (&9FC4) to get the second value to add.
If the second value is a string then generate a Type Mismatch error.

If the second value is a Float then jump to &9EB0 to do the following:
* Pop the first value (the Integer) from the Stack
* Push the second value (the Float) to the Stack
* Convert the Integer to a Float (and put it in the FWA).
* Pop the second Float value from Stack to argp (&4A, &4B)
* Call the Floating-Point Addition routine to add the values (&A68D)
* Jump to 9E4F (Expression handler level 4) to check for further + or - operators.

Otherwise, both values are Integers, so carry out the Integer Addition routine. This
routine automatically jumps back to 9E4F on completion, to check for further + or - operators.


Disassembly for the '+' Operator - Addition routine

9E58   168 A8 TAY
9E59   240 199 F0 C7 BEQ -57 --> &9E22 String Addition
9E5B 07 048 055 30 37 BMI 55 --> &9E94
9E5D   032 196 159 20 C4 9F JSR &9FC4 Push Integer to stack & Expression handler level 5
9E60   168 A8 TAY
9E61 . 240 046 F0 2E BEQ 46 --> &9E91 [JMP &9092 Type Mismatch error]
9E63 0K 048 075 30 4B BMI 75 --> &9EB0
9E65 ...iplus (Integer addition)

Disassembly for the Floating Point '+' Operator

9E91 L 076 146 144 4C 92 90 JMP &9092 Type Mismatch error
9E94   032 250 187 20 FA BB JSR &BBFA Push FWA to Stack
9E97   032 199 159 20 C7 9F JSR &9FC7 Expression Handler level 5 (*,/,MOD,DIV)
9E9A   168 A8 TAY
9E9B   240 244 F0 F4 BEQ -12 --> &9E91 Type Mismatch error
9E9D ' 134 039 86 27 STX &27
9E9F 0 048 003 30 03 BMI 3 --> &9EA4
9EA1   032 133 129 20 85 81 JSR &8185 Convert Integer to Float
9EA4   032 232 187 20 E8 BB JSR &BBE8 Pop Float to argp
9EA7   032 141 166 20 8D A6 JSR &A68D Floating-Point Addition
9EAA ' 166 039 A6 27 LDX &27
9EAC   169 255 A9 FF LDA#&FF
9EAE   128 159 80 9F BRA -97 --> &9E4F Expression handler level 4 (+,-)
9EB0 ' 134 039 86 27 STX &27
9EB2   032 230 188 20 E6 BC JSR &BCE6 Pop Integer from Stack
9EB5   032 250 187 20 FA BB JSR &BBFA Push FWA to Stack
9EB8   032 133 129 20 85 81 JSR &8185 Convert Integer to Float
9EBB   128 231 80 E7 BRA -25 --> &9EA4

 


 Back to 8BS
Or