'Divide by A' procedure in 90x0 ROM

From: Baltissen, GJPAA (Ruud) <ruud.baltissen_at_apg.nl>
Date: Fri, 18 Feb 2011 14:13:37 +0100
Message-ID: <B33CBAA5B1C897429CEE13DB2F3590D034FF8B@winsv284.office01.internalcorp.net>
Hallo allemaal,
 
 
Can you have a look at this, please:
 
;**  Divide by 6
DivideBy6    ;    $D333
  lda #$06

;**  Divide Result+2/Result+1/Result by value in A
; in: A = divider
; Result+2 MSB
; Result+1
; Result  LSB
; out: Result+2 MSB
; Result+1
; Result  LSB
; Accumulator+1 MSB
; Accumulator LSB
DivideByA    ;    $D335
  sta Temp0
 
  lda #$00
  sta Accumulator
  sta Accumulator+1
 
  ldx #$18
A_D33F
  asl Result
  rol Result+1
  rol Result+2
  rol Accumulator
  rol Accumulator+1
 
  lda Accumulator
  sec
  sbc Temp0
  tay
 
  lda Accumulator+1
  sbc #$00
  bcc A_D35B
 
  inc Result
 
  sta Accumulator+1
  sty Accumulator
A_D35B
  dex
  bne A_D33F
 
  rts


I know it works, I even wrote a small Pascal program to emulate the
above. I had to because I wasn't sure what was stored in which variable.

My problem: I haven't any idea how it works. I look at it but cannot
understand it. I even haven't any idea where to start! Can anybody
explain the above, please?

Many thanks in advance!


--
     ___
    / __|__
   / /  |_/     Groetjes, Ruud
   \ \__|_\
    \___|       URL: Ruud.C64.org


 
De informatie in dit e-mailbericht is vertrouwelijk en uitsluitend bestemd voor de 
geadresseerde. Wanneer u dit bericht per abuis ontvangt, verzoeken wij u contact op te 
nemen met de afzender per kerende e-mail. Verder verzoeken wij u in dat geval dit 
e-mailbericht te vernietigen en de inhoud ervan aan niemand openbaar te maken. 
Wij aanvaarden geen aansprakelijkheid voor onjuiste, onvolledige dan wel ontijdige 
overbrenging van de inhoud van een verzonden e-mailbericht, noch voor daarbij 
overgebrachte virussen.

APG Algemene Pensioen Groep NV is gevestigd te Heerlen en is ingeschreven in het 
handelsregister van de Kamer van Koophandel Limburg onder nummer 14099617


The information contained in this e-mail is confidential and may be privileged. 
It may be read, copied and used only by the intended recipient. 
If you have received it in error, please contact the sender immediately by 
return e-mail; please delete in this case the e-mail and do not disclose it's 
contents to any person. We don't accept liability for any errors, omissions, 
delays of receipt or viruses in the contents of this message which arise as a 
result of e-mail transmission.

APG Algemene Pensioen Groep NV is registered in the trade register of the Chamber 
of Commerce Limburg, The Netherlands, registration number: 14099617


       Message was sent through the cbm-hackers mailing list
Received on 2011-02-18 14:00:05

Archive generated by hypermail 2.2.0.