Discussion Forum

C51 'in-line' compilation

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
David Fussell
Posted
30-Nov-2001 10:38 GMT
Toolset
C51
New! C51 'in-line' compilation
Hi!

I've a particular module within a large project in which I wish to avoid making jumps to code segments from other modules (including C51 library code).
Is there a means by which I can ensure that the compilation of this module will expand any calls to external code segments 'in-line'? I guess this is more-or-less what happens when optimising for speed, but would appreciate any feedback. (i.e is there a #pragma directive for speed?)

Thanks!

David


Read-Only
Author
Support Intl Keil
Posted
30-Nov-2001 15:05 GMT
Toolset
C51
New! RE: C51 'in-line' compilation
Yes, C51 provides you with the OPTIMIZE (SPEED) directive.
Read-Only
Author
Andrew Neil
Posted
30-Nov-2001 21:55 GMT
Toolset
C51
New! RE: C51 'in-line' compilation
but this does not mean that it will make function calls inline.

C51 does not have a #pragma inline.

In particular, note that the manual is incorrect when it says that the intrinsic functions are inserted inline: this is not true - they are called just like any other function.
Read-Only
Author
Jon Ward
Posted
2-Dec-2001 23:38 GMT
Toolset
C51
New! RE: C51 'in-line' compilation
In particular, note that the manual is incorrect when it says that the intrinsic functions are inserted inline: this is not true - they are called just like any other function.

This is only true for the _chkfloat_, _lrol_, and _lror_ functions.

The _crol_, _cror_, _irol_, _iror_, _nop_, and _testbit_ routines are implemented as explicit instructions. For example:

;---- Variable 'i?042' assigned to Register 'R2/R3' ----
;---- Variable 'c?041' assigned to Register 'R1' ----
; {
			; SOURCE LINE # 6
; float f;
; unsigned char c;
; unsigned int i;
; unsigned long l;
; 
; bit b;
; 
; if (_chkfloat_ (f))
			; SOURCE LINE # 14
	MOV  	R7,f?040+03H
	MOV  	R6,f?040+02H
	MOV  	R5,f?040+01H
	MOV  	R4,f?040
	LCALL	?C?CHKFLOAT
	JZ   	?C0001
;   {
			; SOURCE LINE # 15
;   f = 0.0;
			; SOURCE LINE # 16
	CLR  	A
	MOV  	f?040+03H,A
	MOV  	f?040+02H,A
	MOV  	f?040+01H,A
	MOV  	f?040,A
;   }
			; SOURCE LINE # 17
?C0001:
; 
; c = _crol_ (c, 3);
			; SOURCE LINE # 19
	MOV  	R0,#03H
	MOV  	R7,AR1
	MOV  	A,R7
	INC  	R0
	SJMP 	?C0007
?C0006:
	RL   	A
?C0007:
	DJNZ 	R0,?C0006
	MOV  	R1,A
; c = _cror_ (c, 4);
			; SOURCE LINE # 20
	MOV  	R0,#04H
	MOV  	R7,A
	INC  	R0
	SJMP 	?C0009
?C0008:
	RR   	A
?C0009:
	DJNZ 	R0,?C0008
	MOV  	R1,A
; 
; i = _irol_ (i, 3);
			; SOURCE LINE # 22
	MOV  	R0,#03H
	MOV  	R7,AR3
	MOV  	R6,AR2
	MOV  	A,R7
	INC  	R0
	SJMP 	?C0011
?C0010:
	RLC  	A
	XCH  	A,R6
	RLC  	A
	XCH  	A,R6
	MOV  	ACC.0,C
?C0011:
	DJNZ 	R0,?C0010
	MOV  	R2,AR6
	MOV  	R3,A
; i = _iror_ (i, 4);
			; SOURCE LINE # 23
	MOV  	R0,#04H
	MOV  	R7,A
	INC  	R0
	SJMP 	?C0013
?C0012:
	MOV  	C,ACC.0
	XCH  	A,R6
	RRC  	A
	XCH  	A,R6
	RRC  	A
?C0013:
	DJNZ 	R0,?C0012
	MOV  	R2,AR6
	MOV  	R3,A
; 
; l = _lrol_ (l, 3);
			; SOURCE LINE # 25
	MOV  	R7,l?043+03H
	MOV  	R6,l?043+02H
	MOV  	R5,l?043+01H
	MOV  	R4,l?043
	MOV  	R0,#03H
	LCALL	?C?LROL
	MOV  	l?043+03H,R7
	MOV  	l?043+02H,R6
	MOV  	l?043+01H,R5
	MOV  	l?043,R4
; l = _lror_ (l, 4);
			; SOURCE LINE # 26
	MOV  	R0,#04H
	LCALL	?C?LROR
	MOV  	l?043+03H,R7
	MOV  	l?043+02H,R6
	MOV  	l?043+01H,R5
	MOV  	l?043,R4
; 
; _nop_ ();
			; SOURCE LINE # 28
	NOP  	
; 
; if (_testbit_ (b))
			; SOURCE LINE # 30
	JBC  	b?044,?C0015
	SJMP 	?C0003
?C0015:
;   {
			; SOURCE LINE # 31
;   b = 1;
			; SOURCE LINE # 32
	SETB 	b?044
;   }
			; SOURCE LINE # 33
?C0003:
; 
; while (1);
			; SOURCE LINE # 35
	SJMP 	?C0003
; END OF main

Jon
Read-Only
Author
David Fussell
Posted
3-Dec-2001 08:57 GMT
Toolset
C51
New! RE: C51 'in-line' compilation
Okay. The lib. functions that my 'c' module require are LSTIDATA ,LLDIDATA and similar, they aren't inlined when the CODE(SPEED) option is specified. I guess my only means of inlining these is to do it manually.

Thanks for your comments.

David

Read-Only
Author
Jon Ward
Posted
3-Dec-2001 17:40 GMT
Toolset
C51
New! RE: C51 'in-line' compilation
Those routines are helper routines and they are not included inline. Refer to

http://www.keil.com/support/docs/1964.htm

for a little more information about what the routines do and how to "decode" the function names.

Jon
Read-Only
Author
Andrew Neil
Posted
3-Dec-2001 10:32 GMT
Toolset
C51
New! RE: C51 'in-line' compilation
This is only true for the _chkfloat_, _lrol_, and _lror_ functions.

Guess which ones I was using, then... ;-)

When will the manual be corrected?

Next Thread | Thread List | Previous Thread Start a Thread | Settings