Live data from Hacker News

Write Your Own Virtual Machine (2022)

jmeiners.com

51–60 of 102 posts

Re: Write Your Own Virtual Machine (2022)

#51
post #25

Earlier quoted context omitted.

8051-core SoCs seem to be found in tons of cheap Chinese electronics. MP3 players, toys, SD card/USB drive controllers, touchscreen drivers etc.

Yeah, 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.

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

Re: Write Your Own Virtual Machine (2022)

#52

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"

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

Re: Write Your Own Virtual Machine (2022)

#53

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"

Sounds like you needed to learn to follow basic instructions.

Re: Write Your Own Virtual Machine (2022)

#54

Earlier quoted context omitted.

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

or https://nandgame.com/

Or Turing Complete [0] the game

[0] https://store.steampowered.com/app/1444480/Turing_Complete/

Re: Write Your Own Virtual Machine (2022)

#55
post #23

To be That Guy: this is an emulator, not a VM. While the term can apply in a descriptive sense, and in the pre-hardware-virtualization past there was some ambiguity, the overwhelmingly common usage of "Virtual Machine" in the modern world refers to an environment making use of hardware virtualization features like VT-x et. al.

I have to politely disagree. In the most pure sense a VM is a made up computer, without any implications being expressed to what it’s intended to be used for or how it works.

In the article the author even states as one example emulation a classic console, but it’s clear from the article that there are many other possible VM’s from the definition they provide.

Anyways the point is VM is abstract, and there are many many types of them. Simulators, emulators, hypervisors, etc… are all VMs, but also there are VMs that don’t quite already have a name for them yet because they’re strange.

I don’t mean to be rude at all - quite the contrary, I want to be respectful - but I also want to be clear about these terms for people who are interested in learning.

Re: Write Your Own Virtual Machine (2022)

#56
post #30
post #23

To be That Guy: this is an emulator, not a VM. While the term can apply in a descriptive sense, and in the pre-hardware-virtualization past there was some ambiguity, the overwhelmingly common usage of "Virtual Machine" in the modern world refers to an environment making use of hardware virtualization features like VT-x et. al.

> To be That Guy: this is an emulator, not a VM. While the term can apply in a descriptive sense, and in the pre-hardware-virtualization past there was some ambiguity, the overwhelmingly common usage of "Virtual Machine" in the modern world refers to an environment making use of hardware virtualization features like VT-x et. al. I don't think the distinction you're advocating for actually exists. 'Virtual machine' is…

Exactly, emulation is “make sure the input and output of what you’re emulating are the same”, whereas simulation is “model the actual internal mechanisms of the thing you’re simulating, so as to achieve the same inputs and outputs”.

Re: Write Your Own Virtual Machine (2022)

#57
post #26

Earlier quoted context omitted.

I don't think that terminology is "overwhelmingly common", and I'd argue that it isn't even entirely correct. The JVM is widely deployed, the Ethereum VM is called the "EVM", https://www.linuxfoundation.org/hubfs/LF%20Research/The_Stat... describes BPF and eBPF repeatedly as "virtual machines", https://webassembly.org/ begins by saying, "WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based…

Disagree with both of you. JVM was always a misnomer, it just stuck because that's just the name they stuck with. Putting "virtual machine" in its name in defiance of the meaning doesn't suddenly make it a virtual machine any more than calling your dog "my son" makes your dog your son. And virtual machines have used software virtialization for the longest time, they aren't always hardware based. Really, a virtual mac…

The JVM is a VM in that sense. It isn't a physical computer, but presents itself as one. It's true that that computer doesn't have a disk or a keyboard, but neither do the vast majority of physical computers, including, specifically, the set-top boxes the JVM was originally designed to run on.

Re: Write Your Own Virtual Machine (2022)

#58
post #25

Earlier quoted context omitted.

Yeah, 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.

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

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

Re: Write Your Own Virtual Machine (2022)

#59

Some books that i was pointed to; 1) Virtual Machines: Versatile Platforms for Systems and Processes by Smith and Nair - Seems to be a comprehensive subject overview book. 2) Virtual Machines by Iain Craig - Seems like a more hands-on book with languages and VMs. 3) Virtual Machine Design and Implementation in C/C++ by Bill Blunden - Seems like an hands-on implementation. If somebody who has read any of the above can…

I'm not convinced that the subject is narrow enough to overview in a single book. The considerations involved in writing a Nintendo emulator, a hypervisor using VT-x, a conventional multitasking operating system, an interpreter for a new scripting language, a SQL query optimizer, a regular expression matcher, a security monitor for untrusted player code running on a game server, etc., would seem to have very little overlap. But these are all "virtual machines". There's even a stack-based virtual machine in the terminfo format for specifying character-cell terminal escape sequences!

In a deep sense, virtual machines are what make computers computers, as we use the term today. Turing's 01936 paper about the Entscheidungsproblem hinged on virtual machines being able to emulate one another.

Re: Write Your Own Virtual Machine (2022)

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

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.
Post reply on HN