Live data from Hacker News

Write Your Own Virtual Machine (2022)

jmeiners.com

81–90 of 102 posts

Re: Write Your Own Virtual Machine (2022)

#81
post #9

Earlier quoted context omitted.

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…

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 i…

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.

Re: Write Your Own Virtual Machine (2022)

#82

Earlier quoted context omitted.

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.

Re: Write Your Own Virtual Machine (2022)

#83

Earlier quoted context omitted.

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.…

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"

Re: Write Your Own Virtual Machine (2022)

#84

Earlier quoted context omitted.

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"

> 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…

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.

Re: Write Your Own Virtual Machine (2022)

#85

Earlier quoted context omitted.

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…

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.

Re: Write Your Own Virtual Machine (2022)

#86
post #5

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 simp…

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).

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

Re: Write Your Own Virtual Machine (2022)

#87
post #79

Earlier quoted context omitted.

This is a VM like in JVM ( Java Virtual Machine ). I think you will find Java qualifies for “overwhelmingly common usage”.

Not in this context, no. If you tell your boss you're deploying the solution "in a VM" and it turns out to be a .jar file, you're likely to be fired. Context and convention are important. This subthread is filled with people who are technically right, but choosing to cheer for an unclear and idiosyncratic terminology. A VM means hardware virtualization. Choosing other meanings is at best confusing and at worst a terr…

Is it not the exact same concept underneath? An environment that provides a layer of abstraction by translating instructions into a standardized, transportable form that can be executed consistently, regardless of the underlying hardware or operating system?

I always thought that it made sense to use the word for both things, and I never even thought twice about it when people used it for programming languages.

It would have to be a very strange conversation for someone to misunderstand someone else in the way you mentioned.

Re: Write Your Own Virtual Machine (2022)

#88
post #79

Earlier quoted context omitted.

Not in this context, no. If you tell your boss you're deploying the solution "in a VM" and it turns out to be a .jar file, you're likely to be fired. Context and convention are important. This subthread is filled with people who are technically right, but choosing to cheer for an unclear and idiosyncratic terminology. A VM means hardware virtualization. Choosing other meanings is at best confusing and at worst a terr…

Is it not the exact same concept underneath? An environment that provides a layer of abstraction by translating instructions into a standardized, transportable form that can be executed consistently, regardless of the underlying hardware or operating system? I always thought that it made sense to use the word for both things, and I never even thought twice about it when people used it for programming languages. It wo…

> Is it not the exact same concept underneath?

Sure, in precisely the same way that a kitchen knife and a sword are the "exact same concept underneath". But if you use the words interchangeably you'll confuse people.

And I'll just repeat the point, if you tell your boss your web app is "running in a VM" when you just wrote it in Java, you'll be fired for some really terrible security analysis.

Re: Write Your Own Virtual Machine (2022)

#89

Earlier quoted context omitted.

For an excellent (and free) 8051 book with lots of C code see Michael Pont's Patterns for Time-Triggered Embedded Systems - https://www.safetty.net/publications/pttes

Thanks, I have heard a lot of good words about this book.

I have all of Michael Pont's books. The reason? Everything is in C (lots of code) and not a line of assembly in sight! And his focus is on time-triggered architectures suitable for real-time in addition to "standard" event-triggered architectures. Thus one gets to learn both the control paradigms in a unified manner. His earlier books use 8051 while the later books deal with ARM. And all of the code/teaching is for "industrial strength" apps and not merely for "hobby" purposes. So here too you get a broad spectrum.

Books - https://www.safetty.net/publications

Video Lectures - https://www.youtube.com/user/SafeTTynet/videos

Re: Write Your Own Virtual Machine (2022)

#90
post #39

Earlier quoted context omitted.

Again, you are coming at this from a software engineering direction, not a computer architecture/engineering one.

Since 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 Emula…

This article would directly apply to NES or game boy emulation.

Yes, there are fewer instructions.

Post reply on HN