defining registers in c
defining registers in c
I use c for my os and sometimes have to use the registers in my code, I know I can use asm(); but I want to know how I can define them for use in c code. Example: Say I want to have an if statement: if ( reg_eax == 0 ) { do this }. I know Linux defines at least the segment registers becaouse I downloaded the linux kernel and looked in linux/arch/x86/boot/boot.h and saw that it defined the registers somehow but I can't make sense of it.
Re: defining registers in c
Google says:
Code: Select all
register int *foo asm ("eax");
Re: defining registers in c
So that wil define foo as constant poiter to eax register like in an if statement? didn't you mean asm("%eax");.Code: Select all
register int *foo asm ("eax");
Re: defining registers in c
If you do it that way you are slicing sushime with katana. You will volatile the C specification with has no concept of x86 registers.huh wrote:I use c for my os and sometimes have to use the registers in my code
I suggest inline assembly or separate assembly stub to manipulate registers.
Re: defining registers in c
Why don't you give it a try, and find out? That also goes for using Google.