Using .hex in code

I wish to use a compiled .hex file in code, not inline asm. I'm trying to get a program booted off a sd card, for use with an os. Any help?

Thanks Isaac

A Hex file is the complete program that the microcontroller will run. Inline ASM is used when you want to run an assembler command within source code. Your trying to boot a computer off of the compiled hex file? I am not sure what you mean.

The arduino cannot run programs outside its flash, the only way to store programs in one SD card and then being able to run then is by using a modified bootloader that programs the flash with the new program, but be ware that the flash only assure 10000 cycles of programming after that it can be damaged and no longer work, so if you need more space just use a bigger avr.

I recall back in the Commodore 64 days we poked data from tape into memory and just set the program Register (?) to the starting address. Tricky and allways fun to debug …

If I map this technique on Arduino, you could allocate some memory and put asm statements in it from disk and call a pointer to a function that points to the address of the array. It might be executing it.

Never done this, no guarantees it will work and I don’t know if it will damage your arduino. So try at own risk :slight_smile:
</thought experiment>

robtillaart,

Unfortunately, this won't work with an Arduino. The Commodore 64's processor used a Von Neumann architecture ( http://en.wikipedia.org/wiki/Von_neumann_architecture), while the processors in Arduinos use a Harvard Architecture (http://en.wikipedia.org/wiki/Harvard_architecture).

On a Commodore 64, the program is in RAM, along with the program's variables. On an Arduino, the program is in flash memory, and the program's variables are in RAM.

Of course, the Arduino bootloader has to be able to change the flash memory to load a new program, so there is a special provision that allows it to write to flash memory. Even for the bootloader, writing to flash memory is very different from changing RAM -- much slower, for instance.

Regards,

-Mike

Hey, thanks for all the help. I needed this for a simple os, but an ARM will probably do better. Thanks Isaac