Go Down

Topic: executing binary code from RAM (Read 125 times) previous topic - next topic

pierrealexis

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

mrburnette

#1
Jul 04, 2015, 06:23 pm Last Edit: Jul 04, 2015, 07:00 pm by mrburnette
Quote
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

cr0sh

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.
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Coding Badly

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

http://bitlash.net/


westfw

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.

pierrealexis

Is it?
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

Paul__B

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?

pierrealexis

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

Paul__B

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.

Go Up