Basic System Problem Analysis - August 2003
57
Case Study: SA663 continued
Yup, it did save the file number in the stack. Well, to be honest we would have to assume
that the $d is the file number just by looking at the value in PSP-$24. If we wanted to be
absolutely certain it is (and absolute certainty is handy a lot of the time) then we would
need to examine the code that fclose_nm executed to see if it did spill the file number
parameter to the stack.
01163d9c fclose_nm 6bc23fd9 STW r2,-20(sr0,r30)
01163da0 fclose_nm+$4 6fc30500 STWM r3,640(sr0,r30)
01163da4 fclose_nm+$8 6bc43b09 STW r4,-636(sr0,r30)
01163da8 fclose_nm+$c 6bc53b11 STW r5,-632(sr0,r30)
01163dac fclose_nm+$10 6bc63b19 STW r6,-628(sr0,r30)
01163db0 fclose_nm+$14 6bc73b21 STW r7,-624(sr0,r30)
01163db4 fclose_nm+$18 6bc83b29 STW r8,-620(sr0,r30)
01163db8 fclose_nm+$1c 6bc93b31 STW r9,-616(sr0,r30)
01163dbc fclose_nm+$20 67da3abd STH r26,-674(sr0,r30)
01163dc0 fclose_nm+$24 67d93ab5 STH r25,-678(sr0,r30)
01163dc4 fclose_nm+$28 67d83aad STH r24,-682(sr0,r30)
01163dc8 fclose_nm+$2c 67d73aa5 STH r23,-686(sr0,r30)
Yes, the file number really was saved to the stack frame. Note that a store half-word was
used since the file number is a 16 bit value.
The value of R26 should be stored to PSP-$24 so if we want to check we can do the
math:
$243 ($70) nmdat > =#674-#640
$22
The location it was saved to, SP-#674 less the size of the stack frame, #640 results in the
value hexadecimal 22. Since it is a half word quantity and is aligned in the right 16 bits of
the value it should really be saved at PSP-$22 and that’s exactly where it is.
VIRT $866.4185453c $ 4185000d
-- SP-$21
-- SP-$22
-- SP-$23
-- SP-$24