Extracting nLoop field

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
tumnes
Posts: 23
Joined: Fri Sep 17, 2004 12:02 pm
Contact:

Extracting nLoop field

Post by tumnes »

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.
b0rje
Posts: 7
Joined: Thu May 12, 2005 6:58 pm

Post by b0rje »

iaddiu takes a 15bit arg (Imm15). your code seems correct.
tumnes
Posts: 23
Joined: Fri Sep 17, 2004 12:02 pm
Contact:

Post by tumnes »

Ah, yes thank you. I missed the extra 4 bits to the in the diagram.
Post Reply