January 12, 2006
"Frank Benoit" <frank_DELETE_@_DELETE_drealtime.com> wrote in message news:dq667u$100d$1@digitaldaemon.com...
>I found this solution. Can somebody correct me, if there is a mistake?
> Perhaps there is a better syntax for getting the address of retval?
>
> const uint RTAI_SYS_VECTOR = 0xf6;
>
> long rtai_srq( int srq, uint args )
> {
>  long retval;

Should be int retval, not long. Longs in D are 64 bits.

>  long* rptr = &retval;
>  asm{
>    // load registers with arguments
>    mov srq,EAX;

For this and the next two instructions, the operands are reversed, should
be:
    mov EAX, srq ;

>    mov args,ECX;
>    mov rptr,EDX;

Can do it like:
    lea EDX, retval[EBP] ;

>    // initiate software interrupt
>    int RTAI_SYS_VECTOR;
>  }
>  return retval;
> }


January 12, 2006
There's possibly a number of things wrong here, so I'll try to get you started at least:

1) long in D is different than long in C. Did you intend to return a 64 bit value?

2) the mov statements are inverted. Intel asm places the destination on the left.

3) you can probably use a lea instruction to get the relevant address of retval.



"Frank Benoit" <frank_DELETE_@_DELETE_drealtime.com> wrote in message news:dq667u$100d$1@digitaldaemon.com...
>I found this solution. Can somebody correct me, if there is a mistake?
> Perhaps there is a better syntax for getting the address of retval?
>
> const uint RTAI_SYS_VECTOR = 0xf6;
>
> long rtai_srq( int srq, uint args )
> {
>  long retval;
>  long* rptr = &retval;
>  asm{
>    // load registers with arguments
>    mov srq,EAX;
>    mov args,ECX;
>    mov rptr,EDX;
>    // initiate software interrupt
>    int RTAI_SYS_VECTOR;
>  }
>  return retval;
> }
>
>
> Frank
>
>
> --
> D goes real-time: http://www.drealtime.com


January 12, 2006
Thanks for the replies. My "solution" wasn't really the optimum :))

Frank

1 2
Next ›   Last »