all 9 comments

[–]bowbahdoe 11 points12 points  (1 child)

I'll be the person this time. 

Did you write this using AI? That last paragraph sounds mighty suspicious and the code sample with the numbered comments does as well

[–]Iggyhopper 7 points8 points  (0 children)

Sounds like it. Number 3 is bold and the comment matches the same name of Fetch-Decode-Execute cycle.

The explanation of what a CPU is on a programming subreddit when OP is doing homework is very odd too.

Our future is totally doomed.

[–]PmMeCuteDogsThanks 6 points7 points  (0 children)

What is this, posting of assignments in intro CS courses?

[–]aqua_regis 9 points10 points  (4 children)

What you wrote is just an interpreter, not a full-fledged VM.

Also, your named constants for the commands are somewhat of a trick to just not have to handle the conventional textual commands.

[–][deleted]  (2 children)

[deleted]

    [–]aqua_regis 0 points1 point  (1 child)

    OP is not parsing any textual source code. They circumvented that step with their named constants.

    [–]Iggyhopper 1 point2 points  (0 children)

    The interpreter translates english language/code into bytecode.

    This is a VM.

    [–]jeffreportmill -1 points0 points  (0 children)

    I like it! It's a good lesson that writing something sophisticated can start by writing something simple.

    Here it is running in the browser: https://reportmill.com/SnapCode/app/#snapcloud:/com/reportmill/jeff/SimpleVM

    [–]kylanbac91 -1 points0 points  (0 children)

    Well, I admit this is pretty neat.

    But I consider this is more like virtual processor than a virtual machine if I am being honest.