FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Inline assembly problem translating C header to D module...

 
Post new topic   Reply to topic     Forum Index -> General
View previous topic :: View next topic  
Author Message
pqnelson



Joined: 03 Jun 2007
Posts: 13
Location: Davis

PostPosted: Mon Jun 04, 2007 6:35 pm    Post subject: Inline assembly problem translating C header to D module... Reply with quote

Hello, I'm trying to translate this simple header to a D module:
Code:
#ifndef _ASM_H_
#define _ASM_H_


/* START HERE IT IS EASY AND DO-ABLE */
#define cli() __asm__ ("cli\n\t")
#define sti() __asm__ ("sti\n\t")

#define halt() __asm__ ("cli;hlt\n\t");
#define idle() __asm__ ("jmp .\n\t");
/*END EASY DO-ABLE INLINE ASSEMBLY */


#define inb(port) (__extension__({   \
unsigned char __res;   \
__asm__ ("inb   %%dx,   %%al\n\t"   \
                :"=a"(__res)   \
                :"dx"(port));   \
__res;   \
}))

#define outb(value, port) __asm__ (   \
"outb   %%al,   %%dx\n\t"::"al"(value), "dx"(port))

#define insl(port, buf, nr) \
__asm__ ("cld;rep;insl\n\t"   \
::"d"(port), "D"(buf), "c"(nr))

#define outsl(buf, nr, port) \
__asm__ ("cld;rep;outsl\n\t"   \
::"d"(port), "S" (buf), "c" (nr))

#endif
The problem is that there is no opcode for "insl", "outsl" or "inb" in the D inline assembler.

I am using the GNU D Compiler front end, which could possibly be a source of my problems. The GNU D Compiler front end supposedly uses the GAS assembler, but when I use the GCC to compile the C code that implements this header there's no problem, which confuses me a tad.

Could I define these unfriendly methods in a "extern (C) { ... }" section of code as methods?

I tried using the "C .h2d module" program, but it told me to go to hell. So I am rather stumped about how to go around this problem.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> General All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group