Multiplication registers

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Multiplication registers

Post by Oziphantom »

Do the 420X registers only latch on the B param?
So if you set 4202 before 4203, it does not interfere with any ongoing multiplication?

Code: Select all

00/85B7 E2 10       mull_16_16_32result              sep #$10 ;x,y 8 bit
00/85B9 A4 00                                        ldy j7E0000 
00/85BB 8C 02 42                                     sty MultiplecandA 
00/85BE A4 02                                        ldy a7E0002 
00/85C0 8C 03 42                                     sty MultiplierB ;0*2  <start multiply
00/85C3 A4 01                                        ldy p7E0001 
00/85C5 8C 02 42                                     sty MultiplecandA  < modifies before 7 clocks??
00/85C8 A4 03                                        ldy p7E0003 
00/85CA AD 16 42                                     lda ProdRemainLo  < reads result
00/85CD 8C 03 42                                     sty MultiplierB ;1*3 < does this then latch both A and B and start the multiplication? 
00/85D0 85 04                                        sta p7E0004 ;result 0*2
00/85D2 A4 02                                        ldy a7E0002 
00/85D4 EA                                           nop  
00/85D5 AD 16 42                                     lda ProdRemainLo 
00/85D8 8C 03 42                                     sty MultiplierB ;1*2
00/85DB 85 06                                        sta p7E0006 ;result 1*3
00/85DD A6 07                                        ldx p7E0007 
00/85DF A5 05                                        lda p7E0005 
00/85E1 18                                           clc  
00/85E2 6D 16 42                                     adc ProdRemainLo 
00/85E5 85 05                                        sta p7E0005 ;5 += 1*2
00/85E7 90 01                                        bcc b0085EA 
00/85E9 E8                                           inx  
00/85EA A4 00       b0085EA                          ldy j7E0000 
00/85EC 8C 02 42                                     sty MultiplecandA 
00/85EF A4 03                                        ldy p7E0003 
00/85F1 8C 03 42                                     sty MultiplierB ;1*3
00/85F4 EA                                           nop  
00/85F5 A5 05                                        lda p7E0005 
00/85F7 18                                           clc  
00/85F8 6D 16 42                                     adc ProdRemainLo ;5+=1*3
00/85FB 85 05                                        sta p7E0005 
00/85FD 90 01                                        bcc b008600 
00/85FF E8                                           inx  
00/8600 86 07       b008600                          stx p7E0007 
00/8602 C2 10                                        rep #$10 ;x,y 16 bit
00/8604 60                                           rts  
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Multiplication registers

Post by koitsu »

Correct -- the multiplication process will start once a write to $4203 (multiplier MMIO register) happens. Multiplicand ($4202) can be changed while there's an existing multiplication operation happening ("A-REGISTER" means "MULTIPLICAND - A" = $4202).

While here: for division registers, the process will begin once a write to $4206 (divisor MMIO register) happens.

Attaching documentation confirming both statements; see bullet items for all of this, including for how many CPU cycles you must wait for a result.

(2018/08/29 Edit: attachments removed.)
Post Reply