pqnelson
Joined: 03 Jun 2007 Posts: 13 Location: Davis
|
Posted: Mon Jun 04, 2007 6:35 pm Post subject: Inline assembly problem translating C header to D module... |
|
|
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. |
|