Tech Off Thread

5 posts

8051 - executing opcodes from the data memory

Back to Forum: Tech Off
  • TomasDeml

    Hi!
    Does anybody know if is it possible to execute opcodes from the data memory (internal ram) on 8051?

    I want to redirect the program flow to instructions located in the data memory. I tried to move the data address into the PC register but this does not work.

    Thanks a lot.

  • Steven J Ackerman

    The 8051 is a modified Harvard architecture with separate data and program address spaces.

    Unless your hardware allows you to map part of the data space into the program space, you will not be able to execute opcodes in data space.

  • TomasDeml

    Steven J Ackerman wrote:

    The 8051 is a modified Harvard architecture with separate data and program address spaces.

    Unless your hardware allows you to map part of the data space into the program space, you will not be able to execute opcodes in data space.



    That's bad Smiley

    I've also searched the net a bit, finding people being curious about the same question, but I have found only this:

    8052 forums wrote:

    Download the 8051 "bible", chapter 1, page1 (talking about basics!) and read about the 8052 memory organisation. You will see that the 8052 is designed to have separate DATA (read RAM) and PROGRAM (read ROM) memories. You can not execute from DATA memory, you can not write to PROGRAM memory. To execute from RAM on an 8052, connect the RAM chip like this:

    /WR (P3.6) from 8052 to /WE pin of RAM chip,
    /PSEN from 8052 to /OE pin of RAM chip.
    /EA to +5V.

    This will allow you to write to the RAM chip as external data memory (but not read from it), and read from it as program memory starting from address 01000h. Instructions from 00000h to 00fffh will be executed from internal (EEP)ROM.

  • Grumpy

    The question is why do you want to execute out of data memory?  Did you run out of program memory space?  If so, you might take a look at a recent article in Embedded Systems.  It was either this month or last, I don't have my article folder at hand, but it describes how you can extend both the program and data memory without using additional pins for bank switching.  It was a really slick article.  The author I think worked for an emulator manufacture.  Sorry about the details, e-mail me if you cannot locate it.

    Here are the details:

    Martin B. Pawloski (pme51@metaice.com). August 2005. "Expand Your 8051 Memory". Embedded Systems Programming. p 20-29.

    Abstract: Here's a way to extend the life of the ever-popular 8051 microcontroller.  The author's clever circuits and software extend the chip's addressing range without awkward tricks or cumbersome add-ons.

  • TomasDeml

    Grumpy wrote:
    The question is why do you want to execute out of data memory?  Did you run out of program memory space?  If so, you might take a look at a recent article in Embedded Systems.  It was either this month or last, I don't have my article folder at hand, but it describes how you can extend both the program and data memory without using additional pins for bank switching.  It was a really slick article.  The author I think worked for an emulator manufacture.  Sorry about the details, e-mail me if you cannot locate it.

    Here are the details:

    Martin B. Pawloski (pme51@metaice.com). August 2005. "Expand Your 8051 Memory". Embedded Systems Programming. p 20-29.

    Abstract: Here's a way to extend the life of the ever-popular 8051 microcontroller.  The author's clever circuits and software extend the chip's addressing range without awkward tricks or cumbersome add-ons.



    Thanks for the article. I'll inspect it asap Smiley

    No, I did not run out of the program space but I was trying whether it is possible to dynamically emit opcodes and then execute them; some sort of JIT. I was just curious Smiley

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.