|
|
View previous topic :: View next topic |
Author |
Message |
joe06 Guest
|
function parameters & return |
Posted: Wed Mar 05, 2003 7:26 am |
|
|
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 |
Posted: Wed Mar 05, 2003 7:41 am |
|
|
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 |
Posted: Wed Mar 05, 2003 10:22 am |
|
|
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 |
Posted: Thu Mar 06, 2003 2:38 am |
|
|
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 |
|
|
|
|
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
|