Search the web
Sign In
New User? Sign Up
gbadev
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Self-modifying code branching problem   Message List  
Reply | Forward Message #13431 of 15019 |
RE: [gbadev] Self-modifying code branching problem

You know that code won't work on any ARM chip with a cache? :) If you ever
want it to run on the GP32 you'll have to be aware of this.

-----Original Message-----
From: James Daniels [mailto:james.daniels@...]
Sent: 29 November 2002 23:39
To: gbadev@yahoogroups.com
Subject: Re: [gbadev] Self-modifying code branching problem


Hi all,

Just to let you know, I solved the problem by hacking the opcodes as
follows: (it probably won't work for negative offsets though)

...

_stored_branch: .word 0xea000000 +
((target_label-stored_branch_moved_here)/4)-2

...

ldr r10,_stored_branch
str r10,_stored_branch_moved_here

...

stored_branch_moved_here:
mov r0,r0 @ may be overwritten by _stored_branch

...

target_label:

...

It's a bit iffy, but it gets the job done.
--
Cheers,
James.

/\ apex James Daniels
//\\ designs james.daniels@...
//__\\ http://www.apex-designs.net






Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





Mon Dec 2, 2002 11:26 am

fnagaton
Offline Offline
Send Email Send Email

Forward
Message #13431 of 15019 |
Expand Messages Author Sort by Date

Hi, I've run into a slight problem when trying to change code to a branch. This is because branches are relative to the PC so I need to specify what address...
James Daniels
j_r_daniels
Offline Send Email
Nov 29, 2002
10:40 am

try a bx instead of a b branch_addr: .long 0 ... <code> bt2: <other code> to set the target ldr r0, =bt1 str r0, branch_addr if you move the code from bt2 to...
Mike Wynn
mike.wynn@...
Send Email
Nov 29, 2002
3:18 pm

Hi Mike, ... Thanks, but that would use an extra register. ... Note that you should use adr whereever possible as it's faster and uses less IWRAM. -- Cheers, ...
James Daniels
j_r_daniels
Offline Send Email
Nov 29, 2002
8:09 pm

Hi all, Just to let you know, I solved the problem by hacking the opcodes as follows: (it probably won't work for negative offsets though) ... _stored_branch:...
James Daniels
j_r_daniels
Offline Send Email
Nov 29, 2002
11:57 pm

You know that code won't work on any ARM chip with a cache? :) If you ever want it to run on the GP32 you'll have to be aware of this. ... From: James Daniels...
Martin Piper
fnagaton
Offline Send Email
Dec 2, 2002
12:02 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help