That might be a little bit an exotic problem, but I hope somebody can still help me out a bit ;). I would like to execute a standard C program, however, at some point during program execution I would like that a certain number of instructions, which are stored in a local scratch pad RAM, are executed. The scratchpad memory is accessable for all processes. Lets assume this local memory starts at address 0x80000000 and I would integrate this in the following C code fragement
int main {
int a=1;
int b=2;
int c=3;
c = a + b;
%goto address 0x80000000 and execute three instructions before continuing
%program execution here
return(0);
}
The program counter would go through the following stages, assuming main is loaded at 0x40000000
0x40000000 a=5;
0x40000004 b=2;
0x40000008 c=1;
0x4000000C c=a+b;
0x80000000 first instruction in the local scratch pad
0x80000004 second instruction in the local scratch pad
0x80000008 third instruction in the local scratch pad
0x40000010 return(0);
Anyone an idea how to do this? Do I need to use assembler jump instructions or is there something more elegant.
Many thanks, Andi
The TI-99/4A console contains 256 bytes of RAM that appear at address >8000-80FF. As the address is not fully decoded, the same memory appears at >8100-81FF, at >8200-82FF, and at >8300-83FF.
Scratchpad memory (SPRAM) is a high-speed internal memory directly connected to the CPU core and used for temporary storage to hold very small items of data for rapid retrieval.
RAM Memory Space Allocation in 8051 80 bytes from 30H to 7FH locations are used for read and write storage; it is called as scratch pad.
The internal data memory of 8051 is divided into two groups. These are a set of eight registers and a scratch pad memory. These eight registers are R0 toR7. The address range 00H to 07H is used to access the registers, and the rest are scratch pad memory.
Assuming that the instructions behave like a normal function, you can do:
#include <stdio.h>
void (*scratchpad_func)(void) = (void(*)(void))0x80000000;
int main()
{
printf("before\n");
scratchpad_func();
printf("after\n");
return 0;
}
Obviously, you'll have to be using a real mode operating system, or jump through whatever hoops your OS/processor combination requires to have direct access to that address space.
(On some architectures "behave like a normal function" is as simple as a "jump $ra" at the end if you don't touch callee-saved registers. E.g. MIPS.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With