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 CCS Technical Support

variables in function calls

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



Joined: 09 Sep 2003
Posts: 67
Location: Winterthur, Switzerland

View user's profile Send private message

variables in function calls
PostPosted: Sat Sep 08, 2001 8:49 am     Reply with quote

Hello (Grüezi)

I wrote the following code to print a character on a LCD-modul (only a part of the code is shown here):

#byte BUS = 6
#separate
void put_to_lcd(char value)
{
BUS = value;
etc.
}

//example:
main()
{
...
put_to_lcd('A');
...
}

my problem: the compiler loads the argument of the function first to a normal RAM-location and then (during the function) to the PORTB.
Is there any possibility to load the argument directly to the PORTB without it loading first to an other location?

Thanks

Greetings from Switzerland
Felix
___________________________
This message was ported from CCS's old forum
Original Post ID: 215
Tomi
Guest







Re: variables in function calls
PostPosted: Sat Sep 08, 2001 10:13 am     Reply with quote

The problem is about parameter passing to a function. It is done either using physical stack (Neumann processor) or a software stack (Harward proc. e.g. PIC). This SW stack in a PIC looks like a "normal RAM-location".
To bypass the usage of the stack you can use a #define instead of a function:
#byte BUS = 6
#define put_to_lcd(value) BUS=value

Sample code:
.................... put_to_lcd('A');
004B: MOVLW 41
004C: MOVWF 06
To make sure that the port_B is output you can extend the statement:
#byte BUS = 6
#define put_to_lcd(value) Set_Tris_B(0);BUS=value

Sample:
.................... put_to_lcd('A');
004B: MOVLW 00
004C: BSF 03,5
004D: MOVWF 06
004E: MOVLW 41
004F: BCF 03,5
0050: MOVWF 06


:=Hello (Grüezi)
:=
:=I wrote the following code to print a character on a LCD-modul (only a part of the code is shown here):
:=
:=#byte BUS = 6
:=#separate
:=void put_to_lcd(char value)
:= {
:= BUS = value;
:= etc.
:= }
:=
:=//example:
:=main()
:={
:=...
:=put_to_lcd('A');
:=...
:=}
:=
:=my problem: the compiler loads the argument of the function first to a normal RAM-location and then (during the function) to the PORTB.
:=Is there any possibility to load the argument directly to the PORTB without it loading first to an other location?
:=
:=Thanks
:=
:=Greetings from Switzerland
:=Felix
___________________________
This message was ported from CCS's old forum
Original Post ID: 216
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