CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

function parameters & return

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
joe06
Guest







function parameters & return
PostPosted: Wed Mar 05, 2003 7:26 am     Reply with quote

when looking to the compiled asm code, it seems CCS uses fixed RAM locations to pass & return parameters from & to functions:
From what I observe, it uses locations 0x77 to 0x7B (bank 0) to store returned values from fucntions, and locations 0x54 to 0x5C to store functions parameters (maybe more ...)
These RAM locations (at least for returns) are saved / restored when an interrupt occurs.
Is anybody know more about these reserved locations ?
I defined some #locate in my program using these locations, is the compiler "intelligent" to reserve other locations, or are these locations reserved ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 12371
Tomi
Guest







Re: function parameters & return
PostPosted: Wed Mar 05, 2003 7:41 am     Reply with quote

1. If you want to return a byte then use the _return_ variable, e.g.:
_return_ = 0x1A;

2. You can use a pointer as the function input:
void MyFunc(long *param)
{
........
*param = 0x1234;
........
}

3. The scratch RAM locations (0x78 and same) could be various depended upon your program. Don't use them.

:=when looking to the compiled asm code, it seems CCS uses fixed RAM locations to pass & return parameters from & to functions:
:=From what I observe, it uses locations 0x77 to 0x7B (bank 0) to store returned values from fucntions, and locations 0x54 to 0x5C to store functions parameters (maybe more ...)
:=These RAM locations (at least for returns) are saved / restored when an interrupt occurs.
:=Is anybody know more about these reserved locations ?
:=I defined some #locate in my program using these locations, is the compiler "intelligent" to reserve other locations, or are these locations reserved ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 12375
joe06
Guest







Re: function parameters & return
PostPosted: Wed Mar 05, 2003 10:22 am     Reply with quote

thanks, however, it seems #locate is forbidden for
locations 0x77 to 0x7C ... reserved for returned values from function ... we can see these locations saved when interrupt occurs and restore after the isr ..
joe

:=1. If you want to return a byte then use the _return_ variable, e.g.:
:=_return_ = 0x1A;
:=
:=2. You can use a pointer as the function input:
:=void MyFunc(long *param)
:={
:=........
:=*param = 0x1234;
:=........
:=}
:=
:=3. The scratch RAM locations (0x78 and same) could be various depended upon your program. Don't use them.
:=
:=:=when looking to the compiled asm code, it seems CCS uses fixed RAM locations to pass & return parameters from & to functions:
:=:=From what I observe, it uses locations 0x77 to 0x7B (bank 0) to store returned values from fucntions, and locations 0x54 to 0x5C to store functions parameters (maybe more ...)
:=:=These RAM locations (at least for returns) are saved / restored when an interrupt occurs.
:=:=Is anybody know more about these reserved locations ?
:=:=I defined some #locate in my program using these locations, is the compiler "intelligent" to reserve other locations, or are these locations reserved ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 12379
Tomi
Guest







Re: function parameters & return
PostPosted: Thu Mar 06, 2003 2:38 am     Reply with quote

The 0x78+ address space is reserved for C scratch RAM. As I mentioned earlier the size of this reserved space is depended on your code complexity, e.g. I have a very small program which reserves only memory 0x77-0x78.

:=thanks, however, it seems #locate is forbidden for
:=locations 0x77 to 0x7C ... reserved for returned values from function ... we can see these locations saved when interrupt occurs and restore after the isr ..
:=joe
:=
:=:=1. If you want to return a byte then use the _return_ variable, e.g.:
:=:=_return_ = 0x1A;
:=:=
:=:=2. You can use a pointer as the function input:
:=:=void MyFunc(long *param)
:=:={
:=:=........
:=:=*param = 0x1234;
:=:=........
:=:=}
:=:=
:=:=3. The scratch RAM locations (0x78 and same) could be various depended upon your program. Don't use them.
:=:=
:=:=:=when looking to the compiled asm code, it seems CCS uses fixed RAM locations to pass & return parameters from & to functions:
:=:=:=From what I observe, it uses locations 0x77 to 0x7B (bank 0) to store returned values from fucntions, and locations 0x54 to 0x5C to store functions parameters (maybe more ...)
:=:=:=These RAM locations (at least for returns) are saved / restored when an interrupt occurs.
:=:=:=Is anybody know more about these reserved locations ?
:=:=:=I defined some #locate in my program using these locations, is the compiler "intelligent" to reserve other locations, or are these locations reserved ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 12415
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 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 © 2001, 2005 phpBB Group