From mboxrd@z Thu Jan 1 00:00:00 1970 From: mperrin@hcs.harvard.edu (Marshall Perrin) To: help-gcc@gnu.org Subject: Assembler in C under Linux Date: Thu, 02 Dec 1999 11:37:00 -0000 Message-id: X-SW-Source: 1999-12/msg00031.html I'm trying to port a driver for a digital signal processor card from DOS to Linux. The DOS driver, developed by someone not me ;-), is mostly C but has a fair amount of inline assembler. For Borland C for DOS, this was pretty easy to do. Just asm { mov dx, DSP_BaseIO add dx, reg_offset } etc etc. Gcc of course chokes on the above. I've attempted to read through the gcc documentation and figure out how to do this, but no luck. That led me towards something like asm("mov dx, %0" : : "d" (DSP32C_BaseIo)); asm("add dx, %0" : : "d" (reg_offset)); asm("in ax,dx"); asm("mov %0,ax" :"=d" (value) : ); And yet I get the error message "/tmp/ccAimSJo.s:818: Error: operands given don't match any known 386 instruction" over and over again with that approach. Poking through the kernel source leads me to try something like asm("mov %%edx, %0" : : "b" (DSP_BaseIo)); asm("add %%edx, %0" : : "b" (reg_offset)); asm("in %%eax,%%edx"); asm("mov %0,%%eax" :"=b" (value) : ); But that's no luck either - If I comment out the third line, that compiles, but if the 3rd line is there I get "/tmp/ccGjg9uV.s:26: Error: bad register name ('%%eax')", which makes little sense as I use %%eax just fine in the other three instructions. So, what am I doing wrong? Any help here would be greatly appreciated, whether it be pointer to a web page, book, or some other source of information. Thanks much! - Marshall Perrin Harvard/Smithsonian Center for Astrophysics From mboxrd@z Thu Jan 1 00:00:00 1970 From: mperrin@hcs.harvard.edu (Marshall Perrin) To: help-gcc@gnu.org Subject: Assembler in C under Linux Date: Fri, 31 Dec 1999 22:24:00 -0000 Message-ID: X-SW-Source: 1999-12n/msg00031.html Message-ID: <19991231222400.64FkEZIec7CfcfI-2xCwkoAapD3vwwPR_xy7XClRDNI@z> I'm trying to port a driver for a digital signal processor card from DOS to Linux. The DOS driver, developed by someone not me ;-), is mostly C but has a fair amount of inline assembler. For Borland C for DOS, this was pretty easy to do. Just asm { mov dx, DSP_BaseIO add dx, reg_offset } etc etc. Gcc of course chokes on the above. I've attempted to read through the gcc documentation and figure out how to do this, but no luck. That led me towards something like asm("mov dx, %0" : : "d" (DSP32C_BaseIo)); asm("add dx, %0" : : "d" (reg_offset)); asm("in ax,dx"); asm("mov %0,ax" :"=d" (value) : ); And yet I get the error message "/tmp/ccAimSJo.s:818: Error: operands given don't match any known 386 instruction" over and over again with that approach. Poking through the kernel source leads me to try something like asm("mov %%edx, %0" : : "b" (DSP_BaseIo)); asm("add %%edx, %0" : : "b" (reg_offset)); asm("in %%eax,%%edx"); asm("mov %0,%%eax" :"=b" (value) : ); But that's no luck either - If I comment out the third line, that compiles, but if the 3rd line is there I get "/tmp/ccGjg9uV.s:26: Error: bad register name ('%%eax')", which makes little sense as I use %%eax just fine in the other three instructions. So, what am I doing wrong? Any help here would be greatly appreciated, whether it be pointer to a web page, book, or some other source of information. Thanks much! - Marshall Perrin Harvard/Smithsonian Center for Astrophysics