5 ms·
TIL that a 6502 didn’t have division and remainder instructions. Yikes.
by vogon_laureate 3y ago
TIL that a 6502 didn’t have division and remainder instructions. Yikes.
- 082349872349872 3y agoI learned a lot from Chuck Moore's designs; for instance he assumes that you know how to build multiply given a multiplication step instruction, or the full set of logic ops given just and and xor. (which comes on top of the traditional forth punning of logical and bitwise booleans) > Before I studied the art, a binding was just a binding. After I learned the art, an assignment was an assignment but an application was an application. Now that I've understood the art, a binding is just a binding.
- flohofwoe 3y agoNone of the 8-bit CPUs had that, but you can get pretty far with left- and right-shift (which is the same as multiplication and division by 2), which allows to compose multiplication and division by constants quite easily (it's a bit more trouble and usually too slow for a universal runtime mul/div, but one simply tried to avoid that, or use precomputed lookup-tables instead).
- zabzonk 3y agonot division, but the 6809 8-bit processor did have a MUL(tiply) instruction.
- flohofwoe 3y agoI stand corrected and TIL :) That's pretty awesome actually, pity that the 6809 wasn't more popular in the home computer era (but looking at the price compared to the Z80 or even 6502 it's understandable - $37 versus $9 for Z80 and $6 for the 6502 in 1980 according to Wikipedia: https://en.wikipedia.org/wiki/Motorola_6809 https://en.wikipedia.org/wiki/Motorola_6809).
- zabzonk 3y agoi wasn't aware of the price difference, and at the time i owned a 6809-based system - a dragon32 (a sort of UK re-branded version of the tandy colco). i wasn't fussed about the MUL instruction, but i simply loved all of the addressing modes that thing had.
- dboreham 3y agoI worked in embedded systems design through this era. I don't remember ever hearing of a design using one 8-bit cpu vs another due to chip cost. Those Wikipedia numbers also seem suspect.
- paulsutter 3y agoZero page addressing was far more inconvenient than calling a library for division on the 6502 16 bit addresses didn’t fit into registers, so you keep pointers in the zero page (bytes 0-255). There was no 16 bit increment either, so to increment the pointer you incremented the low byte and on overflow increment the high byte
- IshKebab 3y agoThere are still modern CPUs that don't. Division/remainder is much much harder than all the other basic arithmetic operations.
- PhilipRoman 3y agoIt is quite rare to need an actual division instruction; for the majority of cases you would simply precompute the modular inverse and use that with multiplication. Non-constant modulo can often be computed by checking for roll-over when incrementing (or just computed in a similar way to division)
- TillE 3y agoGame consoles like the SNES (65816) had a coprocessor for multiplication, division, etc. You load the values into a certain address, wait a couple cycles, and retrieve the result. Not pretty, but those CPUs were designed to be really cheap.