ME Questions

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
dega
Posts: 14
Joined: Tue Oct 24, 2006 1:22 pm

ME Questions

Post by dega »

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: Select all

	.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]
adrahil
Posts: 274
Joined: Thu Mar 16, 2006 1:55 am

Post by adrahil »

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...
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...
User avatar
dega
Posts: 14
Joined: Tue Oct 24, 2006 1:22 pm

Post by dega »

It is the "delay" instruction. It is executed "while" it is jumping to the new location...
That makes sense, thanks.
It just does :3
My favorite reason for how certain things work in programming lol :)
User avatar
Saotome
Posts: 182
Joined: Sat Apr 03, 2004 3:45 am

Post by Saotome »

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
adrahil
Posts: 274
Joined: Thu Mar 16, 2006 1:55 am

Post by adrahil »

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
User avatar
Saotome
Posts: 182
Joined: Sat Apr 03, 2004 3:45 am

Post by Saotome »

you're welcome ;)
infj
Post Reply