Stories
Slash Boxes
Comments

SoylentNews is people

posted by on Wednesday January 11 2017, @03:31AM   Printer-friendly
from the assembly-made-easy dept.

Have you ever wondered what really goes on when your computer takes a higher-level language, like Javascript or C, and turns it into something it can read? Quine8 (Q8) is a simple virtual machine that takes the most basic building block a computer can operate on, bytecode and runs it at a fraction of the speed of a real CPU, allowing you to watch it run each step of the way.


Original Submission

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 4, Interesting) by jmorris on Wednesday January 11 2017, @04:51AM

    by jmorris (4844) on Wednesday January 11 2017, @04:51AM (#452368)

    Sorry, no stack? Or at least nothing resembling a traditional one. Good way to learn a lot of bad habits.

    The overall idea is good, the implementation just a wee bit too spartan to teach useful concepts on. 256 bytes of program and data is hard enough. The pair of general registers is OK, that is all I had on 6809, but with no index registers either it is limiting.. but probably not for anything you could do in 256 bytes. The ALU implemented is just weird. No signed math? In $current_year?

    Suggest a version more like the AVR, with a separate program address space, allowed to be longer than 256 bytes. And a rudimentary assembler (with symbols) is pretty much mandatory. I always hated hand assembling, a newb is going to really get stuck on that. 256 bytes of RAM is then plenty and retains the idea of being able to see the whole thing. Implement a more traditional condition code register and signed/unsigned compares. It also needs SOME sort of I/O, even if just some virtual LEDs and a few switches to play with. That means either a memory mapped register or an I/O opcode.

    Instead of reinventing the wheel though, just implementing a known primitive instruction set would probably be easier than creating a new one. How hard is 8080? And there are simpler still. Heck, 6502 isn't going to strain Javascript's capability. Somebody with far too time on their hand demoed Linux booting on a Javascript emulated CPU.

    Starting Score:    1  point
    Moderation   +2  
       Interesting=2, Total=2
    Extra 'Interesting' Modifier   0  
    Karma-Bonus Modifier   +1  

    Total Score:   4  
  • (Score: 2) by maxwell demon on Wednesday January 11 2017, @06:58AM

    by maxwell demon (1608) on Wednesday January 11 2017, @06:58AM (#452384) Journal

    No signed math?

    The instruction set only supports addition and subtraction, and in 2's complement, signed and unsigned addition and subtraction are exactly the same.

    --
    The Tao of math: The numbers you can count are not the real numbers.
    • (Score: 2) by jmorris on Wednesday January 11 2017, @07:41AM

      by jmorris (4844) on Wednesday January 11 2017, @07:41AM (#452395)

      This is of course true. But there are no signed compares so doesn't help. The Condition Code bits needs C Z V and N to implement the full set of conditionals.

  • (Score: 3, Informative) by Unixnut on Wednesday January 11 2017, @11:37AM

    by Unixnut (5779) on Wednesday January 11 2017, @11:37AM (#452459)

    Somebody with far too time on their hand demoed Linux booting on a Javascript emulated CPU.

    Yep, Fabrice Bellard: http://bellard.org/jslinux/ [bellard.org]

    He was the guy who wrote Qemu originally, along with ffmpeg. Wish I had the free time he does to do these kind of cool OSS projects.