News for hackers. Stuff that matters.
Re:Multiplying and Dividing on the 6502 (2021) by kevin_thibedeau on Tuesday June 28, 2022 @04:02PM (#31912313)
Hardware mul/div is still not universal on new products.
Re:Multiplying and Dividing on the 6502 (2021) by cbm-vic-20 on Tuesday June 28, 2022 @04:48PM (#31912827)
RISC-V doesn't have hardware mul/div in it's baseline spec. There's a "Zmmul" extension that adds mul, and the full "M" extension which includes mul/div. Technically, those extensions are optional, but I think most current hardware implementations include them.
Re:Multiplying and Dividing on the 6502 (2021) by kjs3 on Tuesday June 28, 2022 @05:24PM (#31913209)
That's...very weird I guess? Hardware mul/div requires so little chip real-estate relative to the whole die these days, and has such obvious advantage, why did they make it optional?
Re:Multiplying and Dividing on the 6502 (2021) by shadowofneptune on Tuesday June 28, 2022 @08:18PM (#31914865)
The point of the baseline spec, as far as I know, is to make a modern chip design that even the smallest fab or ASIC can build on its own.
Re:Multiplying and Dividing on the 6502 (2021) by spc476 on Tuesday June 28, 2022 @08:25PM (#31914928)
I wrote almost nothing but assembly for ten years (mid 80s to mid 90s) and I think I can count on one hand the number of times I actually needed a generalized multiplication/division instruction. Heck, even square root could be done with repeated subtraction which could be Good Enough(TM), or maybe a lookup table.
Re:Multiplying and Dividing on the 6502 (2021) by kragen on Tuesday June 28, 2022 @08:32PM (#31914993)
The SeRV implementation of RISC-V fits into 200 4-LUTs on an ICE40 FPGA. If your FPGA doesn't have a multiplier, how many 4-LUTs do you need to build a 32x32 multiplier? I'm guessing the answer is comparable to 200.
Re:Multiplying and Dividing on the 6502 (2021) by kjs3 on Tuesday June 28, 2022 @11:35PM (#31916180)
Ah, you're right. I'm thinking in terms of transistors, not LUTs.
Re:Multiplying and Dividing on the 6502 (2021) by kragen on Wednesday June 29, 2022 @12:33AM (#31916540)
I think the case is even stronger if you're counting in transistors, because FPGAs usually come with multipliers built in, but bare silicon wafers don't. A CPU such as a 6502 or an Intersil 6100 (a PDP-8 on a chip) costs on the order of 4000 transistors. I suspect SeRV would be about the same size, maybe a bit smaller. How many transistors do you need for a 32-bit multiplier?
Re:Multiplying and Dividing on the 6502 (2021) by sophacles on Tuesday June 28, 2022 @05:25PM (#31913217)
IIUC this is because:

* mul/div take a lot of transistors and may not be a single or fixed cycle instruction.

* A lot of embedded systems don't really need those instructions anyway - they just encode discrete state machines or do something like networking that doesn't need * or / for operation.

* less transistors means the chips are cheaper, and single (or fixed) cycles per instruction means hard real-time is simpler to reason about.

Is that correct?