[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] CPU detection broken



Hello.

The current MiNTLib has a mechanism for detecting if the actual CPU (from cookies) is compatible with the program being run. If it is not the case, it tries to display a message like "this program requires an m68020 cpu or higher!".

But it does not work. If I compile a "Hello, World!" with -m68020-60 then I run it on a plain ST, I get 4 bombs instead of the expected message :-(

Basically, the CPU check occurs *after* using special CPU features, so it crashes before reaching the test (actually, with an extb.l instruction generated inside parseargs()).

The only solution is to use only assembly instructions compatible with all CPUs (including ColdFire) before the CPU check. Since GCC cannot produce such code, it has to be written manually in assembly. Fortunately, it is not complicated.

So I propose to write a check_cpu() function fully in compatible assembly, and to call it form crt0.S as soon as possible. It will probably require to rewrite the Getcookie() and get_sysvar() functions in assembler, too.

I'm going to make a patch for that.

If someone has a better idea, please tell it.

--
Vincent Rivière