Python Forum

Full Version: a virtual machine
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
when i first saw a computer program, i tried to imagine what hardware was doing to make that run. back then i had only seen computer hardware on TV and it showed tapes spinning back and forth. so i imagined the hardware was wired to run programs in a language like fortran and was looking up variables by name on the tapes (i was not yet aware of core memory). and there was a 2nd tape with the program. it wasn't long until i figured out reality (with the help of a hexadecimal memory dump printed on paper). it was then less than a year until i was coding assembler language on a large mainframe my mother's professor got me access to (with the help of an assembler language book i acquired in Chapel Hill NC while on summer vacation with the family).

that original concept has stuck in my head. instead of a giant numerically indexed memory i have often envisioned machines where memory storing and memory fetching is done by names. this is what Python (and some others) are doing now. what i want to do is build an emulator of such a machine, like what Python is doing, but structured more like a machine as it might have been built in hardware, with all things such hardware might also need. but i want to basically use exactly the Python system as the starting point. then for that kind of (virtually implemented) machine, its OS would be implemented in Python code.

this, or Python's own assembly code, could be a way to more gently introduce machine language to students, without the difficulty of dealing with a big flat numerically indexed memory at the same time as teaching discrete programming steps. then hit them with "memory as a list" later on.
Out of interest, why do you think it necessary to introduce students to machine language?

Microcode isn't usually taught to anyone but electronics engineers these days. Who would need the next level up of machine code?
It may not be taught, but it's a joy to learn (at least it was for me) and The pay for embedded code is great!
Machine code was what I learned first (honeywell, computer systems engineering lab, Waltham, MA USA (1968)), at same time assembler and soon thereafter lisp and FORTRAN.

The following course is one of the most enjoyable that I have taken recently: https://www.nand2tetris.org/ and it's free (or at least was).
Not only do you design a complete 16 bit computer, but also create assembly language, an operating system, and compiler.

One additional item. If interested in above course, you should watch this TED talk: https://www.ted.com/talks/shimon_schocke...anguage=en

when done, you will not only know machine language (since you created it), but also thoroughly understand computer architecture as well.
I'm similar to you, @Larz60+, I learned machine code and assembly languages first, and went onto Fortran, Pascal, Cobol, ADA, APL, amongst others. Had to get some custom processors developed for specialist applications, hence the microcode interest.
gruntfutuk - You would probably enjoy the course (post #3)
watch the TED talk to see if it interests you.
(Sep-01-2018, 07:04 AM)gruntfutuk Wrote: [ -> ]Out of interest, why do you think it necessary to introduce students to machine language?

Microcode isn't usually taught to anyone but electronics engineers these days. Who would need the next level up of machine code?

it would not be for all students. it would be for those that need, or want, to learn how computers work all the way down to the bare metal, such as the engineer types (electrical engineers, computer engineers). i still find that those who know machine language have a better perspective on things like embedded systems.

a friend of mine who was not into computers at all signed up for "a computer class" when he was in college (where i worked). it turns out it was a PDP-11 machine language class in EE. i had to help him a lot through it. he had expected it to be more analog oriented for his "music technology" track. but at least he passed. today, he could not write a hello world program in any language and ended up running a technology oriented investing company. but he still understands the scope of computers from top to bottom and tells me that having taken that class has helped him a lot even though he never wrote any programs since college.

maybe computers in a few decades will be such that no one needs to learn machine language. maybe programs will automatically code compiler builders and emulator builders for us and we won't know, or need to know, or care, which it is. but, we are not there, yet. dream on.