How add assebly in linux kernel module program?
Hello,
I am writing a linux kernel module program on Fedora core 6 and I am wondering if anyone could tell me how to add an assembly code shown below in my program. The assembly code was written for Windows and I have no idea how to convert to Linux kernel program. #ifdef _MSC_VER Unsigned char lookKbits(char k) { _asm { mov dl, k mov cl, 16 sub cl, dl mov eax, [wordval] shr eax, cl } } Unsigned char WORD_hi_lo(char byte_high, char byte_low) { _asm { mov ah,byte_high mov al,byte_low } } #endif |
See C compiler documentation - because assembly format within C code differs on GCC/MSVC.
However you shouldn't use assembly in kernel modules - this makes modules non-portable (to other compilers and/or architectures). I recommend to use C instead, (because modern compiler can do better job optimizing code). |
It is not recommended to use assembly coding. But to answer your question, GCC follows the standard as below.
__asm__ __volatile__ (assembler template : output operands : input operands : list of clobbered registers ); Regards, Suresh Maniyath |
Moved: This thread is more suitable in Linux-Kernel and has been moved accordingly to help your thread/question get the exposure it deserves.
|
All times are GMT -5. The time now is 09:00 PM. |