Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/06/07 04:21
Read: times


 
#132104 - assigning 4 bytes to a single long variable inSDCC
Hi

1. I want to assign 4 bytes to a single unsigned long variable in SDCC. one method of doing is by using shifting and logical operators
for ex.

unsigned long var = (unsigned long)byte4<<24 | (unsigned long)byte3<<16 | (unsigned long)byte2<<8 | byte1


but this method consumes lot of machine cycles...

now I want to know the alternate method of doing the same which consuming less no. of machine cycles.

2. I have 4 bytes of data stored in following registers
ACC = 0x00 MSB
B = 0x34
DPH = 0xff
DPL = 0x4f LSB
I want return these bytes to my main function in SDCC i.e.
code will look like below (approx.)

unsigned long fun();
main()
{
unsigned long a;
a = fun();
}
unsigned long fun(){

return()// I want to return the above data stored in ACC,B,DPH,DPL;
}


I thanks in advance to everybody/....

with regards
P.Ravi


List of 8 messages in thread
TopicAuthorDate
assigning 4 bytes to a single long variable inSDCC            01/01/70 00:00      
   Try this Function.            01/01/70 00:00      
      If you're worried about machine cycles            01/01/70 00:00      
   Unwise            01/01/70 00:00      
   have you read the manual?            01/01/70 00:00      
   do you now what a union is            01/01/70 00:00      
   #2            01/01/70 00:00      
      quted the relevant part...            01/01/70 00:00      

Back to Subject List