i have searched for a cpuid-like instruction, but didn't find one (which doesn't
say anything, because i was short on time).
if i give you code to determine which processor is running the current
application, would that help?
i have searched for a cpuid-like instruction, but didn't find one (which doesn't
say anything, because i was short on time).
if i give you code to determine which processor is running the current
application, would that help?
i've done it.
it's really easy :D
i've got environment-aware programs now (well ... at least it sounds good xD)
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:
You see, the ARM7 can't write to bank A of VRAM, but it doesn't giveCode:var Dummy : pcuint16 = pointer($06800000); WhichAmI : Boolean; // True = ARM9 begin Dummy[0] := 2106; If (Dummy[0] = 2106) then WhichAmI := True Else WhichAmI := False; End.
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. :)
are you making fun of me? :scratch:
i'm sorry, i'm really not used to forums :D
thank you :D
thank you :D
i hope legolas can use this :)
(and yeah, i forgot to turn it on. i normally don't like them, but the scratching
one was really appropriate :D)
The idea beyond your workaround is very good and seems that work fine :clap:
Btw, this is my modified function I have added to the rtl:
[pascal]{ CPU detecting function (thanks to 21o6):
----------------------------------------
"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"}
function IsARM9(): boolean;
var
Dummy : pword absolute $06800000;
begin
Dummy^ := $C0DE;
IsARM9 := Dummy^ = $C0DE;
end;
...
if IsARM9 then
fpc_cpucodeinit;[/pascal]
(Please, note the g33k value :cylon: :mrgreen
\:D/
thank you for quoting me :D
using $C0DE was a great idea :DD
Bookmarks