forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ME Questions

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
dega



Joined: 24 Oct 2006
Posts: 14

PostPosted: Sat Dec 23, 2006 9:33 am    Post subject: ME Questions Reply with quote

I'm just starting out with MIPS assembly so I decided to give programming the ME a try. I tried altering the MIPS code for the ME sample that comes with the SDK, but the sample stops working as planed.

Here is the sample's code:
Code:

   .set noreorder

   .global me_run
   .global me_end

   .ent me_run

me_run:
   li $2, 0xbfc00060
   li $3, 0
loop:
   addiu $3, $3, 1
   sw $3, 0($2)
   b loop
   nop
me_end:

   .end me_run



The two lines I focused on were "b loop" and the "nop" after it.
I have tried getting rid of the nop to see what happens, and I have also tried changing the "b loop" to "j loop" (I have tried both at the same time too). However, after I make these alterations, the number that the C program watches at 0xBFC00060 no longer increments.

So my questions are:
Is the no-operation after the branch needed, and if so why?
Why doesnt the unconditional jump work while the unconditional branch does?

Thanks!
- dega[/code]
Back to top
View user's profile Send private message AIM Address
adrahil



Joined: 16 Mar 2006
Posts: 277

PostPosted: Sat Dec 23, 2006 1:06 pm    Post subject: Reply with quote

Quote:
Is the no-operation after the branch needed, and if so why?

It is the "delay" instruction. It is executed "while" it is jumping to the new location...
Quote:
Why doesnt the unconditional jump work while the unconditional branch does?

It just does :3 You should read a good R4000 assembly reference to find the answer to the questions like these...
Back to top
View user's profile Send private message
dega



Joined: 24 Oct 2006
Posts: 14

PostPosted: Sat Dec 23, 2006 3:20 pm    Post subject: Reply with quote

Quote:

It is the "delay" instruction. It is executed "while" it is jumping to the new location...


That makes sense, thanks.

Quote:

It just does :3

My favorite reason for how certain things work in programming lol :)
Back to top
View user's profile Send private message AIM Address
Saotome



Joined: 03 Apr 2004
Posts: 182

PostPosted: Sat Dec 23, 2006 8:07 pm    Post subject: Reply with quote

adrahil wrote:
It just does :3...

It does because "b" uses a relative branch address while "j" uses an absolute address, and as far as I remember, in the sample the ME code is copied to the ME memory before running it, so the absolute address would be different from the original location after copying...
_________________
infj
Back to top
View user's profile Send private message
adrahil



Joined: 16 Mar 2006
Posts: 277

PostPosted: Sun Dec 24, 2006 2:28 pm    Post subject: Reply with quote

Saotome wrote:
adrahil wrote:
It just does :3...

It does because "b" uses a relative branch address while "j" uses an absolute address, and as far as I remember, in the sample the ME code is copied to the ME memory before running it, so the absolute address would be different from the original location after copying...

Thanks for lighting my ignorance on that point :P
Back to top
View user's profile Send private message
Saotome



Joined: 03 Apr 2004
Posts: 182

PostPosted: Sun Dec 24, 2006 8:56 pm    Post subject: Reply with quote

you're welcome ;)
_________________
infj
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group