LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 02-23-2009, 03:02 PM   #1
aminoamide
LQ Newbie
 
Registered: Feb 2009
Posts: 1

Rep: Reputation: 0
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

Last edited by aminoamide; 02-23-2009 at 03:05 PM. Reason: Title was not good
 
Old 02-24-2009, 04:56 AM   #2
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
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).
 
Old 02-24-2009, 08:13 AM   #3
Suresh Maniyath
Member
 
Registered: Feb 2009
Location: India
Distribution: Fedora, Ubuntu
Posts: 37

Rep: Reputation: 19
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
 
Old 02-24-2009, 10:39 AM   #4
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
Moved: This thread is more suitable in Linux-Kernel and has been moved accordingly to help your thread/question get the exposure it deserves.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in linux kernel module copilation using makefile(hello-1.c program) of lkmpg kapilaryan2003 Fedora 2 06-09-2008 05:04 AM
adding module to vanilla kernel serefarikan Linux - General 0 02-06-2005 04:26 PM
adding own module to kernel b123coder Linux - Newbie 1 12-08-2004 10:05 PM
Adding module back into kernel Reefcrazed Linux - Software 1 08-28-2004 11:46 PM
adding simple module to kernel(2.6) qfupa Linux - General 5 07-15-2004 06:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 02:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration