5 ms·
Alas, educational architectures like the Brookshear Machine and Little Computer look nothing like real ones, making them worse than useless: in my experience st
by saithound 2y ago
Alas, educational architectures like the Brookshear Machine and Little Computer look nothing like real ones, making them worse than useless: in my experience students who take courses using these often end up with a more distorted understanding of computers than those who take no classes at all.
Most people who want to learn a bit about how their machines work would be better served by taking an operating systems course. Same goes here: if you only have time for a short tutorial, I recommend "Writing my own bootloader" instead. [1]
(This is not meant to say that the Write your own VM tutorial is a bad tutorial; only that, in my experience, most people who'd do it would be best served by a different subject)
[1] https://dev.to/frosnerd/writing-my-own-boot-loader-3mld https://dev.to/frosnerd/writing-my-own-boot-loader-3mld
- markus_zhang 2y agoI just did the LC-3 one and look forward to learning a bit about dynamic recompilation using LC-3 as an (inappropriate) target machine in the current project. Can you please elaborate why it is bad to use LC-3 for studying computer architecture? I do understand it is completely different from real hardware, and too simplified. But from the perspective of writing CPU emulators, is it bad for me?
- saithound 2y agoI answered a similar question by anyfoo downthread, the point about implementing a PIT should explain what I mean, and why I think that emulating a simple real architecture might be more useful while requiring similar effort.
- c0wb0yc0d3r 2y agoLink in case the order changes. https://news.ycombinator.com/item?id=42519788 https://news.ycombinator.com/item?id=42519788
- anyfoo 2y agoAgain, you are coming at this from a software engineering direction, not a computer architecture/engineering one.
- saithound 2y agoSince I have the exact same thought (that you are coming at this from a software engineering direction, not a computer architecture/engineering one), this is unlikely to be further productive :( You say you want students to be able to write emulators/simulators etc. (you list a bunch of software.engineering tasks). I say writing an LC-3 emulator won't give you any transferable skills for writing, say, a Gameboy Emulator (still a 30yo system), because these educational arhitectures are bad and abstract away precisely the things that you have to get right to do that, leaving you with something trivial to implement: a C array for "memory" and a few bitwise operations. Since we're largely looking at the same things and coming to orthogonal conclusions, I suggest we agree to disagree on this one.
- liontwist 2y agoThis article would directly apply to NES or game boy emulation. Yes, there are fewer instructions.
- anyfoo 2y agoWhen studying computer architecture, I think the implementation details of a real architecture, even a simple one, might actually slow you down if your goal is to learn about dynamic recompilation. The commenter you replied to seems to be coming from a software engineering perspective, i.e. learning how to program a computer (which someone interested in computer architecture probably knows about already).
- deleted 2y ago[deleted]
- userbinator 2y agoMy recommendation is to use an old 8-bit architecture like 6502 or Z80. Apparently a lot of CS courses in India still use the 8086/8088 too.
- markus_zhang 2y agoBack in China my first comp arch class used 8051, it was fun. I remember everyone getting a development board and playing with assembly.
- userbinator 2y ago8051-core SoCs seem to be found in tons of cheap Chinese electronics. MP3 players, toys, SD card/USB drive controllers, touchscreen drivers etc.
- kragen 2y agoYeah, the 8051 family is still pretty popular, unlike, for example, the 68HC11/08/12 etc.. I think it's not as popular as the PIC, ARM, AVR, or even MSP430, but it seems to be more popular than STM8, M16C, SH-4, MAXQ, MIPS, or 8086. I'm not sure how to assess the Z80 (8080 variant), Z8, RL78, and RX families, all of which seem to be showing disturbing signs of life. Fortunately the 8048 seems to be dead.
- userbinator 2y agoI think it's not as popular as the PIC, ARM, AVR, or even MSP430 Far more 8051 cores are shipped than all of those combined, excluding ARM.
- kragen 2y agoEven today? That's plausible, but I'd like to know what leads you to believe it. I was mostly looking at Digi-Key stock numbers, which are at best a very imperfect measure.
- 2y ago
- PaulHoule 2y agoI think of Knuth's old MIX which was a decimal machine which might have gotten built in the 1960s but which nobody has built since the 1970s. A system like that can teach you many fundamentals but not the tricks here https://en.wikipedia.org/wiki/Hacker%27s_Delight https://en.wikipedia.org/wiki/Hacker%27s_Delight which mainly depend on conventional numeric representations.
- kragen 2y agoMIX wasn't decimal, but rather abstract over the choice of base, a decision Knuth changed in later volumes of the series, even before switching to MMIX. There have been decimal and hybrid computers built since the 01970s (especially for pocket calculators, but new decimal instructions were still being added to Intel's lineup in the 8086 with AAM and AAD, and I think decimal continued to be a consideration for the AS/400 into the 90s), but MIX is really kind of an 01950s design, with: - word-addressed memory - five bytes per word (plus a sign bit) - one word per instruction - six bits per byte (in binary realizations) - possible decimal - a single accumulator - sign-magnitude - no stack, and - a nonrecursive subroutine call convention relying on self-modifying code. You can find one or another of these characteristics in machines designed since 01960, but the combination looked old-fashioned already when it was introduced.
- anyfoo 2y agoCan you elaborate what you don’t like about this one, LC-3, in particular? I’m not familiar with it, but just had a look at it on Wikipedia. After your comic, I was expecting something weird, but upon a quick glance, it doesn’t seem too jarring. A bit like a mixture of s/360, some x86, and a tiny bit of ARM (or other RISCy architectures). With lots of omissions and some weirdness of course, but the goal seems to be to quickly come to a working implementation. I’m curious what exactly you think makes it “worse than useless” for teaching.
- saithound 2y agoI'm not talking about the instruction set, or teaching basic assembly (probably anything except Malbolge is suitable for that). Let's look at just one thing every programmer has to deal with, memory. On an LC-3, the address space is exactly 64KiB. There is no concept of missing memory, all addresses are assumed to exist, no memory detection is needed or possible, and memory mapped IO uses fixed addresses. There are no memory management capabilities on the LC-3, no MMU, no paging, no segmentation. In turn there are no memory-related exceptions, page faults or protection faults. When an x86 machine boots with 1MB of RAM, the 4GB address space still exists in full, but accessing certain addresses will cause bus timeouts, crashes. One must track and manage available memory. There's a BIOS, and manually probing memory locations may trash its critical structures. There's INT 0x15. I picked memory arbitrarily but you run into the same limitations no matter what you pick. Would a students who was educated on LC-3 know how a computer keeps time? Of course not, there's no PIT, there's no CMOS clock. Would they have thought about caches? Nope. Oh, but wouldn't a student who implements a timer emulation extension for LC-3 learn more about timers than somebody who just learned to use an x86 PIT? Alas, no. There are 20 equally easy and reasonable mathematical ways to implement a timer abstraction. A good 15 of these are physically impossible on real hardware, out of the remaining 5 two would be prohibiitively expensive due to electrical engineering reasons, one has never been implemented in real hardware due to historical accidents, and two are designs that are actually in use. So to write timer emulation that teaches you anything at all about how actual timers work, you'll have to look at and understand a real architecture anyway. That's why educational architectures are so contraproductive. They abstract away exactly the things that make modern computers modern computers. One comes away with fundamentally wrong ideas about what computers do and how they actually work, or could work. It's like learning to drive in GTA: in principle, there could be plenty of skills that transfer to the real thing, but in practice you'll prefer to teach how to drive to the person who didn't play GTA at all.
- hayley-patton 2y agoThe LC-3 has pretty odd addressing modes - in particular, you can do a doubly indirect load through a PC-relative word in the middle. But you still have to generate subtraction from negation, and negation from NOT and ADD ,,#-1. (I suppose NOT d,s = XOR d,s,#-1 would be a better use of the limited instruction encoding space too.)