A89: Re: TIOS functions disobey register conventions!


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

A89: Re: TIOS functions disobey register conventions!




Hi!

| I have just discovered that some TIOS functions don't obey they standard
| register conventions (allowing changes only to D0/D1/D2/A0/A1).  In
| particular, OSContrastUp trashes the upper word of the D4 register.

That sucks!

| I only actually verified this under AMS version 1.05 and 2.04, though I
| have a bad feeling the same thing will happen on other versions as well.

Probably, and it won't matter anyway.  If it does this on one AMS version
only, it is already a problem that has to be solved.

| I uncovered this while working on a program in TIGCC which contained a
| contrast changer.  It crashed for no apparent reason, but after examining
| further, I discovered the TIOS was the problem (since only the upper words
| are trashed, if the registers were only keeping integers, the problem
| might be unnoticd).

This is actually possible to do in the compiler at a global level, but not
desirable, of course.

| I'm not exaclty sure how many TIOS functions do stuff like this, but it is
| certainly an annoying problem for only one function.

Maybe if it's only the contrast functions, Zeljko could make interface
macros, something like this:

#define OSContrastUp() \
do { \
  register long dummy asm("d4") __attribute__ ((unused)); \
  InternalOSContrastUp(); \
} while (0)

Zeljko, what do you think?  BTW: Is it possible to use the parentheses after
OSContrastUp like that?

| This seems to make no sense, until of course you consider
| that the OS contrast adjust function trashes the upper half of the D4
| register, a very annoying side effect, to say the least (as it can
| sometimes cause crashes!)

We should check this for other functions as well.  I'll check it for some,
but I certainly can't do it for a lot of them.  We should also check other
registers as well, I think.

Bye,
Sebastian Reichelt




References: