Here it is given that no spilling can be done so we can’t the result in the memory.
now i am picking new register only when it requires.
we want to multiply p and q both are in memory so we load them both in register from memory.
Load R1,p (R1← p)
Load R2,q (R2-<q)
mul R1,R1,R2(R1← R1*R2)
now we need to add these value with t.
now t is in memory so we need to bring it back and we have R2 empty.
Load R2,t (R2← t)
now just add them both.
add R1,R1,R2 (R1← R1+R2)
now i need the value of u but R1 store the value of the sum and R2 store t which need next operation so we need to assign another register R3 for u.
load R3,u (R3<-u)
sub R3,R2,R3 (R3← R2-R3)
now we only have R2 left to store the value of r and we need another register for s as R1,R2 store the result of our calculation which needed in future.
Load R2,r (R2<-r)
Load R4,s (R4<-s)
Hence answer is 4.