Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 6th, 2010, 5:40 AM   #1
539
Newbie
 
Join Date: May 2010
Posts: 4
Rep Power: 0 539 is an unknown quantity at this point
[MIPS] J, JAL, and JR commands

J Jump
Jal Jump and Link
Jr Jump Register

Jump:

Jumps to the target offset, a delay slot is needed.
Syntax:

J $Offset
Noop // This is the delay slot

Best used to call subroutines.

Jump and Link:

Executes the next line, then jumps to the target offset, then changes the return value (ra) value so it jumps to the offset after the delay slot.
Syntax:

Jal $Offset
Noop // Delay slot, so when the next line is executed nothing happens
{Now here is where the ra will jump to}

Best used for function calls because after the function is done it will return to the offset after the noop.

Jump Register:

Jumps to the offset stored in a register. A delay slot is needed.
Syntax:

Lui t0, $0880 // Loads 0880 into t0, now t0 holds the offse 08800000
Jr t0 // Jumps to the offset 08800000
Noop

Now if you are confused why we didn't do this to load the offset:

Lui t0, $0880
Lw t0, $0000(t0)

Is because the LUI command loads 16 bits into a register and the right 16Bits are zeros. So lui t0, $0880 will load the offset 08800000 into the register t0

So the syntax will jump to the offset 08800000

Tips for these commands:

Use J for calling subroutines
Use Jal for calling functions
Use Jr for ending a subroutine by jumping to the return address (ra)
Always use a delay slot (A noop on the next offset) when using Jump commands

END TUTORIAL
539 is offline   Reply With Quote
Old May 6th, 2010, 9:16 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 8,368
Rep Power: 19 DaWei will become famous soon enoughDaWei will become famous soon enough
Re: [MIPS] J, JAL, and JR commands

This "tutorial" is just as good as the C++ tutorial you posted. That is to say, it's a piece of doo-doo. The operand for J and JAL, for instance, have nothing to do with a delay. They are in fact the basis for constructing the address to which one wishes to branch. JAL puts a return address in the return address register, J does not.

Quit spreading bullchit.
__________________
Contributor's Corner:
Politically Incorrect
DaWei on Pointers
DaWei is offline   Reply With Quote
Old May 6th, 2010, 9:43 AM   #3
539
Newbie
 
Join Date: May 2010
Posts: 4
Rep Power: 0 539 is an unknown quantity at this point
Re: [MIPS] J, JAL, and JR commands

Quote:
Originally Posted by DaWei View Post
This "tutorial" is just as good as the C++ tutorial you posted. That is to say, it's a piece of doo-doo. The operand for J and JAL, for instance, have nothing to do with a delay. They are in fact the basis for constructing the address to which one wishes to branch. JAL puts a return address in the return address register, J does not.

Quit spreading bullchit.
Try writing a MIPS Subroutine with out a delay slot, it freezes, at leased in PSP Coding, which is what I learned MIPS for.
539 is offline   Reply With Quote
Old May 6th, 2010, 12:11 PM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 8,368
Rep Power: 19 DaWei will become famous soon enoughDaWei will become famous soon enough
Re: [MIPS] J, JAL, and JR commands

OK, forgive me in this instance. I thought you said the operand represented the delay slot. I will still abjure you to refrain from your "tutorials." The C++ thang was really bad. I would suggest that until you can write an accurate tutorial that covers proper usage of a language, you confine yourself to making contributions by answering questions correctly.

Quotes from reference manuals and experimental code that tromps on official definitions of defined operation are not only less than helpful, they're damaging.
__________________
Contributor's Corner:
Politically Incorrect
DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:30 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC