Page 1 of 1

Extracting nLoop field

Posted: Sun Mar 19, 2006 4:31 am
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.

Posted: Tue Mar 21, 2006 3:33 am
by b0rje
iaddiu takes a 15bit arg (Imm15). your code seems correct.

Posted: Tue Mar 21, 2006 6:31 am
by tumnes
Ah, yes thank you. I missed the extra 4 bits to the in the diagram.