View previous topic :: View next topic |
Author |
Message |
aeroboy
Joined: 26 Apr 2009 Posts: 9
|
signed char and signed long |
Posted: Tue Apr 28, 2009 5:36 pm |
|
|
Hello,
Does the CCS compiler support a signed char subtraction from a signed long?
Code: |
signed long x;
signed char y;
x=989;
y=-45;
x=x+y;
x=944
|
I do not have a way to verify this but I need it to know how to do the code.
Thanks.
--Luis |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Apr 28, 2009 5:49 pm |
|
|
Quote: | I do not have a way to verify this |
Do you have the CCS compiler and MPLAB ? If so, you have the power
to make a test program and run it in the MPLAB simulator. Configure
the simulator to display printf() text in the Output Window.
Instructions on how to do this:
http://www.ccsinfo.com/forum/viewtopic.php?t=23408&start=1
Here's the output of the following program:
Here is the test program:
Code: | #include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//======================================
void main()
{
signed long x;
signed char y;
x=989;
y=-45;
x=x+y;
printf("%ld", x);
while(1);
} |
|
|
![](templates/subSilver/images/spacer.gif) |
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Tue Apr 28, 2009 5:51 pm |
|
|
Standard C rules say it should promote Y to a long and then do the math. I would be astonished if CCS could not handle this automatically. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
![](templates/subSilver/images/spacer.gif) |
|