7 ms·
> There are only two common reasons to learn Z80 assembler, though: to program the Gameboy [...] and to program a TI calculator What about the myriad of other
by muterad_murilax 10y ago
> There are only two common reasons to learn Z80 assembler, though: to program the Gameboy [...] and to program a TI calculator
What about the myriad of other (mostly vintage) computer systems and video game consoles out there? ;)
Sega Master System and Game Gear, for example.
- qwertyuiop924 10y agoThey're not as common reasons. But yes, if you want to program your TRS-80 (but only the original: later ones were 6502), or your ZX* (How many of you lot know the ZX line? Spectrum? No?), or your Game Gear, or your Master System, or any of the various CP/M machines, you have to learn Z80.
- userbinator 10y agoHow many of you lot know the ZX line? Spectrum? No? The ZX Spectrum and its clones were very popular in the UK, Eastern Europe, and the former USSR.
- qwertyuiop924 10y agoYeah. AFAICT, most of HN (myself included) is US based. So I was curious.
- pjmlp 10y agoThey also ruled in Portugal and Spain. Almost no C64 in sight beyond a few computer magazines.
- mangamadaiyan 10y ago... and for a brief period of time in the late '80s, "popular" in India as well. (I quoted popular because they were bloody expensive. In 7th grade, a kid in my class had one. He was the only one in all of the school to have a computer.).
- qwertyuiop924 10y agoHuh. The Spectrum was popular elswhere because it was so comically cheap.
- mangamadaiyan 10y agoRelatively speaking. It was definitely much cheaper than a PC Clone with an 80286 processor, but expensive enough to be a luxury, I think.
- david-given 10y agoThe Game Boy doesn't quite use a Z80 --- like the Z80 it's based on the 8080, but in a different way. So you don't get things like the IX and IY or the alternate register banks, but you do get things like (a very crude set of) stack-relative addressing modes, which makes it a better fit for modern programming languages than the Z80. http://gbdev.gg8.se/wiki/articles/CPU_Comparision_with_Z80 http://gbdev.gg8.se/wiki/articles/CPU_Comparision_with_Z80 As an aside: most of the old, classic 8-bit micros are complete pains to write modern code for, because modern programming languages all assume fast stacks. The Z80 has no stack-relative addressing, which means you need to reserve a precious index register as a frame pointer at the top of every function, and then indirect off that --- but the Z80 designers didn't realise that people would want to do it so often and as a result it's verbose, deal slow, and doesn't handle 16-bit values. So you need to do: ld h, [iy+8] ld l, [iy+9] ...for a total of 8 bytes of code and lots of cycles. The Game Boy processor (which doesn't have a snappy name) allows this: ld hl, sp+8 ldi a, [hl] // load and increment ld l, [hl] mov a, h ...which is (IIRC) five bytes. Still not great, but shorter, and also loads faster. If you look at the instruction encodings, the Z80's actually a pile of nasty hacks. The original 8080 is way more elegant; and there's lots of software and tooling for it, too. (But it still can't run C efficiently.)
- qwertyuiop924 10y agoAs I understood it, the GB is based on the Z80, not the 8080: That's why its nickname is the GBZ80. >If you look at the instruction encodings, the Z80's actually a pile of nasty hacks. The original 8080 is way more elegant; and there's lots of software and tooling for it, too. (But it still can't run C efficiently.) I don't know about what makes an instruction encoding elegant or inelegant, so can't help you there. Yes, the 8080 is probably more elegant, but the extra features on the Z80 are incredibly useful (especially register exchange: The Z80 had two sets of registers, which you can exchange. No, Zachtronics didn't make that up: that was a real thing, on the Z80 at least). Also, the Z80 tooling is quite nice: asxxxx and WLA-DX are fine assemblers, and SDCC is a pretty good C compiler. It sure as heck beats cc65, in any case.