www.digitalmars.com         C & C++   DMDScript  

c++.dos.16-bits - Problem with function containing inline assembly

reply "tjulian" <t t.com> writes:
/*
** The readx routine below always returns 0.
** compile with:
** sc -mld -3 -o+all readx.c
*/

#include <stdio.h>

unsigned int readx(unsigned int *p)
{
    unsigned int x;

    if (p)
    {
        asm
        {
            les bx,p
            mov ax,ES:[bx]
            mov x,ax
        }
    }
    else
    {
        x = 0;
    }
    return(x);
}

int main(int argc, char *argv[])
{
    unsigned int x,y;

    x = 55;
    y = readx(&x);
    printf("y=%d\n",y);
}
Jan 30 2002
next sibling parent "Walter" <walter digitalmars.com> writes:
Thanks for the bug report!

"tjulian" <t t.com> wrote in message news:a39igt$1o1h$1 digitaldaemon.com...
 /*
 ** The readx routine below always returns 0.
 ** compile with:
 ** sc -mld -3 -o+all readx.c
 */

 #include <stdio.h>

 unsigned int readx(unsigned int *p)
 {
     unsigned int x;

     if (p)
     {
         asm
         {
             les bx,p
             mov ax,ES:[bx]
             mov x,ax
         }
     }
     else
     {
         x = 0;
     }
     return(x);
 }

 int main(int argc, char *argv[])
 {
     unsigned int x,y;

     x = 55;
     y = readx(&x);
     printf("y=%d\n",y);
 }
Jan 30 2002
prev sibling parent reply "Walter" <walter digitalmars.com> writes:
I fixed it, but your email address is invalid so I can't send it to
you. -Walter

"tjulian" <t t.com> wrote in message news:a39igt$1o1h$1 digitaldaemon.com...
 /*
 ** The readx routine below always returns 0.
 ** compile with:
 ** sc -mld -3 -o+all readx.c
 */

 #include <stdio.h>

 unsigned int readx(unsigned int *p)
 {
     unsigned int x;

     if (p)
     {
         asm
         {
             les bx,p
             mov ax,ES:[bx]
             mov x,ax
         }
     }
     else
     {
         x = 0;
     }
     return(x);
 }

 int main(int argc, char *argv[])
 {
     unsigned int x,y;

     x = 55;
     y = readx(&x);
     printf("y=%d\n",y);
 }
Jan 31 2002
parent "tjulian" <tjulian removethis.oldi.com> writes:
Walter,
This problem is fixed in the 8.27.2 beta. Thanks!
Tim

"Walter" <walter digitalmars.com> wrote in message
news:a3cbid$s25$1 digitaldaemon.com...
 I fixed it, but your email address is invalid so I can't send it to
 you. -Walter

 "tjulian" <t t.com> wrote in message
news:a39igt$1o1h$1 digitaldaemon.com...
 /*
 ** The readx routine below always returns 0.
 ** compile with:
 ** sc -mld -3 -o+all readx.c
 */

 #include <stdio.h>

 unsigned int readx(unsigned int *p)
 {
     unsigned int x;

     if (p)
     {
         asm
         {
             les bx,p
             mov ax,ES:[bx]
             mov x,ax
         }
     }
     else
     {
         x = 0;
     }
     return(x);
 }

 int main(int argc, char *argv[])
 {
     unsigned int x,y;

     x = 55;
     y = readx(&x);
     printf("y=%d\n",y);
 }
Feb 19 2002