Jump to content
OMRON Forums

Recommended Posts

Posted
I'm having some difficulty in using the 'long long' data type on the PPMAC. I'm using IDE 22/07/2010 1.1.1026, firmware 1.2.1.5 and this example code : [code] #include int main(void) { int i; double dd = 0.0; long long ll = 0; for (i = 0; i < 4; ++i) { dd += 1000000001.0; ll = dd; printf("int i %d; double dd %f; long long ll %lld\n", i,dd,ll); } } [/code] I can compile this on another machine (x86 linux), and get the result I expect : [code] int i 0; double dd 1000000001.000000; long long ll 1000000001 int i 1; double dd 2000000002.000000; long long ll 2000000002 int i 2; double dd 3000000003.000000; long long ll 3000000003 int i 3; double dd 4000000004.000000; long long ll 4000000004 [/code] I can also compile it natively on the PPMAC and get the same result. However, if I compile it using the IDE, I get : [code] int i 0; double dd 1000000001.000000; long long ll 0 int i 1; double dd 2000000002.000000; long long ll 0 int i 2; double dd 3000000003.000000; long long ll 0 int i 3; double dd 4000000004.000000; long long ll 0 [/code] I guess this is due to a difference between the cross and native compilers, either due to the crosscompilation or merely an older version. Does the forthcoming IDE release fix this ? -adrian
  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Posted
I changed your code a little to see what part was going wrong. With this you can see the correct values in P0 to P3 which means that the printf is having the problem. Printf is probably using emulation and that might be where the problem originates. I have no solution for that yet but hopefully this information will let you continue. { int i; double dd = 0.0; long long ll = 0; for (i = 0; i < 4; ++i) { dd += 1000000001.0; ll = dd; pshm->P[i]=ll; printf("int i %d; double dd %f; long long ll %lld\n", i,dd,ll); } }
  • 2 weeks later...
Posted
[quote='bradp' pid='1118' dateline='1295370455'] I changed your code a little to see what part was going wrong. With this you can see the correct values in P0 to P3 which means that the printf is having the problem. Printf is probably using emulation and that might be where the problem originates. I have no solution for that yet but hopefully this information will let you continue. [code] { int i; double dd = 0.0; long long ll = 0; for (i = 0; i < 4; ++i) { dd += 1000000001.0; ll = dd; pshm->P[i]=ll; printf("int i %d; double dd %f; long long ll %lld\n", i,dd,ll); } } [/code] [/quote] I tried to work on from this, but still failed. The reason becomes apparent if I change the code to [code] dd += 1000000001.01; ll = dd; pshm->P[i]=ll; [/code] This produces the output : int i 20; double dd 1000000001.010000; long long ll 0 int i 21; double dd 2000000002.020000; long long ll 0 int i 22; double dd 3000000003.030000; long long ll 0 int i 23; double dd 4000000004.040000; long long ll 0 But if the values of P20-P24 are queried in the terminal window: P20 P20=1000000001.00999999 P21 P21=2000000002.01999998 Since the fractional part of dd should have been lost when converting to a long long, I suspect that the compiler has optimised the assignment and assigned dd directly to P[n] without going via ll. Is there an option to output the assembler listing so I can check this ? -adrian
Posted
We do not manually generate the assembler code as part of the IDE compiler process, but you can do this manually by modifying the make file. the following is what you do to generate and assembler file. 1. Go to you CApp folder on your pc (where the actuall files are physically located) 2. open up the make file. there should be a file such as the following "....._debug.mak" 3. go to the line that has the following script. $(CC) $(CFLAGS) $(DTDEBUG) -c $< 4. Modify the script to the following $(CC) $(CFLAGS) -S $(DTDEBUG) -c $< 5. save the file. 6. open up a command prompt and CD to where this make file is located. 7. execute the following command. make -f"....._debug.mak" clean ex: make -f"capp1_debug.mak" clean 8. execute the following command. make -f"....._debug.mak" ex: make -f"capp1_debug.mak" at this point after building you program, you should see a file with .s extension residing in the same folder. this file is the assembly code of your Capp. note: If you go to the IDE and build your program again, it will recreate your make file and remove the -S option from it. Dro Ghazarian [quote='artag' pid='1219' dateline='1296144644'] [quote='bradp' pid='1118' dateline='1295370455'] I changed your code a little to see what part was going wrong. With this you can see the correct values in P0 to P3 which means that the printf is having the problem. Printf is probably using emulation and that might be where the problem originates. I have no solution for that yet but hopefully this information will let you continue. [code] { int i; double dd = 0.0; long long ll = 0; for (i = 0; i < 4; ++i) { dd += 1000000001.0; ll = dd; pshm->P[i]=ll; printf("int i %d; double dd %f; long long ll %lld\n", i,dd,ll); } } [/code] [/quote] I tried to work on from this, but still failed. The reason becomes apparent if I change the code to [code] dd += 1000000001.01; ll = dd; pshm->P[i]=ll; [/code] This produces the output : int i 20; double dd 1000000001.010000; long long ll 0 int i 21; double dd 2000000002.020000; long long ll 0 int i 22; double dd 3000000003.030000; long long ll 0 int i 23; double dd 4000000004.040000; long long ll 0 But if the values of P20-P24 are queried in the terminal window: P20 P20=1000000001.00999999 P21 P21=2000000002.01999998 Since the fractional part of dd should have been lost when converting to a long long, I suspect that the compiler has optimised the assignment and assigned dd directly to P[n] without going via ll. Is there an option to output the assembler listing so I can check this ? -adrian [/quote]
  • 1 year later...
Posted
can you use the pmac on the computer(linux), and what is the kernel of linux? [quote='artag' pid='1109' dateline='1295344723'] I'm having some difficulty in using the 'long long' data type on the PPMAC. I'm using IDE 22/07/2010 1.1.1026, firmware 1.2.1.5 and this example code : [code] #include int main(void) { int i; double dd = 0.0; long long ll = 0; for (i = 0; i < 4; ++i) { dd += 1000000001.0; ll = dd; printf("int i %d; double dd %f; long long ll %lld\n", i,dd,ll); } } [/code] I can compile this on another machine (x86 linux), and get the result I expect : [code] int i 0; double dd 1000000001.000000; long long ll 1000000001 int i 1; double dd 2000000002.000000; long long ll 2000000002 int i 2; double dd 3000000003.000000; long long ll 3000000003 int i 3; double dd 4000000004.000000; long long ll 4000000004 [/code] I can also compile it natively on the PPMAC and get the same result. However, if I compile it using the IDE, I get : [code] int i 0; double dd 1000000001.000000; long long ll 0 int i 1; double dd 2000000002.000000; long long ll 0 int i 2; double dd 3000000003.000000; long long ll 0 int i 3; double dd 4000000004.000000; long long ll 0 [/code] I guess this is due to a difference between the cross and native compilers, either due to the crosscompilation or merely an older version. Does the forthcoming IDE release fix this ? -adrian [/quote]
Posted
[quote='xiaowei506' pid='3477' dateline='1337686836'] can you use the pmac on the computer(linux), and what is the kernel of linux? [/quote] Can you explain a little better? Do you want to communicate to a PMAC through a Linux PC? What type of PMAC do you have?
Guest
This topic is now closed to further replies.

×
×
  • Create New...