first i thought about a cpuid-like-instruction, but didn't find anything in the manuals... then i thought it's possible to measure the performance to determine which cpu the code is running on, but that's too complicated.

so i thought... each processor has features the other doesn't have, so i
tried this:

Code:
var
  Dummy : pcuint16 = pointer($06800000);
  WhichAmI : Boolean; // True = ARM9

begin
  Dummy[0] := 2106;

  If (Dummy[0] = 2106) then WhichAmI := True
     Else WhichAmI := False;
End.
You see, the ARM7 can't write to bank A of VRAM, but it doesn't give
any error ... it just doesn't write there... so it's easily determinable
what CPU is running the code ... do you understand? :D

btw, tested in no$gba and on real hardware ... and worked.

does this help you?

edit: the actual code i've used is different. because i can't do printf on
arm7 i had to use ipc to tell arm9 if arm7 found itself, but as you want
the program to know on which CPU it's running, the code above should
give you what you need. :)