Buggy inline assembler

Heinz malagana15 at yahoo.es
Fri Aug 18 11:08:52 PDT 2006


Hi everyone, i've seen many bugs with the inline assembler in D. I've tried
many functions that work with other assemblers, simple functions such as print
to screen (i've seen D users complaining about this too).
I'm writing a block of code to make some sound through the pc speaker. It
compiles fine but at runtime i get a Win32 Exception.
Here's the code:

public void Beep(uint Frequency)
{
    ushort count 1193180 / Frequency;
    asm
    {
        mov AL, 0xB6;
        out 0x43, AL;// It crashes here.
        mov AX, count;
        out 0x42, AL;
        mov AL, AH;
        out 0x42, AL;
        in AL, 0x61;
        or AL, 0x3;
        out 0x61, AL;
        in AL, 0x61;
        and AL, 0xFC;
        out 0x42, AL;
    }
}

I tried this block with tasm and works fine but not with D. The program
crashes at the second line of asm code, looks like we can't send data to
ports, 0x43 in this case.

Does somebody have a hint about this?

Big thanks.



More information about the Digitalmars-d-bugs mailing list