Hi,

This is a question comparing assembler macros for the sun studio compiler 
versus gcc, so I hope this is the right forum for this question. I don't know 
were I should turn in other case.

I'm trying to define a macro that can be used inside the kernel code (disp.c). 
I need to tell the compiler which registers I'm using so that I don't overwrite 
already used registers.

The macro itself is simple:
I need to pass the third argument (the value of a variable) to register g2, the 
second argument (the value of another variable) to register g1, and finally a 
integer value to the sethi instruction.

I would like to define this assembler macro so that it can be accepted by the 
sun studio compiler. So far, I have used a gcc-style macro with input, output, 
and a clobber list. This has forced me to change the compiler from the sun 
studio compiler to gcc. I would like to avoid this switch. Still, even though I 
used the following macro and compile successfully with gcc, the kernel crashes 
upon boot complaining about a null pointer, so I guess the macro is not 
entirely correct.

#define MAGIC_QL(n, id, ql) do {  \
        __asm__ ("mov %0, %%g1\n\t" \
                 "mov %1, %%g2\n\t" \
                 "sethi " #n ", %%g0" : : "r"(id), "r"(ql) : "%g1", "%g2" ); \
} while (0)


Is it possible to define a macro (as above) that can be accepted by the sun 
studio compiler? Secondly, if anyone finds an error with the original macro 
code itself i would be happy to hear about it.

Regards,
Mladen
--
This message posted from opensolaris.org

Reply via email to