Note: This website is archived. For up-to-date information about D projects and development, please visit


Part of KeywordsCategory


D allows the use of inline assembly language


void main()
    int myint = 1234;
    char* mystring = "This number -> %d <- should be 1234\n";
            push    dword ptr myint     ; // pointer to the integer variable declared in D 
            push    dword ptr mystring  ; // pointer into the C-style string declared in D
            call    printf              ; // call the printf function

        This piece of code is the assembly equivalent of the C/D code
            int myint = 1234; 
            printf("This number -> %d <- should be 1234\n", myint);        

Expected Output

This number -> 1234 <- should be 1234

More Information

Inspired by a code snippet found at in the NASM manual.

For more details regarding asm blocks in D, check out the D Specification.

This example was tested on a x86 machine. I don't have any idea whether it'd work on any other platforms.


Posted by jcc7
Date/Time Thu Dec 2, 2004 6:48 pm