Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ User's Guide - there is an alternative to watcom's auxiliary pragma method for creating http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
There is an alternative to Watcom's auxiliary pragma method for creating
in-line assembly code.  You can use one of the _asm or __asm keywords to
imbed assembly code into the generated code.  The following is a revised
example of the cursor positioning example introduced above.

Example:

     #include <stdio.h>

     void main()
     {
         unsigned short _rowcol;
         unsigned char _page;

         _rowcol = (5 << 8) | 20;
         _page = 0;
         _asm {
             mov     dx,_rowcol
             mov     bh,_page
             push    bp
             mov     ah,2
             int     10h
             pop     bp
         };
         printf( "Hello world\n" );
     }

The assembly language sequence can reference program variables to retrieve
or store results.  There are a few incompatibilities between Microsoft and
Watcom implementation of this directive.

__LOCAL_SIZE
    is not supported by Watcom C/C++.  This is illustrated in the following
    example.

    Example:

         void main()
         {
             int i;
             int j;

             _asm {
                 push    bp
                 mov     bp,sp
                 sub     sp,__LOCAL_SIZE
             };
         }

structure
    references are not supported by Watcom C/C++.  This is illustrated in
    the following example.

    Example:

         #include <stdio.h>

         struct rowcol {
             unsigned char col;
             unsigned char row;
         };

         void main()
         {
             struct rowcol _pos;
             unsigned char _page;

             _pos.row = 5;
             _pos.col = 20;
             _page = 0;
             _asm {
                 mov     dl,_pos.col
                 mov     dh,_pos.row
                 mov     bh,_page
                 push    bp
                 mov     ah,2
                 int     10h
                 pop     bp
             };
             printf( "Hello world\n" );
         }

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson