Read-Only Author Jon Ward Posted 2-Dec-2001 23:38 GMT Toolset C51 |  RE: C51 'in-line' compilation Jon Ward 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
|