Commodore64et6510

Multiplication with repeated additions

Jun 14th, 2025
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. *=$C000
  2. ; 120 x 100 = 12000(d) = $2EE0(h)
  3. ; Register X will hold multiplier
  4. ; Accumulator will hold multplicand
  5. ; HB of the Result in Accumulator
  6. ; LB of the Result in Register X
  7.  
  8. MULTPLICAND = $FC
  9. RESULT_HB = $FB
  10. ; 0 is assumed at $FB and $FC
  11.  
  12. LDX #100 ; X=MPR
  13. LDA #120 ; Acc=MPCND
  14. STA MULTPLICAND
  15. LDA #00
  16. LOOP
  17. DEX
  18. BMI STOP
  19. CLC
  20. ADC MULTPLICAND
  21. BCC LOOP
  22. INC RESULT_HB ; INY if Y register used instead
  23. JMP LOOP
  24. STOP
  25. TAX
  26. LDA RESULT_HB ; TYA if Y register used instead
  27.  
Advertisement
Add Comment
Please, Sign In to add comment