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 

load delay

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



Joined: 23 Jul 2005
Posts: 119

PostPosted: Wed May 24, 2006 9:18 pm    Post subject: load delay Reply with quote

Hello, i would like to know why this small code works :

Code:

.set noreorder

   .global   func
   .ent   func

func:

   lw $a2, 0x0($a0)
   sw $a2, 0x0($a1)

   jr $ra
   nop

   .end func


In the mips documentation, load in memory uses delay : "you *must* have an instruction following a load that does not use the result of the load".

However, this code uses the result of the load immediately after and he works.

Is what it is because the compiler arranges the code ? (even with .set noreorder directive ?)
Back to top
View user's profile Send private message
ector



Joined: 12 May 2005
Posts: 195

PostPosted: Wed May 24, 2006 9:39 pm    Post subject: Reply with quote

No modern MIPS CPU:s that I know of have this limitation. They all added forwarding, fixing this problem, in something like 1992. What documentation are you reading?
_________________
http://www.dtek.chalmers.se/~tronic/PSPTexTool.zip Free texture converter for PSP with source. More to come.
Back to top
View user's profile Send private message
BlackDiamond



Joined: 02 Jul 2005
Posts: 16
Location: Paris, FRANCE

PostPosted: Wed May 24, 2006 10:12 pm    Post subject: Reply with quote

Modern MIPS CPUs can (partially) stall the pipeline and wait for the result to be availiable. So no interlaced instruction is needed but the delay is still here.
Back to top
View user's profile Send private message
groepaz



Joined: 01 Sep 2005
Posts: 305

PostPosted: Wed May 24, 2006 10:20 pm    Post subject: Reply with quote

conclusion, make it

Code:
 
   lw $a2, 0x0($a0)
   jr $ra
   sw $a2, 0x0($a1)


:)
_________________
http://www.hitmen-console.org
http://hitmen.c02.at/files/yapspd/
Back to top
View user's profile Send private message Visit poster's website
BlackDiamond



Joined: 02 Jul 2005
Posts: 16
Location: Paris, FRANCE

PostPosted: Thu May 25, 2006 12:36 am    Post subject: Reply with quote

yep, got rid of the 2 wasted cycles :)
Back to top
View user's profile Send private message
johnmph



Joined: 23 Jul 2005
Posts: 119

PostPosted: Thu May 25, 2006 12:58 am    Post subject: Reply with quote

Thanks all.

groepaz wrote:
conclusion, make it

Code:
 
   lw $a2, 0x0($a0)
   jr $ra
   sw $a2, 0x0($a1)


:)


yes, it's the code that i will use.
Back to top
View user's profile Send private message
johnmph



Joined: 23 Jul 2005
Posts: 119

PostPosted: Sun May 28, 2006 10:01 pm    Post subject: Reply with quote

one more question :

write in memory has also a delay like read ?
In documentation, it talks about load only.

Thanks
Back to top
View user's profile Send private message
johnmph



Joined: 23 Jul 2005
Posts: 119

PostPosted: Mon May 29, 2006 5:58 am    Post subject: Reply with quote

johnmph wrote:
one more question :

write in memory has also a delay like read ?
In documentation, it talks about load only.

Thanks


oups, stupid question.

Even if write has a delay, registers are not affected and even if i read memory just after having written this memory, load creates a delay, thus no problem ;-)
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