9

I am looking for an inexpensive single board computer that I could program in assembly language, using limited facilities to load the object code from a PC and simple I/O peripherals.

Ideally I would like to be able to write in a reasonable time all the code on the machine myself. I don't want an OS in the way, as I want to have a program that writes in RAM some code and then branches to execute it. Arduino would probably be my best choice, as far as system simplicity suitable for assembly programming goes, but it has a Harvard architecture and it won't allow me to execute from RAM.

Years ago I was using a Von Neumann architecture 8-bit CPU that could branch execution to any address, no matter whether it was mapped to ROM, RAM or whatever. This is what I would like to do now.

I probably could write and load in Flash memory an interpreter of op codes written in RAM, but it is a very complex and time-consuming solution, unless virtual machines of this kind exist already.

Any suggestions on other workarounds with Arduino or of other micro-controllers I might use?

Thanks!

Pierre

7
  • 3
    The PIC32 is a Princeton (Von Neumann) architecture chip. It's a MIPS CPU so is well documented and standardized, though somewhat more complex than a lowly AVR. The chipKIT boards may be more to your liking.
    – Majenko
    Jul 4, 2015 at 14:05
  • 2
    Although optimized as a Harvard Architecture, the ARM Cortex-M series can execute from RAM at a tolerable efficiency loss and would still be a lot faster than an AVR when doing so. At least a half dozen chip companies make widely used offerings based on licensing this core, and while many people use vendor and/or semi-standard libraries, it is entirely possible to do it all yourself based on the data sheets. I went with STM32 first as their discovery boards are very cheap, work on Linux/OSX with open source tools, and can program chips on custom boards, but have now used Kinetis as well. Jul 4, 2015 at 14:13
  • The main question is Why? Why do you require ASM execution from RAM? And what kind of assembly do you want to use? Since every architecture has its own language... Do you do this for learning purposes? Or you have a specific target?
    – frarugi87
    Jan 30, 2017 at 11:40
  • 2
    I beg to differ, why I wished to do this is irrelevant to the question I asked at the time as this is not a workaround to some other issue. Incidentally, I followed Majenko's advice and I currently have a Uno32 plus external interfaces running assembly (and calling C functions from assembly), writing its own modified asm code in RAM and executing it.
    – pierre
    Jan 30, 2017 at 19:11
  • Forth is what you are looking for :) Jul 31, 2017 at 13:23

1 Answer 1

1

In my opinion the interpreter idea is much more feasible. The notion of writing, in assembler, code that itself generates machine code, in RAM, and then executes it, is itself incredibly complex.

You haven't said why you want to do this, so this is somewhat of an X-Y problem.

I don't want an o.s. in the way ...

The normal Arduinos do not have an OS in the way - basically the code you write is what gets loaded onto the chip.

8
  • 2
    In a word, no. The inability to execute modifiable memory is a rather unusual limitation in this day and age, where most other nominally Harvard architecture devices are modified to be able to avoid that limitation. Writing a software interpreter is both going to be a lot more work, and a lot less efficient, than dealing with one of the many inexpensive, high performance, and easy to use chips that has the necessary internal connections to simply execute code from RAM. The slightly less efficient pipeline operation in that mode is still far, far ahead of software interpretation. Jul 5, 2015 at 0:35
  • 1
    No. If you are going to do runtime code modification, it is by far easier to directly generate machine code than to generate high level code and also have to create a compiler or interpreter as in your recommendation. It might be worth spending some time hand-writing instructions to get some perspective. And no, "write all the code on the machine myself" does not refer to run time code generation to begin with, but rather merely to creating original work vs. relying on other authors for supporting components. Jul 5, 2015 at 5:47
  • 1
    Here is a simple forth style shell for the Arduino that executes code from any of the memory storages (SRAM, EEMEM, EEPROM). Not the fastest interpreter but shows how the instruction fetch (memory access) and instruction pointer (call/return addresses) can be abstracted. github.com/mikaelpatel/Arduino-Shell Sep 2, 2016 at 8:33
  • 1
    I'm impressed, Mikael. I wrote a Forth interpreter for the Apple II years ago. I doubt I can even find the code these days. Good old Forth, still alive and kicking! :)
    – Nick Gammon
    Sep 3, 2016 at 1:21
  • 1
    @NickGammon I recently wrote a more traditional forth virtual machine (fvm) for the Arduino. It allows embedding a byte instruction interpreter in an Arduino sketch as it is multi-tasking (allows yield of the fvm). github.com/mikaelpatel/Arduino-FVM. There is a token compiler (runs on the Arduino :) and a traditional forth interactive interpreter. Please see the example sketches. Mar 1, 2017 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.