3 ms·
The trouble with the old architectures like the 6502 and the Z80 is that they were designed before stack-frame languages like C became popular --- which means t
by david-given 11y ago
The trouble with the old architectures like the 6502 and the Z80 is that they were designed before stack-frame languages like C became popular --- which means they don't have any stack-relative addressing modes, which means that accessing stack frames is horribly expensive.
e.g. on the Z80 most compilers have to keep a copy of the stack pointer in an index register, so that they can address the stack; and even then the absence of 16-bit accesses means that you need eight bytes of code and like a billion cycles to read or write a single 16-bit value. (I do know that the Z80 variant in the Game Boy added a ld hl, (sp+offset) instruction, which helps; shame they didn't add a ld (sp+offset), hl instruction...)
The 6502 is even worse; the stack's limited to 256 bytes and isn't relocatable, let alone addressable. The C compilers I've seen maintain their own stack pointer in zero page. They also generate code which at best is terrible and at worst makes you want to claw your own eyes out to make the pain stop.
So:
(a) I'm curious to know what they wrote the Tamagotchi firmware in --- raw machine code? Forth? C? Fortran? (Fortran's actually a good match for these architectures because all variables, including function parameters, are global --- no stack frames required.)
(b) why was it cheaper to use a 6502 core rather than a more modern architecture --- PIC, AVR, MSP430? Licensing? An in-house team of 6502 experts?
- nickpsecurity 11y agoThat product was made in 1996. Up to then, quite a few gaming devices already used them. Commodore was going bankrupt but company taking over still sold tons of them. So, it was a decent chip, probably cheaper than usual, and might have hired game developers with prior experience in it. All speculation based on business details at the time. I'd also like to know if it was cheaper or there was a talent advantage in mid-90's.