目前只完成了赋值语句以及递增、递减语句功能。
源程序1:#include <stm8s903k3.h>
long *p;
long *pp;
foo()
{
char a = PA_DDR;
int n;
long m;
a++;
n += 0x100;
m -= 0x001201;
*p += 0x1;
*pp += 0x1100;
a += 2;
a -= 2;
}
汇编输出1:
;****************************************************************
; ATM8S C compiler - AT8CC, v0.10
; Wed Jul 21 10:40:14 2010
;****************************************************************
.device stm8s903k3, 1024, 8192
.segment BANKi (REL)
p:: .rs 2
.segment BANKi (REL)
pp:: .rs 2
.segment CODE2 (REL), foo
foo_$1_a .equ 1
foo_$2_n .equ 2
foo_$3_m .equ 4
; ::: 'e5.c' #5: foo()
foo::
pushw X
sub SP, #0x7
; ::: 'e5.c' #7: char a = PA_DDR;
ld A, 0x5002
ld (foo_$1_a, SP), A
; ::: 'e5.c' #10: a++;
inc (foo_$1_a, SP)
; ::: 'e5.c' #11: n += 0x100;
inc (foo_$2_n, SP)
; ::: 'e5.c' #12: m -= 0x001201;
ldw X, (foo_$3_m+2, SP)
addw X, #0xedff
ldw (foo_$3_m+2, SP), X
ldw X, (foo_$3_m, SP)
jrnc .+1
incw X
ldw (foo_$3_m, SP), X
; ::: 'e5.c' #13: *p += 0x1;
ldw X, p
ldw Y, (2, X)
addw Y, #0x1
ldw (2, X), Y
ldw Y, (X)
jrnc .+2
incw Y
ldw (X), Y
; ::: 'e5.c' #14: *pp += 0x1100;
ldw X, pp
ldw Y, (1, X)
addw Y, #0x11
ldw (1, X), Y
jrnc L2
inc (X)
L2:
; ::: 'e5.c' #15: a += 2;
inc (foo_$1_a, SP)
inc (foo_$1_a, SP)
; ::: 'e5.c' #16: a -= 2;
dec (foo_$1_a, SP)
dec (foo_$1_a, SP)
add SP, #0x7
popw X
ret
.end
源程序2:
char n, m;
foo()
{
char a, b, *p1, *p2, const *p5;
int *p3, *p4;
a = b;
n = m;
*p1 = *p3;
*p4 = *p3;
}
汇编输出2:
;****************************************************************
; ATM8S C compiler - AT8CC, v0.10
; Wed Jul 21 10:58:08 2010
;****************************************************************
.device stm8s
.segment BANKi (REL)
n:: .rs 1
.segment BANKi (REL)
m:: .rs 1
.segment CODE2 (REL), foo
foo_$1_a .equ 1
foo_$2_b .equ 2
foo_$3_p1 .equ 3
foo_$4_p2 .equ 5
foo_$5_p5 .equ 7
foo_$6_p3 .equ 10
foo_$7_p4 .equ 12
; ::: 'e3.c' #3: foo()
foo::
pushw X
sub SP, #0xd
; ::: 'e3.c' #7: a = b;
ld A, (foo_$2_b, SP)
ld (foo_$1_a, SP), A
; ::: 'e3.c' #8: n = m;
mov n, m
; ::: 'e3.c' #9: *p1 = *p3;
ldw X, (foo_$6_p3, SP)
ld A, (1, X)
ldw X, (foo_$3_p1, SP)
ld (X), A
; ::: 'e3.c' #10: *p4 = *p3;
ldw X, (foo_$6_p3, SP)
ldw X, (X)
ldw Y, (foo_$7_p4, SP)
ldw (Y), X
add SP, #0xd
popw X
ret
.end |
|