×   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

A26C (?) / A279 Multiply FWA Mantissa by 10

Submitted by Steve Fewell

Routine:FWAMantissaMult10
Name: Floating-Point Division (FWA=FWB/FWA)
Starting Address: &A279
Entry criteria: The FWA contains the number to multiply by 10.
Exit: FWA Mantissa has been multiplied by 10.

Description:
A26C (Not used by any routines so far described - context not fully understood)

A = FWA Mantissa byte 1. Divide by 8 [move top 4 bits to bottom 4 bits]
gosub A2CE :- Convert A to ASCII & put ASCII value back at the end of string (&0600)
A = ?&F0.
Test & reset bits in &31 :- Set top 4 bits of &31 to zero (to reduce the value by 48)
thus converting the digit from ASCII to decimal.

A279 : Multiply the FWA's Mantissa by 10.
Temporarily backup A on the stack.
X = ?&34 - FWA Mantissa bit 4
Push ?&31 [FWA Man 1] to Stack
Push ?&32 [FWA Man 2] to Stack
Push ?&33 [FWA Man 3] to Stack

A = ?&35 [FWA Rounding]
A = A * 2 (Transferring the overflow & effect of the multiplication through to
&34, &33, &32, &31 (the rest of the mantissa).
A = A * 2 again (Transferring the overflow & effect of the multiplication through to
&34, &33, &32, &31 (the rest of the mantissa).

Add ?&35, store result in &35.
Add original ?&34 [stored in X] to &34
Add original ?&33 [stored on stack] to &33
Add original ?&32 [stored on stack] to &32
Add original ?&31 [stored on stack] to &31
Multiply &35, &34, &33, &32, &31 (the FWA mantissa) by 2

This in effect does Mantissa = ((Mantissa * 2) + Mantissa) * 2
Which is: Mantissa = (Mantissa * 5) * 2 or Mantissa = Mantissa * 10.


Disassembly for the FWA Mantissa multiplied by 10 routine

A26C 1 165 049 A5 31 LDA &31
A26E J 074 4A LSR A
A26F J 074 4A LSR A
A270 J 074 4A LSR A
A271 J 074 4A LSR A
A272   032 206 162 20 CE A2 JSR &A2CE
A275   169 240 A9 F0 LDA#&F0
A277 1 020 049 14 31 TRB &31
A279 H 072 48 PHA
A27A 4 166 052 A6 34 LDX &34
A27C 1 165 049 A5 31 LDA &31
A27E H 072 48 PHA
A27F 2 165 050 A5 32 LDA &32
A281 H 072 48 PHA
A282 3 165 051 A5 33 LDA &33
A284 H 072 48 PHA
A285 5 165 053 A5 35 LDA &35
A287   010 0A ASL A
A288 &4 038 052 26 34 ROL &34
A28A &3 038 051 26 33 ROL &33
A28C &2 038 050 26 32 ROL &32
A28E &1 038 049 26 31 ROL &31
A290   010 0A ASL A
A291 &4 038 052 26 34 ROL &34
A293 &3 038 051 26 33 ROL &33
A295 &2 038 050 26 32 ROL &32
A297 &1 038 049 26 31 ROL &31
A299 e5 101 053 65 35 ADC &35
A29B 5 133 053 85 35 STA &35
A29D   138 8A TXA
A29E e4 101 052 65 34 ADC &34
A2A0 4 133 052 85 34 STA &34
A2A2 h 104 68 PLA
A2A3 e3 101 051 65 33 ADC &33
A2A5 3 133 051 85 33 STA &33
A2A7 h 104 68 PLA
A2A8 e2 101 050 65 32 ADC &32
A2AA 2 133 050 85 32 STA &32
A2AC h 104 68 PLA
A2AD e1 101 049 65 31 ADC &31
A2AF 5 006 053 06 35 ASL &35
A2B1 &4 038 052 26 34 ROL &34
A2B3 &3 038 051 26 33 ROL &33
A2B5 &2 038 050 26 32 ROL &32
A2B7 * 042 2A ROL A
A2B8 1 133 049 85 31 STA &31
A2BA h 104 68 PLA
A2BB ` 096 60 RTS

 


 Back to 8BS
Or