Jason,
The problem is that the use of the link register and pc have been
extended to determine what mode the processor should be in. By mode,
I mean THUMB or ARM (rather than supervisor etc).
If your processor is in the wrong state and it tries to execute a
command from the wrong instruciton set, then you get all sorts of
problems, Basically it tends to keep on going executing random
instructions since it is doubtfull that you'll have coded a branch by
accident!! - Or until it gets to some code which is in the correct
state... but then that wont help much either!
So if your return address is in the middle of some thumb code and
your procedure is in ARM, then the processor state must be swapped to
thumb when you return. As far as I can work out without the docs, the
command bx changes the processor state depending on the flags in the
lr. The mov command does not. So basically you need to use bx if
you're jumping back into some code which you don't know whether it's
in thumb or arm, or if you KNOW that it's in tumb or arm and your
procedure is in arm or thumb!
This means that to do an LDMFD sp!,{r0-r12,pc} or whatever your more
complicated code is, then you need to do:
LDMFD sp!,{r0-r12,lr}
bl lr
Yes it's silly, but there you go. Hope that helps.
Owain
--- In gbadev@y..., "felix_draconis" <felixd@f...> wrote:
>
> Has anyone managed to get GASS compiling and running and would have
> the time to provide a few answers to questions?
>
> I think I'm pretty close, as everything now links in and compiles
> properly, but it promptly crashes at the instruction:
>
> mov pc,lr
>
> (which I presume is trying to copy the return address for the
> function call to assembly into PC)
>
> (and yes, I can 'fix' it with bx lr, but there are more complex
uses
> of pc later on that I can't seem to correct)
>
> I know there'll likely be other problems, hence why I'm reluctant
to
> ask too many questions of the list. Searching elsewhere doesn't
seem
> to reveal any tutorials on this, or even what compiler was being
used
> at the time. I can only imagine what settings
>
> But at the same time, days of constant effort are starting to be
> tiring. ^.^
>
> Jason Emery
> World Tree Games