3 ms·
I have been working on this project on and off for about 6 months. I would love feedback on the code, design - whatever!
by tekknolagi 12y ago
I have been working on this project on and off for about 6 months. I would love feedback on the code, design - whatever!
- dsturnbull2049 12y agoVery concise implementation. I keep thinking there's missing files or at least I'm missing something in my understanding. :) I wrote a 0-operand VM in C a few years ago that used a lot of the same concepts but considerably more code, like 10x at least. I will learn a lot from this.
- tekknolagi 12y agoWhat kinds of files look missing? I'm curious. What is a 0 operand VM? I'd love to see it!
- chewxy 12y agoUsing only PUSH and POP I think. i.e a stack machine. also, OP, your code looks great.
- tekknolagi 12y agoOh interesting. That sounds... complicated. Thanks! It's my first big C project that isn't hideous :D
- dsturnbull2049 12y agoYeah, a stack machine. https://github.com/dsturnbull/stack_cpu https://github.com/dsturnbull/stack_cpu What I mean by missing files is that it's so clean that at first glance it didn't look like the whole deal :)
- tekknolagi 12y agoOh well thanks — that's quite a compliment. This is pretty cool!
- Hytosys 12y agoJust for anyone looking for more information: http://en.wikipedia.org/wiki/Instruction_set#Number_of_operands http://en.wikipedia.org/wiki/Instruction_set#Number_of_opera...
- tekknolagi 12y agoAwesome!
- listic 12y agoUnfortunately, with the ever-increasing processor-memory gap (the growing discrepancy between processor and memory speeds, also called Memory Wall, if I'm not mistaken), 0-operand, or stack VM's are seeing ever-increasing performance penalties.
- ghkbrew 12y agoIs there a reason for the combination of register-based (logical ops) and stack-based (arithmetic ops) operations? Otherwise fun project.
- tekknolagi 12y agoProbably just my sloppiness. Things like OR were implemented while looking at other projects like tinyvm, so it's not perfectly consistent.
- zura 12y agoNice. Any particular tutorial/article/book you're following?
- tekknolagi 12y agoNope :) Lots of small web resources.
- wsc981 12y agoPerhaps, if you're interested in learning to write well-written C code, you might be interested in the book "C Programming: A Modern Approach"[0] by King. Coding style is an important topic in his book. [0]: http://www.amazon.com/Programming-Modern-Approach-2nd-Edition/dp/0393979504 http://www.amazon.com/Programming-Modern-Approach-2nd-Editio...
- zura 12y agoThank you, seems very interesting. Usually, I only write pure C code when I really have to. Otherwise, I see no reason why someone should restrict "shimself" from using C++.