I would like to port C’s outb function to D.
static __inline void outb (unsigned char value, unsigned short int port)
{
__asm__ __volatile__ ("outb %b0,%w1"
:
:
"a" (value),
"Nd" (port));
}
This is D version.
extern(C)
{
void outb (ubyte value, ushort port)
{
// I couldn't figure out this part
}
}
These are some links about the subject.
D Inline Assembler
GCC-Inline-Assembly-HOWTO
http://ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html
But I don’t know assembly language so I need some help. Any help would be appreciated. Thanks.
The
outbinstruction should only be called asoutb %al, %dxwhere%alis the value and%dxis the port.D uses Intel syntax for x86, as opposed to GNU assembler which uses the AT&T syntax by default. The corresponding Intel syntax would be
out dx, al, and corresponding code in D would look like:Note that you don’t need to write the assembly at all, because druntime has the
core.bitop.outpfunction which perform the same instruction.