Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

what is executing code from RAM

Status
Not open for further replies.
Hi,

I don't understand this concept of executing the code from RAM. In general upon power on the micro controller will go to the reset vector which is located in the flash memory. Then how does it actually execute the code from the RAM. Could someone please explain me the concept and how to set up in any micro controller that is the steps involved in it.

Thanks in advance,
regards,
Satya
 
The PC you are using NOW is executing code from RAM right NOW.

Some micro controllers can not execute code from RAM.
Some micros see all memory as the same. ROM and RAM are addressed as the same thing.
There are many different types of computers. Some start at 0 and some start out at FFFF but it does not matter.
Example: Your computer has a "boot loader" starting at 0 in ROM or FLASH. This program goes to a hard drive or some storage device and gets the real program and loads it into RAM at 8000h then when done jumps to 8000h and runs the program.
 
 
The easiest way that I can explain this by using a microprocessor system because its mainly the microprocessor systems that allow you to do this.... I say allow, I mean its the way they work..

Z80 can access 2^16 bytes of memory The program counter starts as usual at 0x0000.. When it gets to 65535 to spills over to 0... This is linear memory.

Take the ZX Spectrum developed by Clive... The program pointer first runs through ROM where all the BIOS and basic interpreter resides its 16384 bytes long. Then it sees the video memory which is 6912 bytes long which is the start of the RAM... There are places put aside for system variables and system buffers 457 bytes.. But then your runnable code can be inserted.. You have 41613 byte ( about 41k ) to write your programs with... Once you write a program for the Z80 you load it into the RAM... As the memory is linear you can then place the program pointer where your program starts.. You can also call ROM routines whenever you like..

The Z80 and 8080 where developed around the same time and could run the same code (basically the same chip) so the progression of the x86 has been influenced by this memory model.. The PC has had loadable code ever since.. Imagine having to flash your program every time you want to use your PC... It would be faster, but you would get a bit annoyed every time you need to do something...

I believe that pic32 and ARM have loadable code.... There is probably a way to do it with most micro's..

BTW the PC memory map is very similar to the ZX Spectrum.... Apart from the MMU ( Memory Management Unit )
 
Last edited:
I don't understand this concept of executing the code from RAM. In general upon power on the micro controller will go to the reset vector which is located in the flash memory. Then how does it actually execute the code from the RAM.
It reads the instruction from the memory and executes it. There is a program counter register that points to the next instruction that is read from the memory and queued for execution.
 
Status
Not open for further replies.

Latest threads

Back
Top