Earlier quoted context omitted.
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 o…
You are thinking about "Virtual Machines" in a more philosophical/abstract sense. Here the definition is in a much more narrower and conventional sense. Surprisingly i can't find too many books on this subject. The Iain Craig book looks pretty interesting since it seems to link language to the VM, so maybe one can learn both language design and a VM to run it on. Other than the above i can only think of studying "QEM…
Write Your Own Virtual Machine (2022)
71–80 of 102 posts
Re: Write Your Own Virtual Machine (2022)
#72Earlier quoted context omitted.
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…
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.
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.
Re: Write Your Own Virtual Machine (2022)
#73Earlier quoted context omitted.
Interesting. How would you advocate actually gaining that knowledge then? It seems like a student would need to know a significant amount of coding in order to learn those abstractions in an interactive manner. And by learn them I mean learn them (not just following a tutorial), organizing the code for a fully working x86 architecture is no joke. But a student with that level of skill probably doesn't need to learn t…
Very good question. My working assumption throughout was that the people in a computer architecture class already had 1 or 2 semesters of other programming courses where they worked in a high-level language, and are looking to learn how computers work "closer to the hardware". And educational architectures create a completely false impression in this domain. If I had to teach assembly programming to people who never…
MIPS was, I think, a decent compromise between academic architecture and industrial architecture. There was a decent amount of practical stuff the students had to deal with without having to eg do the dance from x86 real mode to protected mode.
One of the most memorable lectures though was on the second last day. As it turned out I had gotten through all of my material one say early. We had a review/Q&A session scheduled for the last day but needed 1h30 of filler. I ended up putting together a lecture on JVM bytecode. Throughout the course I would often use C MIPS ASM throughout examples because the 214, which was a prerequisite, was a C course. All of their first year work had been in Java. Anyway, we took real Java programs and disassembled them down to bytecode and walked through it, showing how it’s very similar to hardware assembly but with extra instructions for eg placing objects on the stack or calling methods on objects. The class ended up going almost an hour over because everyone was oddly engaged and had a ton of questions.
Re: Write Your Own Virtual Machine (2022)
#74I just wish I could find the time to sit down and design the damn thing.
Re: Write Your Own Virtual Machine (2022)
#75Earlier quoted context omitted.
Can 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 t…
I'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 n…
> 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.
Sounds an awful lot like a Commodore 64, where I got my start. There's plenty to learn before needing to worry about paging, protection, virtualization, device discovery, bus faults, etc.
It sounds like it's not teaching the wrong things like your GTA driving example, but teaching a valid subset, but not the subset you'd prefer.
Re: Write Your Own Virtual Machine (2022)
#76Earlier quoted context omitted.
Back in China my first comp arch class used 8051, it was fun. I remember everyone getting a development board and playing with assembly.
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
Re: Write Your Own Virtual Machine (2022)
#77Earlier quoted context omitted.
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…
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 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.
Re: Write Your Own Virtual Machine (2022)
#78Earlier quoted context omitted.
> The JVM is a VM in that sense. It isn't a physical computer, but presents itself as one. No, it isn't and doesn't. What in the world does it have that makes you think it pretends to be a computer? A bunch of pretend registers and a memory limit?
It doesn't have registers, pretend or otherwise, or a memory limit. It sounds like you aren't very familiar with the JVM or computers in general. On the JVM in particular, I suggest reading https://docs.oracle.com/javase/specs/jvms/se23/html/index.ht... .
https://docs.oracle.com/javase/specs/jvms/se23/html/jvms-2.h...
I just mixed it up with Dalvik having multiple registers, but that makes it even worse. At least normal machines have more registers.
And literally here:
The following section provides general guidelines for tuning VM heap sizes: The heap sizes should be set to values such that the maximum amount of memory used by the VM does not exceed the amount of available physical RAM.
https://docs.oracle.com/cd/E21764_01/web.1111/e13814/jvm_tun...
Maybe instead of telling me I'm clueless, tell me how you're right? What do you see in it that is actually virtializing a computer in your mind? Because I'm pretty sure that if someone sold you a VM service and it turned out to be just them running your programs under the JVM, you'd be kind of mad.
Re: Write Your Own Virtual Machine (2022)
#79To 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.
This is a VM like in JVM ( Java Virtual Machine ). I think you will find Java qualifies for “overwhelmingly common usage”.
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 terrible security bug.
Re: Write Your Own Virtual Machine (2022)
#80Earlier 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 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.