| View previous topic :: View next topic |
| Author |
Message |
dega

Joined: 24 Oct 2006 Posts: 14
|
Posted: Sat Dec 23, 2006 9:33 am Post subject: ME Questions |
|
|
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 |
|
 |
adrahil
Joined: 16 Mar 2006 Posts: 277
|
Posted: Sat Dec 23, 2006 1:06 pm Post subject: |
|
|
| 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 |
|
 |
dega

Joined: 24 Oct 2006 Posts: 14
|
Posted: Sat Dec 23, 2006 3:20 pm Post subject: |
|
|
| Quote: |
It is the "delay" instruction. It is executed "while" it is jumping to the new location... |
That makes sense, thanks.
My favorite reason for how certain things work in programming lol :) |
|
| Back to top |
|
 |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Sat Dec 23, 2006 8:07 pm Post subject: |
|
|
| 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 |
|
 |
adrahil
Joined: 16 Mar 2006 Posts: 277
|
Posted: Sun Dec 24, 2006 2:28 pm Post subject: |
|
|
| 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 |
|
 |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Sun Dec 24, 2006 8:56 pm Post subject: |
|
|
you're welcome ;) _________________ infj |
|
| Back to top |
|
 |
|