www.digitalmars.com         C & C++   DMDScript  

D - asm (in/out) don't work on DMD (0.71) Linux

reply Mike Wynn <mike l8night.co.uk> writes:
I've checked the doc's the x86opcodes in and out do not work in inline asm.

void io_outp( ushort port, ubyte v ) {
	asm {
		mov  DX, port;
		mov  AL, v;
		out AL, DX;
	}
}

has to be rewritten as

void io_outp( ushort port, ubyte v ) {
	asm {
		mov  DX, port;
		mov  AL, v;
		db 0xEE;
		// out AL, DX;
	}
}

outsb/w/d work.

as in/out are D keywords I think the inline asm for in/out should be
inb, inw, ind, outb, outw, outd (I did try this as some asm's support them)
Sep 07 2003
parent reply "Riccardo De Agostini" <riccardo.de.agostini email.it> writes:
"Mike Wynn" <mike l8night.co.uk> ha scritto nel messaggio
news:bjfob0$chd$1 digitaldaemon.com...
 I've checked the doc's the x86opcodes in and out do not work in inline

 void io_outp( ushort port, ubyte v ) {
 asm {
 mov  DX, port;
 mov  AL, v;
 out AL, DX;
 }
 }

Maybe it's just a typo in your message, but it should be "out DX, AL". Ric
Sep 08 2003
parent reply Mike Wynn <mike l8night.co.uk> writes:
Riccardo De Agostini wrote:
 "Mike Wynn" <mike l8night.co.uk> ha scritto nel messaggio
 news:bjfob0$chd$1 digitaldaemon.com...
 
I've checked the doc's the x86opcodes in and out do not work in inline

asm.
void io_outp( ushort port, ubyte v ) {
asm {
mov  DX, port;
mov  AL, v;
out AL, DX;
}
}

Maybe it's just a typo in your message, but it should be "out DX, AL".

"out" should be written ... just tried asm { mov DX, 0xCF8; mov EAX, 0x80000000; out DX, EAX; } give the error dmain.d(124): opcode expected, not out as does all the other rearrangments of AL,AX, EAX, DX, [DX] {gas uses `out %eax, (%dx)` and `in (%dx), %eax`}
Sep 08 2003
next sibling parent "Walter" <walter digitalmars.com> writes:
It's a bug, I'll take care of it. Thanks!
Sep 08 2003
prev sibling next sibling parent reply "Riccardo De Agostini" <riccardo.de.agostini email.it> writes:
"Mike Wynn" <mike l8night.co.uk> ha scritto nel messaggio
news:bjia4u$11ju$1 digitaldaemon.com...
 as I've been using gas I'm getting very confused over which way
 "out" should be written ... [...]

I too get confused when I use gas; too much sniffing gives me bad headaches! :) Seriously speaking, I just hoped it was a classic typo case instead of a bug in DMD. Not that I thought you hadn't tested enough, but you know, sometimes the bug you've been hunting for days gets spotted at once by the first one passing by, just because he hasn't been frying his own brain over it for the last twenty work hours or so... It happens. Actually happened to me more than once <sigh> Ric
Sep 09 2003
parent reply Mike Wynn <mike l8night.co.uk> writes:
Riccardo De Agostini wrote:
 "Mike Wynn" <mike l8night.co.uk> ha scritto nel messaggio
 news:bjia4u$11ju$1 digitaldaemon.com...
 
as I've been using gas I'm getting very confused over which way
"out" should be written ... [...]

I too get confused when I use gas; too much sniffing gives me bad headaches! :) Seriously speaking, I just hoped it was a classic typo case instead of a bug in DMD. Not that I thought you hadn't tested enough, but you know, sometimes the bug you've been hunting for days gets spotted at once by the first one passing by, just because he hasn't been frying his own brain over it for the last twenty work hours or so... It happens. Actually happened to me more than once <sigh> Ric

I had hoped you where right too, .... took me a long time to realise that `if ( v & 0xFFFF != 0xFFFF ) { ... }` was not working as I'd expected partly due to me checking that db 0xEF; was `out` 'EAX->port(DX)' I agree spotting other ppls typos/bugs is a lot easier than spotting your own, especially when your as masterful at creating them as I am :)
Sep 09 2003
parent reply "Sean L. Palmer" <palmer.sean verizon.net> writes:
Check the precedence for operator & versus operator !=.  This is hard to do
since there's not a precedence table anywhere on "The D Programming
Language" website, that I can find.

I for one vote that operators & and | and ^ should all be higher precedence
than the comparison operators.  I think they got this wrong in C.

The most common case for use of operator & is as below, yet this isn't valid
due to precedence, it evaluates to 'if ( v & (0xFFFF != 0xFFFF) ) { ... }'
which is just nonsense.

Most C compilers issue a warning if they see something like this (bitwise
operation applied to a boolean value with an int).  Just skip the warning
and fix the precedence.

Sean

"Mike Wynn" <mike l8night.co.uk> wrote in message
news:bjkp7t$1ku7$1 digitaldaemon.com...
 I had hoped you where right too, .... took me a long time to realise
 that `if ( v & 0xFFFF != 0xFFFF ) { ... }` was not working as I'd
 expected partly due to me checking that db 0xEF; was `out` 'EAX->port(DX)'

 I agree spotting other ppls typos/bugs is a lot easier than spotting
 your own, especially when your as masterful at creating them as I am :)

Sep 09 2003
parent "Fabian Giesen" <rygNO SPAMgmx.net> writes:
 Check the precedence for operator & versus operator !=.  This is hard
 to do since there's not a precedence table anywhere on "The D
 Programming Language" website, that I can find.

 I for one vote that operators & and | and ^ should all be higher
 precedence than the comparison operators.  I think they got this
 wrong in C.

The first C compilers didn't have || and &&, you used the normal binary | and & operators. That explains the precedence in original C. However, it's ofcourse one of the historical issues that D tries to fix :) -fg
Sep 11 2003
prev sibling parent "Walter" <walter digitalmars.com> writes:
"Mike Wynn" <mike l8night.co.uk> wrote in message
news:bjia4u$11ju$1 digitaldaemon.com...
 as I've been using gas I'm getting very confused over which way
 "out" should be written ... just tried

The rule the D inline assembler uses is it follows the format in the Intel documentation.
Sep 10 2003