Hi,
I'd like to know how can i know at run time my kernel's size.
If i want want to use asm with intel sintaxi in gcc, what should i do?
thanks for all.
Some questions
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Some questions
http://sources.redhat.com/ml/binutils/2 ... 00268.html should interrest you ...The easiest solution is to insert symbols like _start_kernel (before anything else) and _end_kernel in your linker script (just after everything else) and then use _end_kernel - _start_kernel to know the kernel size at runtimeBAlroj wrote: I'd like to know how can i know at run time my kernel's size.
If i want want to use asm with intel sintaxi in gcc, what should i do?
Re:Some questions
Hi pype,
thanks for the answer.
this is my funtion now:
unsigned int ReadCr0()
{
unsigned int cere=0;
asm( ".intel_syntax noprefix\n" );
asm( "\tmov cere, cr0\n");
return cere;
}
Gcc tells me that there's not an movl instruction. is still searching at$t syntax. I'm triying to use intel asm syntax in my c code. i know i could do it with nasm and link them after.. but i'm interested on that way.
Thanks for all.
thanks for the answer.
this is my funtion now:
unsigned int ReadCr0()
{
unsigned int cere=0;
asm( ".intel_syntax noprefix\n" );
asm( "\tmov cere, cr0\n");
return cere;
}
Gcc tells me that there's not an movl instruction. is still searching at$t syntax. I'm triying to use intel asm syntax in my c code. i know i could do it with nasm and link them after.. but i'm interested on that way.
Thanks for all.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Some questions
there's a trick here: the control registers (CR0, CR1, CR2 and CR3) may not be moved to something else than a generic register (eax, ebx, ecx, edx, ebp, esp, esi or edi). Thus if you want to get the content of the CR0 register in a C variable, you'll need to use
Note that i'm unsure GCC could have generated the proper code for "mov cere,eax", as "cere" is not really a label (until defined static): it's a location on the stack (something like [ebp-4]) ... Never really tried it, though, so it might work anyway.
Code: Select all
int cere;
asm volatile("mov eax,CR0":"=a"(cere));
Re:Some questions
Thanks again pype for answering.
I'll try it this night, now i'm at work
One last question, in this line:
thanks for all.
I'll try it this night, now i'm at work
One last question, in this line:
what is =a(cere) for? ( well, i undertand what is for, but don't know why to put an =a, will be the same =b? or there is a reason?)asm volatile("mov eax,CR0":"=a"(cere));
thanks for all.
Re:Some questions
For use of intel's asm syntax in GCC inline assembly, check if your gcc supports the -masm option
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Some questions
the full answer is in "info gcc" -> "extended inline assembly" documentation. briefly, the full asm command looks likeBalroj wrote: One last question, in this line:what is =a(cere) for?asm volatile("mov eax,CR0":"=a"(cere));
asm(<asm text>:[output specifiers][:[input specifiers][:<clobber specifiers>]]);
thus here, we have <asm text> :: "mov eax,CR0" and <output specifiers> :: "=a"(cere).
The '=' sign is mandatory for output specifiers and the letter after it defines a constraint on the operand that can be used to hold the result. the 'a' letter means i want the compiler to assume the value of eAx should be stored in cere after the asm commands completes. if i had used "=b", the content of ebx would have been used, but this would have been plain silly as there's nothing interresting in ebx so far ...
in order to have easier optimizable code (for the compiler), i could have used "=g" to let it select the register, but this then means the asm command must be parametric:
Code: Select all
asm volatile("mov %0,CR0":"=g"(cere));