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

simple conversion c->asm

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



Joined: 11 Sep 2007
Posts: 7

View user's profile Send private message

simple conversion c->asm
PostPosted: Thu Jan 10, 2008 11:25 am     Reply with quote

I'm trying do convert:
Code:
counter = 256*TMR1H + TMR1L;

to
Code:

#asm
movf   TMR1H,W
movwf high counter
movf   TMR1L,W
movwf low counter
#endasm

but compiler don't know operator 'low' and 'high'.

What is other way to do that?
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Jan 10, 2008 11:52 am     Reply with quote

Simplest way to find out is to compile your C code and than have a look at the list file (*.lst) to see what assembly the compiler generated.

I wouldn't use assembly at all. It is hard to read, not portable and there is no need to use it.
Code:
counter = make16(TMR1H, TMR1L);
This will compile to just as short assembly code as your example.
Andrew-miksys



Joined: 11 Sep 2007
Posts: 7

View user's profile Send private message

PostPosted: Thu Jan 10, 2008 5:17 pm     Reply with quote

make16() doing exactly what I need! Thanks!

BDW here is 'compiler' optimalization Shocked

Code:

....................             counter = 256*TMR1H + TMR1L;
;  address of TMR1H is 0x0F
;  address of TMR1L is 0x0E
;  address of counter is 0x58,0x59
;  both in bank0

0321:  MOVF   0F,W
0322:  BSF    03.5
0323:  BSF    03.6
0324:  MOVWF  11
0325:  CLRF   10
0326:  BCF    03.5
0327:  BCF    03.6
0328:  MOVF   0E,W   
0329:  BSF    03.5
032A:  BSF    03.6
032B:  ADDWF  10,W
032C:  BCF    03.5
032D:  BCF    03.6
032E:  MOVWF  59
032F:  BSF    03.5
0330:  BSF    03.6
0331:  MOVF   11,W
0332:  BCF    03.5
0333:  BCF    03.6
0334:  MOVWF  5A
0335:  BTFSC  03.0
0336:  INCF   5A,F
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