Writing exceptions for the 8260, and I want access to the program counter.
I think I can get access to all other registers, but I don't know how to get
access to the program counter.
Thanks in advance,
Derek
There is no pc register. When handling an exception you can examine SRR0 to
determine the source of the exception. To get hold of a current pc value
you can play games with the branch and link instructions (branch to next
address) so that the LR is filled with the next pc.
--
--------------------------------------------------------------------------------
Lee Douglas Gibbons
ldgi...@avaya.com
Doug Gibbons <ldgi...@avaya.com> wrote in message
news:3A26AC96...@avaya.com...
> There is no pc register.
There is a pc register, although it's not accessable (the ways to findout / modify
the pc is either by
changing srr0 or lr as you said, however when changing lr keep in mind that you
need to back up
the old lr or you'll easially get caugth in a loop).
However here's a little snippet I used for a little program...
asm long getpc()
{
mflr r4;
bl a:
mflr r3;
mtlr r4;
a: blr
}
something like this works pretty good for system level code, although, you need to
make sure
that this function gets inlined otherwise it will return the same pc eachtime you
call it.
/Fredrik Andersson
Shouldn't that be:
asm long getpc()
{
mflr r4;
bl a:
a: mflr r3;
mtlr r4;
blr
}
--
Kenneth Dyke, k...@jumpgate.com (personal), kd...@apple.com (work)
Sr. Mad Scientist, MacOS X OpenGL Group, Apple Computer, Inc.
C++: The power, elegance and simplicity of a hand grenade.
"Kenneth C. Dyke" wrote:
> >asm long getpc()
> >{
> > mflr r4;
> > bl a:
> > mflr r3;
> > mtlr r4;
> >a: blr
> >}
>
> Shouldn't that be:
> asm long getpc()
> {
> mflr r4;
> bl a:
> a: mflr r3;
> mtlr r4;
> blr
> }
right, I didn't notice this, although both works except that the first
verison takes slightly longer.
(however it was ment to look as your version does)
/Fredrik Andersson
Fredrik Andersson <an...@digithought.net> wrote in message
news:3A2A62E2...@digithought.net...
>
>
> "Kenneth C. Dyke" wrote:
>
> > >asm long getpc()
> > >{
> > > mflr r4;
> > > bl a:
> > > mflr r3;
> > > mtlr r4;
> > >a: blr
> > >}
> >
> > Shouldn't that be:
> > asm long getpc()
> > {
> > mflr r4;
> > bl a:
> > a: mflr r3;
> > mtlr r4;
That's a Macintosh question, not a PowerPC question. Ask in a Mac
newsgroup whether OS X can enable instruction fetches from data
segments.
-=- Andrew Klossner (and...@teleport.com)
So sorry, I looked over some messages here and saw the Mac mentioned and PPC
assembler. I figured someone here may know. I didn't mean to intrude on
your club.
Pete
> I am working on porting some old code from the current Macintosh OS
> to OS X. It is a very big project and at the heart of it is a bunch
> of assembler code that is self modifying. ...
> The problem is that I now want to run this on Mac OS X and the code
> space is read only. Now I know I can set up data space in the
> assembler code, but the real question is can I then execute the code
> I write into the data space? Any suggestions or pointers would be
> helpful. I can send some code snippets if that helps.
I don't know the answer, but is MakeDataExecutable() available in
Carbon? Perhaps someone knows on c.s.m.p.h.
____________________________________________________________________
TonyN.:' tony...@shore.net
'
I am working on porting some old code from the current Macintosh OS to OS X.
It is a very big project and at the heart of it is a bunch of assembler code
that is self modifying. The code is used to analyze data in real time and
so the programmer put together a little internal compiler which uses little
code templates, modifies them, and then writes them out to the middle of an
existing routine. This was all done over 10 years ago, first on 68K and
them PPC assembler and all of the original programmers are gone.
The problem is that I now want to run this on Mac OS X and the code space is
read only. Now I know I can set up data space in the assembler code, but
the real question is can I then execute the code I write into the data
space? Any suggestions or pointers would be helpful. I can send some code
snippets if that helps.
Pete
>> The problem is that I now want to run this on Mac OS X and the code
>> space is read only. Now I know I can set up data space in the
>> assembler code, but the real question is can I then execute the code
>> I write into the data space? Any suggestions or pointers would be
>> helpful. I can send some code snippets if that helps.
> I don't know the answer, but is MakeDataExecutable() available in
> Carbon? Perhaps someone knows on c.s.m.p.h.
I just looked it up, and yes it is in Carbon. Thanks this is just the
pointer I needed.
Pete