PHO - Pokémon Hackers Online
Go Back   PHO - Pokémon Hackers Online > Discussion Board > Archive

Notices

Archive Old threads that serve no purpose are here.

 
 
Thread Tools Display Modes
Old 7th November 2013, 02:13 PM   #11
Diegoisawesome
Oh god the bees
Ex-Staff
 
Diegoisawesome's Avatar
 
Join Date: Jul 2013
Location: :noitacoL
Age: 21
Posts: 60
Diegoisawesome
Default

Quote:
Originally Posted by Full Metal ★ View Post
that's...what I was saying... ;_;
What you said was that you could replace the bl with the ldr r1 and bx r1 and it would work, but I was saying that that wouldn't work; you'd need to delete the push {lr} and pop {pc} or else the stack would get out of sync.
Diegoisawesome is offline  
Sponsored Links
Old 7th November 2013, 03:45 PM   #12
Full Metal ★
Unstable?
Ex-StaffPHO VIP
 
Full Metal ★'s Avatar
 
Join Date: Oct 2012
Posts: 312
Full Metal ★ Full Metal ★
Default

If you don't push your link register in the outer code and pop it, then you'll never return execution control to your calling code. which is generally a bad idea. Why would you do that, it doesn't even almost make sense.

Quote:
BLX may not use R15. BLX saves the return address as LR=PC+3 (with thumb bit).
Using BLX R14 is possible (sets PC=Old_LR, and New_LR=retadr).
using blx just assumes that the function / code you're calling utilizes the same push lr / pop pc calling convention that we do -- which most of the code I've seen does.

Code:
.thumb
.align 2
push {lr}
ldr r0, SCRIPT_ADDRESS
ldr r1, SCRIPT_EXECUTOR
Bx r1//really. it will work fine. i promise.
pop {pc}

.align 2
SCRIPT_ADDRESS: .word 0x081624F5 / / Here is where you define your script offset.
SCRIPT_EXECUTOR: .word 0x08069AE5 / / This is the routine that executes the scripts. Offset +1
*edit*

Also I just realized that I misread what you were saying in the first response.
__________________

★ full metal.

#busy

Last edited by Full Metal ★; 7th November 2013 at 03:48 PM.
Full Metal ★ is offline  
Old 7th November 2013, 04:06 PM   #13
Diegoisawesome
Oh god the bees
Ex-Staff
 
Diegoisawesome's Avatar
 
Join Date: Jul 2013
Location: :noitacoL
Age: 21
Posts: 60
Diegoisawesome
Default

Quote:
Originally Posted by Full Metal ★ View Post
If you don't push your link register in the outer code and pop it, then you'll never return execution control to your calling code. which is generally a bad idea. Why would you do that, it doesn't even almost make sense.
I think you're getting confused between bx and blx here. bx writes nothing to the link register; it just branches to the routine at the address. And while not having a push and pop wouldn't exactly be a good way to write it, it would actually work correctly since in lr would still be the original routine when branching to the script handler (in this circumstance) and the pop in the script handler would return to the original routine and bypass what we wrote.
Diegoisawesome is offline  
Old 7th November 2013, 04:52 PM   #14
Full Metal ★
Unstable?
Ex-StaffPHO VIP
 
Full Metal ★'s Avatar
 
Join Date: Oct 2012
Posts: 312
Full Metal ★ Full Metal ★
Default

Quote:
Originally Posted by diegoisawesome View Post
I think you're getting confused between bx and blx here. bx writes nothing to the link register; it just branches to the routine at the address. And while not having a push and pop wouldn't exactly be a good way to write it, it would actually work correctly since in lr would still be the original routine when branching to the script handler (in this circumstance) and the pop in the script handler would return to the original routine and bypass what we wrote.
Ah, that makes sense. Sorry for being a huge durp. XD
__________________

★ full metal.

#busy
Full Metal ★ is offline  
 

Tags
asm, mode, run, scripts, thumb, [Tutorial]

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:54 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc. User Alert System provided by Advanced User Tagging (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Pokémon characters and images belong to Pokémon USA, Inc. and Nintendo.
Pokémon Hackers Online (PHO) is in no way affiliated with or endorsed by Nintendo LLC, Creatures, GAMEFREAK inc,
The Pokémon Company, Pokémon USA, Inc., The Pokémon Company International, or Wizards of the Coast.
All forum/site content (unless noted otherwise) and site designs are © 2006-2013 Pokémon Hackers Online (PHO).
Green Charizard Christos TreeckoLv100

"Black 2" by ARTPOP. Kyurem artwork by XOUS.

no new posts