Comments (11)
Do you mean like hot swapping the code? I'm confused
from mac.
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.
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.
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.
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.
Might do this later today on another branch since I'm kinda bored :)
from mac.
I'll check it out then 👍
from mac.
@yorickdewid 😀 I'll be back in around 2 hours and I'll probably work on it then :)
from mac.
@yorickdewid Done :) Mac improved now reads a binary file from the disk.
from mac.
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.
@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)
- No dmg? (Mac) HOT 1
- dead link HOT 1
- / / /Eagga|_
- Thanks for nice work HOT 1
- I think I caught a small bug HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mac.