0

I want to try and convert a simple language Lox (https://craftinginterpreters.com/the-lox-language.html) to basic assembly, but I don't want to use the x86 instruction set because its simply too much. Is there a basic (but Turing complete) assembler language that would suit this?

I am not looking to compile this, but make a simple assembler vm for it (with registers, stack, flags etc)

I was considering making a simple instruction set that only worked with 64 bit values, and have ADD,SUB, etc.. but not sure what basic instructions I would need.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Kladskull
  • 10,332
  • 20
  • 69
  • 111
  • 1
    [x86 `mov` is turing complete](https://stackoverflow.com/questions/61048788/why-is-mov-turing-complete) but I guess you don't want to write your software in `mov`s... – tkausl Jul 22 '22 at 20:56
  • 2
    You might have success with RISC-V assembly. It's quite easy to use the basic instruction set, ignoring the various extensions. – fuz Jul 22 '22 at 20:56
  • @tkausl just using one command (mov) is intereesting, but it sounds like it could be very complex. – Kladskull Jul 22 '22 at 21:05
  • Do you mean easiest to *learn*, or most minimal in terms of a how many instructions, or in terms of hardware complexity to implement? See https://en.wikipedia.org/wiki/One-instruction_set_computer for the latter two. But yeah, actually getting anything useful done is a huge pain with very reduced instruction sets, like with languages such as brainf***k – Peter Cordes Jul 22 '22 at 21:24
  • 1
    LC-3 is Turing complete, although the lack of a right shift is a pain for programs that need it. Probably even more stripped down toy instructions sets are, too, like MARIE and even LMC, although without bitwise binary operations, any program that includes those things must be formulated to avoid them, keeping its data in a less compact form. Of course we're ignoring the infinite-memory part of Turing completeness; like C, assembly languages naturally have some fixed pointer width and way to address memory. – Peter Cordes Jul 22 '22 at 21:28
  • As a compiler target, it's generally most convenient if you don't need helper functions for most operations on integers in the source language. So it's actually easier to deal with if your ISA has a few more instructions, like multiply and divide. RISC-V is a good choice, as fuz says. – Peter Cordes Jul 22 '22 at 21:31

0 Answers0