PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

c variable in asm

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Sukesh



Joined: 21 Sep 2005
Posts: 3

PostPosted: Wed Oct 26, 2005 6:22 pm    Post subject: c variable in asm Reply with quote

need another help, iam not able compile the following code.
is my usage of c variable in asm correct ?
thanks

Code:

#include <stdio.h>
main()
{
    int y1=2;
    __asm
    ("
      dec   y1
    ");

}
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6129
Location: The Portland Group Inc.

PostPosted: Thu Oct 27, 2005 6:54 pm    Post subject: Reply with quote

Hi Sukesh,

In basic asm statements, you can only use global C variables. Also, 'dec' only works with registers. Example:
Code:
#include <stdio.h>
int y1=2;
main()
{
    printf("Before %d\n", y1);
    __asm("mov   y1, %eax");
    __asm("dec   %eax");
    __asm("mov   %eax, y1");
    printf("After %d\n", y1);

}

Code:
%pgCC tmp.c
% a.out
Before 2
After 1


Note that we will support extened asm in our next major release (6.1) which will allow you do more advanced assembly coding, such as using local variables. For now, however we're stuck with basic asm.

Thanks,
Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group