Coder Social home page Coder Social logo

Comments (11)

felixangell avatar felixangell commented on August 25, 2024

Do you mean like hot swapping the code? I'm confused

from mac.

yorickdewid avatar yorickdewid commented on August 25, 2024

To load the program from a (encoded) file so that the vm really 'runs' the code instead of the hardcoding a predefined structure. Much like interpreter vm's such as CPython do. Its really just an extention to your idea :)

from mac.

felixangell avatar felixangell commented on August 25, 2024

Oh wait sorry, I thought this was for Alloy and not mac so I was really confused. Yeah you could do file IO, it should be relatively easy. I would do it, but I don't want to deviate too much from the article that this repository is for.

Or even better, you could write an assembler that translates something like

psh 5
psh 5
add
hlt

To whatever the instructions are, and then you feed that into the VM, bam you got yourself a little assembly language for your custom vm! :) I may consider implementing something like this for the advanced version of Mac; but for now it serves for a guide/tutorial as opposed to a virtual machine for something more serious.

from mac.

yorickdewid avatar yorickdewid commented on August 25, 2024

Say the thing, read the article (excellent by the way 👍 ) and I kind of was expecting you'd want to stick to the blog post. Anyway, I'm planning on doing something myself later this year including a tokenizer and the parse/AST story. Something Python based, but with a smaller footprint. Petty possible some of the Alloy concepts will be present and ofcourse the VM

from mac.

felixangell avatar felixangell commented on August 25, 2024

Thanks! 11/10 would write another article again, Matz -- the guy who created Ruby -- tweeted my article!!!!!!!!!!!!!!!!! 😲 And yeah, sounds awesome, virtual machines are great. They're what got me into more lower level concepts of computers like compilers, etc. I'll check it out when it's up :)

For now, I'm going to close the issue; but it doesn't mean I won't implement this later on :)

from mac.

felixangell avatar felixangell commented on August 25, 2024

Might do this later today on another branch since I'm kinda bored :)

from mac.

yorickdewid avatar yorickdewid commented on August 25, 2024

I'll check it out then 👍

from mac.

felixangell avatar felixangell commented on August 25, 2024

@yorickdewid 😀 I'll be back in around 2 hours and I'll probably work on it then :)

from mac.

felixangell avatar felixangell commented on August 25, 2024

@yorickdewid Done :) Mac improved now reads a binary file from the disk.

from mac.

yorickdewid avatar yorickdewid commented on August 25, 2024

Seems to be working, nice. Though it looks like you don't allocate enough for the instructions array.
Anyway you should add some cleanup procedures to free the blocks and close the descriptor.

Looks pretty good, next step is to generate these .mac files based on user input? :)

from mac.

felixangell avatar felixangell commented on August 25, 2024

@yorickdewid It allocates more space when necessary, and the instructions buffer is increased exponentially. And good catch on the cleanup, forgot about that. Oh, found another bug too.

And what you're suggesting is an assembler, it takes an assembly file and creates the .mac files. These are still quite simple, but I'll leave that as an exercise for the reader ;) It shouldn't be too tricky, and you can even do some more fancy stuff like checking if the actual logic of the assembly is correct etc.

from mac.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.