In a called function,I want to save the "program counter" , when program reached to a specified location ,& then return from the function .
In the next calling of this function , I want to restore "pc+1" to continue the process.
How can I do this?
5 5518
Can you give an example of precisely what you want? It's not so clear to me. Besides, I'm not sure one can gain access to the program counter.
C++ files may also be relative. That is suppose you have a function that prints the memory location of an instruction, then returns. If you run the program a second time, you may not get the same value.
Banfa 9,065
Expert Mod 8TB
To get access to processor registers you normally need to drop into assembly code.
However the C/C++ standards do not define this, only some C/C++ compilers support it and all in propriatory ways.
For instance in MSVC I think (IIRC) that the sytanx is -
void fn(void
-
{
-
// Some C code here
-
-
asm
-
{
-
// we've dropped into assembler, assembly code here
-
}
-
-
// More C code here
-
}
-
However you'd better be really sure you know what you are doing it you are going to mess directly with the pc.
Thanks for your reply,
I use IAR 4.4 for arm.
In this program I have a timer interrupt. I have a specified routine to be done in this sub routine.But every part should be done in one time,then the program should wait until next interrupt service routine call to continue.
I tried function pointer arrays & also switch-case routines.But these routines are not practical for me as they are very time consuming.
If I can save PC, in the next interrupt call I can continue the routine very quickly.
Isn't so?
Banfa 9,065
Expert Mod 8TB
If I can save PC, in the next interrupt call I can continue the routine very quickly.
Isn't so?
For the ARM platform I would definately expect you to have a way to write assembler instructions but it may require an assembler file (i.e. write 2 functions 1 to read the pc 1 to write it). You will need to check your toolset documentation.
What you propose to do may work, on the other hand it may cause everything to fall over in a big heap.
In assembly, yes, this is do-able. Anytime an interrupt is called, it automatically pushes the registers and PC onto the stack. In order to pop the same information off of the stack, you should have an assembly command that "Returns from interrupt".
From the limited assembly programming I have done, RETI was the return from interrupt command, that I don't think I ever needed.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Vikrant |
last post by:
Friends,
Due an application (old) install program problem, Under AIX I could
only create DB2 instance, I could also catalog it. Its complex
application and I am not expert in creating full...
|
by: Daniel Vallstrom |
last post by:
I'm having problems with inconsistent floating point behavior
resulting in e.g.
assert( x > 0.0 && putchar('\n') && x == 0.0 );
holding. (Actually, my problem is the dual one where I get...
|
by: Arne |
last post by:
A lot of Firefox users I know, says they have problems with validation
where the ampersand sign has to be written as & to be valid. I don't
have Firefox my self and don't wont to install it only...
|
by: Irene |
last post by:
Hello all!
I'm creating a web site in ASP.NET (VB.NET). One of the requirements was to
allow users to create orders going through several steps. A must have is to
have an option to save the work...
|
by: Aenima1891 |
last post by:
write a program that replaces strings of blanks by the minimum number
of blanks to space to the next tab stop.
#include <stdio.h>
#define TABSIZE 8
int main()
{
int counter, c;
|
by: Jonathan Pritchard |
last post by:
I know this is a simple problem, but I've just included this in the
title because it explains what my program tries to do.
The following does not work, it for someone reason does not want to...
|
by: fdu.xiaojf |
last post by:
Hi,
I have a program which will continue to run for several days. When it is
running, I can't do anything except waiting because it takes over most
of the CUP time.
Is it possible that the...
|
by: pkirk25 |
last post by:
I wonder if anyone has time to write a small example program based on
this data or to critique my own effort?
A file called Realm List.html contains the following data:
Bladefist-Horde...
|
by: 1388-2/HB |
last post by:
I have a page with a significant number of dynamically created radio
buttons, checkboxes and textboxes.
When a user is presented with this form and subsequently fills a bunch of
stuff out, when...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |