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 

Extracting nLoop field

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



Joined: 17 Sep 2004
Posts: 23

PostPosted: Sun Mar 19, 2006 4:31 am    Post subject: Extracting nLoop field Reply with quote

I want to extract the nloop field of a giftag on vu1 so that I know how many vertices I have to process. The nloop field is 15 bits, the 16th would be eop to indicate if this is the last gif packet. So if my giftag is located at address 0 in vu1mem, I do something like this:

iadd address, vi00, vi00
ilwr.w nLoop, (address)
iaddiu mask, vi00, 0x7FFF
iand nLoop, nLoop, mask

Now I think there is a problem here because the immediate field of iaddiu is only 11 bits and the value I am passing in is 15 bits. However vcl doesnt complain and neither does dvp-as. Am I correct to assume that it will just be cut off at the 11th bit and the results will not be as I desire? If so is there an easy way to go about this? I noticed there are other instructions with a 15bit immediate that are specifically for this sort of thing but are tied to a specific flag like status or clip.

[edit]
I guess a solution would be to just do:
iadd address, vi00, vi00
ilwr.w nLoop, (address)

if nLoop < 0 then
{
nLoop -= 1
}
for nLoop to 0, --nLoop
{
process element
}

Any input would be appreciated.
Back to top
View user's profile Send private message Visit poster's website AIM Address
b0rje



Joined: 12 May 2005
Posts: 7

PostPosted: Tue Mar 21, 2006 3:33 am    Post subject: Reply with quote

iaddiu takes a 15bit arg (Imm15). your code seems correct.
Back to top
View user's profile Send private message
tumnes



Joined: 17 Sep 2004
Posts: 23

PostPosted: Tue Mar 21, 2006 6:31 am    Post subject: Reply with quote

Ah, yes thank you. I missed the extra 4 bits to the in the diagram.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 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