STACK SEGMENT IDATA
VAR SEGMENT DATA
RSEG STACK
DS 10H ; 16 Bytes Stack
RSEG VAR
x: DS 2
CSEG AT 0
USING 0 ; Register-Bank 0
; Execution starts at address 0 on power-up.
JMP MAIN
; //#include <reg52.h>
;
; static unsigned int x;
;
; unsigned int mul(unsigned int a, unsigned int b) {
_mul:
; SOURCE LINE # 5
;---- Variable 'b?041' assigned to Register 'R4/R5' ----
;---- Variable 'a?040' assigned to Register 'R6/R7' ----
; unsigned int result = 0;
; SOURCE LINE # 6
;---- Variable 'result?042' assigned to Register 'R2/R3' ----
CLR A
MOV R3,A
MOV R2,A
; unsigned int i;
; for(i = 0; i < a; ++i) result += b;
; SOURCE LINE # 8
;---- Variable 'i?043' assigned to Register 'DPTR' ----
MOV DPL,A
MOV DPH,A
?C0001:
CLR C
MOV A,DPL
SUBB A,R7
MOV A,DPH
SUBB A,R6
JNC ?C0002
MOV A,R5
ADD A,R3
MOV R3,A
MOV A,R4
ADDC A,R2
MOV R2,A
INC DPTR
SJMP ?C0001
?C0002:
; return result;
; SOURCE LINE # 9
MOV R6,AR2
MOV R7,AR3
; }
; SOURCE LINE # 10
RET
; END OF _mul
;
; unsigned int FUNC(void) {
FUNC:
; SOURCE LINE # 12
; if(x < 20) return mul(2, x);
; SOURCE LINE # 13
CLR C
MOV A,x+01H
SUBB A,#014H
MOV A,x
SUBB A,#00H
JNC ?C0005
MOV R5,x+01H
MOV R4,x
MOV R7,#02H
SJMP ?C0011
?C0005:
; if(x < 50) return mul(5, x);
; SOURCE LINE # 14
CLR C
MOV A,x+01H
SUBB A,#032H
MOV A,x
SUBB A,#00H
JNC ?C0007
MOV R5,x+01H
MOV R4,x
MOV R7,#05H
?C0011:
MOV R6,#00H
LJMP _mul
?C0007:
; return x;
; SOURCE LINE # 15
MOV R6,x
MOV R7,x+01H
; }
; SOURCE LINE # 16
?C0006:
RET
; END OF FUNC
;
; void main(void) {
main:
MOV SP,#STACK-1
; SOURCE LINE # 18
; unsigned int result;
; SOURCE LINE # 19
; {
; x = 0; result = FUNC();
; SOURCE LINE # 21
CLR A
MOV x,A
MOV x+01H,A
LCALL FUNC
;---- Variable 'result?244' assigned to Register 'R6/R7' ----
; x = 15; result = FUNC();
; SOURCE LINE # 22
MOV x,#00H
MOV x+01H,#0FH
LCALL FUNC
; x = 19; result = FUNC();
; SOURCE LINE # 23
MOV x,#00H
MOV x+01H,#013H
LCALL FUNC
; }
; SOURCE LINE # 24
; {
; SOURCE LINE # 25
; x = 20; result = FUNC();
; SOURCE LINE # 26
MOV x,#00H
MOV x+01H,#014H
LCALL FUNC
; x = 40; result = FUNC();
; SOURCE LINE # 27
MOV x,#00H
MOV x+01H,#028H
LCALL FUNC
; x = 49; result = FUNC();
; SOURCE LINE # 28
MOV x,#00H
MOV x+01H,#031H
LCALL FUNC
; }
; SOURCE LINE # 29
; {
; SOURCE LINE # 30
; x = 50; result = FUNC();
; SOURCE LINE # 31
MOV x,#00H
MOV x+01H,#032H
LCALL FUNC
; x = 90; result = FUNC();
; SOURCE LINE # 32
MOV x,#00H
MOV x+01H,#05AH
LCALL FUNC
; x = 1000; result = FUNC();
; SOURCE LINE # 33
MOV x,#03H
MOV x+01H,#0E8H
LCALL FUNC
; }
; SOURCE LINE # 34
?C0008:
; while(1);
; SOURCE LINE # 35
SJMP ?C0008
; END OF main
END