executing binary code from RAM

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. I want to have an assembly 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. I probably could write an interpreter of op codes written in RAM, but it is a very complex solution. Years ago I was using a Von Neumann architecture 8 bit CPU which 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.

Any suggestions on workarounds with Arduino or of non-AVR Arduino boards based on Von Neumann architectures I might use?

Thanks!

Pierrealexis

I want to have an assembly program that writes in RAM some code and then branches to execute it.

Use a STM32 board that natively supports execute from SRAM. Google it. Board pricing starts @ $4USD - yeah! Maple Mini STM32F103

Ray

If you're wanting something simple (ie - 8 bit), there are microcontrollers out there based on 6502 and Z80 cores (maybe even 680x - but since Motorola is still around, maybe not). Many of these controllers have a ton of on-board peripheral ports, and a lot of RAM - but still bring out the address and data lines for expansion purposes. In many cases, they can be programmed using C - some also have an on-board BASIC interpreter (you essentially hook up a serial terming, boot, then start coding - storage is handled by flash or similar). All of them, though (just like the ATMega line for the Arduino) still support assembler and can handle what you want to do.

pierrealexis:
I probably could write an interpreter of op codes written in RAM, but it is a very complex solution.

Is it?

http://bitlash.net/

Msp430 (ti launchpad) is a microcontroller architecture with a Von neumann architecture , that will let you load code into ram and execute it. And is supported by Energia , an arduino-compatible IDE.

[quote author=Coding Badly date=1436032584 link=msg=2303349] Is it? [/quote]

I think so, because what I meant is writing a program that would read the instruction codes from RAM and the zero or more inline data bytes that follow them and substitute these data bytes, somehow, presumably using stack variables, to the data bytes that follow hard coded instructions in Flash and I haven't thought about interrupts and branches... I guess it is writing a virtual machine in assembly. Anyway the suggestions of other Von Neumann architectures are excellent, along the same lines I have found a chipKit PIC32-based Arduino Uno. Thanks!

Pierre

I think you almost explained why you would want to run code from RAM, but I still don't see the point.

Self-modifying code is a very niche "market", generally obsoleted by faster processors and more complex instruction sets. AVRs tend to be short on RAM anyway so large sections of such code would be inconvenient. What is the point?

The point is academic: I’d like to show some self-modifying code to my IT students.
Thanks!

pierrealexis: The point is academic: I'd like to show some self-modifying code to my IT students.

Oh well, perfectly fine!

I most certainly have no complaints against that!

While you are at it, do not forget to demonstrate FORTH to them as well. Whether or not you actually use it in practice, it is stunningly elegant.

Is this one of those demonstrations where everyone wears safety specs, and you do the demo behind a plexiglass blast shield, with the warning "and ever don't let me catch you doing this" ?

What about the eZ80? A Z80 compatible runs code from ram in binary and can be programmed via a debug port, look at this:

https://youtu.be/cKoRRA4MyM4

Awesome! This is exactly what I'd love to do (and I did in the past with other microprocessors) if only I'd have the time to dedicate to the hardware work! This guy really knows his stuff!

How about an Arduino Zero? That has 32k of ram and is a Von Neumann architecture?

I would also second westfw's suggestion of an msp430. Although the amount of ram on them most of them is small. However, the msp430fr5xxx series uses FRAM instead of FLASH. You can use the FRAM as though it is RAM. The launchpad msp430fr5969 has 64k of FRAM and 2k of real RAM. It can be had for ~$20 USD (15.99 + 7 shipping) from the estore.ti.com . msp430 assembler is pretty simple to learn and has been compared to PDP-11 asm.

-rick

[quote author=Rick Kimball date=1436200937 link=msg=2305863] How about an Arduino Zero? That has 32k of ram and is a Von Neumann architecture? [/quote] Indeed, you got me thinking about the Arduino M0 Pro. However, I looked up ATMEL Studio 6.2 and it does not install on Linux. It is disappointing, given that it is a considerable investement in time I have to make, I'd rather make it on a very popular architecture, such as ARM. Also I would really like the EDBG (embedded debugger) feature of this processor, if that means I need no specific debugging hardware and assuming it debugs assembly.

Arduino m0 pro, using atmel samd21, IS an ARM processor. You can use any non-atmel arm environment you want with it, at least theoRetically.

OTOH, if you don't need the arduino environment, I don't see why you'd be much interested in a $50 m0-pro,compared to the various manufacturer boards that are about $20