Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As a teenager I took an intro CS class at a community college, and the instructor had us design a simple cpu instruction set, and write our own VM and assembler that worked and let me write and run assembly programs. It was shockingly easy, and it was amazing how much is demystified computers for me.

I feel like one could learn every level of computing this way- from designing a real cpu for a FPGA, to writing a simple OS and programs that run on it. This stuff is all shockingly simple if you just want it to work and don’t need all of the extra performance and security modern computing needs.



That sounds like a fun class! It sounds very similar to https://www.nand2tetris.org/ or Charles Petzold's book "Code".




I think once you move from early fantasy CPUs to early CPUs in production such as 80286, the complexity immediately moves up drastically. IIRC it involves at least memory segmentation, protected mode (MMU).


True enough, but having designed a “fantasy cpu” gives you a better frame of reference for understanding the more complex features of a cpu (privilege levels, memory segmentation, virtual addresses, cache hierarchy, etc.)

I often feel like those who haven’t done the exercise of understanding the ISA of a “fantasy cpu” have a really hard time understanding those more advanced features.

I guess all I am saying is that learning the “fantasy cpu” still has value even if everything else in the real world is more complex.

Walking before running and all that.


I've been doing some planning for a 24-bit fantasy CPU, my plan is to make it pretty baroque. For instance it has some instructions to do things like unpack UTF-8 strings into chars, do alpha compositing, etc. The CPU part looks like a strange mainframe that didn't quite get built into the 1970s and it is coupled to a video system that would make a Neo-Geo blush.


“Neo Geo[a] is a brand of video game hardware developed by SNK.

It was launched with the Neo Geo, an arcade system (called MVS) with a home console counterpart (AES). Games on the Neo Geo (MVS and AES) were well received and it spawned several long-running and critically acclaimed series, mostly 2D fighters. Later, SNK released the Neo Geo CD, a more cost-effective console with games released on compact discs, which was met with limited success. A new arcade system, Hyper Neo Geo 64, was released in 1997, but it did not fare well. SNK also released a handheld console under the brand, the Neo Geo Pocket, which was quickly succeeded by the Neo Geo Pocket Color, which have been given praise despite its short lifetime.

SNK encountered various legal and financial issues resulting in a sale of the company in 2001. Despite that, the original Neo Geo arcade and console continued receiving new games under new ownership until 2004. The Neo Geo brand was revived in 2012 with the release of the Neo Geo X[1] handheld. Since then, a number of other Neo Geo products have been released based on the original Neo Geo.”

— Wikipedia

Seems to be from about 30 years ago in the 1990s.


I just realized that people like me that know all about the Neo Geo are actually in the minority in the world. It's easy to forget what is and isn't common knowledge.


Neo Geo was unforgettable. Anyone who could afford one was a legend.


Yeah, I heard it was very expensive that a joke said that "only kids with divorced parents get one".


That's amazing. I'm a fan of the Beat-them-up games the Neo Geo brought from the arcade. Do you have any write-ups?


Forget advanced features... Without understanding a CPU it's easy to never really understand pointers, and without pointers, it's hard to understand lots of data structures.

I was easily 12 months ahead of other students in my CS education because I learned 6502 assembly in high school. I wish all CS courses started with "make a VM".


I don’t get this take. Is it so hard to understand that a computer operates on a giant array of bytes?

I think the hard thing to understand is that C’s pointer syntax is backwards (usage follows declaration is weird).

I also think understanding how arrays silently decay to pointers and how pointer arithmetic works in C is hard: ptr+1 is not address+1, but address+sizeof(*ptr)!

Pointers are not hard. C is just confusing, but happens to be the lingua franca for “high level” assembly.


> Is it so hard to understand that a computer operates on a giant array of bytes?

Beginner programming languages universally (since BASIC and Pascal) were designed to hide this fact. There's nothing in a beginning Python course that explains the true nature of computers. You learn about syntax, semantics, namespaces, data structures and libraries. But there's nothing that says, "a computer is endlessly incrementing a counter and executing what it finds where the counter points". And this is probably partly because of "go-to considered harmful", which posited that a lack of control flow (which is a fundamental fact of how computers actually work) is harmful to reasoning about programs.

It's probably objectively true. But a lack of go-to also restricts people from seeing the fundamental truth of the indistinguishable nature of data and instructions in the Von Neumann architecture. Which may also make it difficult to explain GPU computing to students (because it must be understood by contrasting it with Von Neumann architecture).


This is very true. I had tried learning C multiple times but pointers were always kind of hard. I kind of understood them but not really. I later spent a lot of time making an OS in assembly for my homebrew 6502 computer, and after that pointers made so much sense. It actually took me a little while to realize that these addresses I was passing around were pointers, and I had started to understand them without realizing it.


agreed! A fantasy CPU is good for the first project.


80286 is the PHP of CPUs.

A wonderfully different early CPU with plenty of existing software is the https://en.wikipedia.org/wiki/RCA_1802 which was a target of the https://en.wikipedia.org/wiki/CHIP-8 interpreter.


Or you could pick the 68000 which is easier to emulate than a 286 because it was 'properly designed' (and not a stopgap solution like the x86 line until the 386 arrived).


the 80286 has its own problems/inessential complexity

if you look at this from the riscv angle, moving from "u-mode only vm that doesn't use paging under the hood" to "u+s-mode vm with sv39" isn't an enormous jump in complexity imo

i think i might teach it starting as like, "sv21" (page tables aren't nested), then pose real sv39 and the tree structure as the solution to making a sparse mapping over 512GiB

then moving on to the idea of having a TLB is simple, especially if students have already been introduced to hashtables


Sometimes I dream of a 24-bit generation of computers (in terms of address space and the space of index math) of which

https://en.wikipedia.org/wiki/Zilog_eZ80

may be the best realization. You can almost run a real operating system on that chip in the sense of a 24 bit supervisor that could run multiple 16 bit processes (if you could get CP/M to run you have one heck of a userspace) Unfortunately you can't trap the instruction that switches back to 24 bit mode.

Would be nice too if a 24 bit supervisor could contain a 24 bit application, that requires some kind of memory management and I'd imagine something a little lighter weight than the usual paging system, say something that maps (0..N) in logical space to (i+0..i+N) in physical address space. I like the "access register" concept

https://en.wikipedia.org/wiki/Access_register

but would probably have a small number of memory banks such as 16 or 64. In a load-store architecture it doesn't seem like much of a burden to add a bank id to stores and loads. In return you get not just more RAM but also separation of code and data, video memory, file mmap(ing) and such.

What bugs me is how to control the mapping of memory banks to physical memory, on one hand you want the supervisor in charge so it can be used for memory protection, on the other hand some programming techniques would want the speed of changing the memory banks from user space.

The 80286 was a turkey because it didn't meet the minimal viable product level of being a target for a 24-bit OS that could virtualize DOS applications. It was already crazy fast and became affordable pretty quickly but it seemed tragic that it couldn't do that.


> The 80286 was a turkey because it didn't meet the minimal viable product level of being a target for a 24-bit OS that could virtualize DOS applications. It was already crazy fast and became affordable pretty quickly but it seemed tragic that it couldn't do that.

That's mainly because it was designed before the IBM PC was a success and backwards compatibility with DOS applications important.


I took a different approach by just making an FPGA-based multi-core Z80 setup. One core is dedicated to running 'supervisor' CP/NET server, and all of the applications run on CP/NET clients and can run normal CP/M software. I built a 16-core version of this, and each CPU gets its own dedicated 'terminal' window, with all of the windowing handled by the display hardware (and ultimately controlled by the supervisor CPU). It's a fun 'what-if' architecture that works way better than one might expect in practice. It would have made an amazing mid-to-late 1980s machine.


Even better than that was an Z280 which did have a proper user/supervisor mode and simple MMU. Really reminiscent of a PDP-11 in terms of supervisor state, just strapped to a z80 instruction set otherwise. Also added a nice SP relative load to the instruction set.


Also PIC24 family of μcontrollers.


The mostly redundant memory segmentation features that modern OS do not care or use anymore.

If OS fully utilizes memory segmentation it can be the most secure OS and makes borrow checker languages like Rust becomes unnecessary since not unlike Rust it can mitigates data races and race conditions (better at the latter).

This can considerably reduce developers' cognitive load or overload [1]. It also can contribute towards more secure computing and containers can be made as secure as VMs.

Someone can probably propose a new memory segmentation extension to the Linux kernel in the similar manner of real-time Linux. But again it can takes 20 years to be accepted into the mainline Linux kernel [2].

[1] Cognitive load is what matters:

https://news.ycombinator.com/item?id=42489645

[2] 20 years later, real-time Linux makes it to the kernel:

https://news.ycombinator.com/item?id=41584907


There are plenty of real CPUs that are useful in the real world but are much simpler than a 286.... 8 bit RISC microcontrollers like Atmel AVRs for example. I've done a small amount of programming for those in assembly, and they are not a whole lot more complex than the 'toy' design I used for the class.


Our CS 101 class had such a system. Simple computer/assembler written in BASIC on the PDP.

One of the assignments was to do a simple multiply (i.e. add in a loop).

Rather than do that, my friend simply altered the program and created a new MUL command.

The teacher was not amused.


Teachers don't want extra work.

My first 360 assembler class our first assignment: add two numbers, fault, print the crashdump and circle the answer to the ADD in the printout.

I wrote an RPN calculator, had it do a series of calculations and print the result. Turned that in.

The teacher wrote on it "You have 24 hours to turn in the required assignment"


I was a professor. I would have given you a zero.

From the instructor's perspective, it sounds like you didn't even try to do the intentional assignment (which the fault/crashdump/find info in the crashdump was the most important part), and either did your own thing or sent in someone else's assignment because you didn't look closely enough at what it was. Yes, this is a big accusation, but it happens every semester.

The professor just wanted you to learn what you were supposed to from the assignment, so that you could build off it.

Your cynical take on it now shows that you still don't understand how to teach or the importance of that fundamental skill.

Is there a place for fun, exploratory projects? Of course, and I always incorporated them into my syllabus. But there's also a place for structure. If you want to explore along the way, then that is even better! But you still have to meet the incremental checkpoints along the way, otherwise you have not demonstrated that you have met the core competencies of the subject, as reflected by your grade.

There's a lot of shortcomings in modern university education, but I loved teaching, and would still be doing it today if it paid reasonably. My biggest headaches were the cheaters and the know-it-alls, mostly because neither of them knew enough to respect the subject matter and its importance. The students that made me the most proud, though, were those that trusted the roadmap, and in the end were able to do bigger and better things than they thought that they were capable of.

It's not about extra work. We did plenty of it, btw. We just didn't always tell you about it. The University system referrs to it as "service", and you, the student, are the beneficiary of it, either directly or indirectly.

"Teachers don't want extra work." I'm sorry, but this sounds like a toddler stomping their foot and saying "Mommy and Daddy don't love me because they went to work today instead of staying home to play with me."

I'm glad that you wrote the RPN calculator. That's cool! I'm disappointed that you use this as an opportunity to bash the educator who agreed to take a low salary so that they could help you learn important things that are fundamental to your craft and chosen field of study.


It is very sad that you kind of people exist as professor. Yes he is wrong. But you can appreciate that and knowing effectively he is cursing you about your assignment. Take it open mind. Call him in. Explain your view. And if he cannot do it, fail him. But if he can. Move on.

IT need innovation. As you are not just building systems or maintaining one, you need to people think beyond what is assigned. As most likely it is this innovation drive us.

Not rule followers. Obviously we need those as well. But a few rule breaker does not kill you.

Unless he goes all the way to say to the whole class not to be rule followers. That is revolution. ... I may still with him but I would understand then you fail him. But if just one ... why not accept computer or IT guys has exception. After all are we in hacker news. Do you have all those rule followers are reading these!


I didn't go into my entire syllabus, but it is sufficient to note that I did drop the lowest grade, and I only failed a few students out of hundreds, and that is a reflection of their work, not mine.

Yes, it is sad that people of my "kind" "exist as professor." I helped students start a business. I started a makerspace for them so they could explore the world of 3d printing, arduinos, etc. I guided them build projects that were worthy of showing off on their resume (which resulted in some getting jobs). I was proud of the cool things that they did, and I worked with those who had difficulty. I was just so horrible!

Actually, my students quite liked me, and I was often forgiving if a student came and talked to me... after all, that's part of their learning process. Either the student cared or they didn't. I made it clear from the beginning that I cared about them, even when I had a class of 165 in the middle of Covid.

Do you actually understand what a diploma represents? It is a certification of knowledge (binary in nature... you either have one or you don't, so it is by definition a very coarse measure). A grade (or GPA) is a one-dimensional measurement of that certification. That is what your tuition is paying for. It is paying for someone who is qualified to teach you something and then evaluate you on the standard to which everyone else from that institution is also held. It is also a ranking against their peers (which is a reason that I had no patience for cheaters, which I found some every semester). As an aside, this is why a course transferred from one institution to another will often not be included in the GPA of the later institution, because it is not the same standard.

In education, you need both structure as well as innovation. I taught both. You seem stuck on the "rule follower" and "rule breaker" mentality, but that is completely orthogonal to what I am saying. I taught mastery. Whether you follow or don't follow the rules (however you define "rules") you must still master your craft, and the university exists to certify that mastery. That is the point of the university. Certification of mastery.

If you don't want certification, then don't go to a university. You aren't required to get a degree. You can learn everything that you need to from books and other places. But if you want certification of your knowledge, then you have to actually go through the steps that verifies your knowledge and ability, as determined by other people from a variety of backgrounds who have each had their knowledge and ability certified by even more people from a variety.... you get the idea. That is what a university is.

Consider the similarity with the martial arts world. You can buy a black belt online, but do you have mastery? Someone would ask how you got it. Who considered you worthy of posessing the black belt? You might say "it doesn't matter... I can fight and win!" You might be right. But the black belt isn't about fighting. It's about self-discipline, philosophy, experience, and yes, mastery, as learned from and evaluated by someone else who has an applicable certification.

I have a Ph.D. in Computer Science from the University of Notre Dame, an R1 research university, as conferred by a panel of experts from a variety of universities (meaning faculty from other universities, not just Notre Dame itself) based on my academic achievement in the field of Computer Science, peer-reviewed conference and journal publications in the field of Computer Science, as well as my creation of a peer-reviewed, published, and publicly-defended dissertation over graph grammars (blending formal language grammars and graph theory). That is my certification. Every grade that I gave derived its credibility from that certification, and was my communication to the world of my assessment of the mastery of that student to the expectations of the university, me, and their relation to their peer group (you've heard of a grade curve, right?). That's the way it works.

You are not requrired to take part in it, but just don't treat it like sour grapes (from Aesop's Fables, it might be an obscure reference).


Well put! A thoughtful, balanced and nuanced explanation. I wish more Teachers/Professors/Seniors put forth their pov like you. The problem with "today's kids" is that because of their access to the Internet they think they "know" everything whereas without the structure given by the educational system (in spite of its shortcomings) all is mere data and they can form no proper mental model of the "entire thing". Education is holistic and tries to give one most of the knowledge and tools needed to deal with the Modern World.


I didn't bash anybody - that's words in my mouth.

I understand that it's a sensitive subject, students that stray from the boundaries of the lesson plan, so often to no good effect. Making work for an overworked teacher, I have complete sympathy.

But understand that there's also room for the teacher that doesn't stomp their own foot and petulantly demand every student stay in the herd like good little scholars.

Maybe even encourage exceptional students, maybe suggest something more appropriate for them, another class perhaps. But no, that certainly didn't happen, just the deliberate ignoring of the effort spent, because it didn't serve their tiny objective.

Just that one weary, autocratic bland statement, telegraphing as sure as a digital signal "I am the teacher, and you will not do anything I don't sanction, like learning way more than I demand for today's lesson"


I am not the person you replied to, but you are wrong about this;

> "I am the teacher, and you will not do anything I don't sanction, like learning way more than I demand for today's lesson"

The person explicitly made it clear that while you can be encouraged on your own initiatives you still need to be graded/ranked on a common scale with your peers and hence the need for some sort of standardization.

For example, in a recent HN discussion on "Software Developer Productivity" lots of folks were arguing on how you can have no common scale/metrics and so you can make no comparisons at all between developers which is plainly wrong.

Education is about giving everybody a minimum standard of knowledge/tools needed for the Modern World and that is what a Teacher/Professor focuses on. Every Society needs to revere/honour (and pay well !) their Teachers/Professors because they are the ones who build the next generation.


This was college. Not primary school. The point (which they are amply paid to perform) is to make sure you learn the necessities of the science/art/craft. They can do this any way they like I suppose.

But to resort to primary-school gold stars and points and such is possibly the very worst way, the lowest common denominator of the educator's craft.

I dare say my enthusiasm was evident. Knowledge and skill were on ample display. A better educator would have responded to that, advised more advanced study, given a different book and a different challenge.

I know; I was still naive, anticipating my college experience would be somehow different from the mass-indoctrination that had been primary and secondary school. It was my first inkling that no, that was not to be.


I think you have too many preconceptions, assumptions and misinterpretations here. My charitable interpretation of your comment would be that you have been scarred strongly by the event you describe and are generalizing from it unnecessarily. The uncharitable interpretation would be that you have an inflated sense of your own self-worth which was not validated in the above event.

When it comes to our own selves we are all necessarily biased in our own favour. Hence we need to step back and take a broader perspective so that we can be objective in our assessments. In today's society Teaching as a profession (in School/College/University) has been unfairly denigrated and become a thankless job. They are asked to operate only within a defined policy framework and not really allowed freedom to change that framework. In spite of that there are scores of stories (and even movies made) where Teachers have gone well beyond their boundaries to help students learn and perform. If you want to blame somebody blame the "System" built by policy-making idiots with no idea of human psychology, behaviour, needs etc. Teachers are really caught between a rock and a hard place i.e. policy says follow standardized curriculum/tests and don't do any creative individual things whereas students want individual recognition/attention and don't want to be called out on their lack of hardwork and application to proper studies. Hence we need to be understanding of them.


“Don’t let education get in the way of your learning” seems appropriate here.

Never underestimate how few fucks teachers give about anything beyond their small bubble.


I never let schooling get in the way of my education.

- Mark Twain.


> My first 360 assembler class our first assignment: add two numbers, fault, print the crashdump and circle the answer to the ADD in the printout.

> I wrote an RPN calculator, had it do a series of calculations and print the result. Turned that in.

The teacher wanted you to learn:

1. how to write a (very simple) assembly program for 360 to add to numbers

2. how to create a fault

3. how to print a crashdump

4. how to read a crashdump

By using a RPN calculator, you learned none of these objectives.


Not 'using'. Writing. In assembler. A full RPN calculator.

Which, by the way, required accomplishing those bullet points many times over. Obvious to anybody who's ever written anything in assembler.


Sounds like you needed to learn to follow basic instructions.


Said like a true teacher.


> This stuff is all shockingly simple

it is, but the thing is that these simple building blocks end up quite far away from an actual production level outcome that someone looking at a computer might see or interact with. It's hundreds of levels deep.

Someone with curiosity and eager to learn will be able to easily learn these foundational layers. Someone looking to "get rich quick" and be ready and employable ASAP won't.


That's what the nand2tetris course does, I think (I only looked at the first lessons)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: