68hc11 Cross-Compiler Test 3
- this page compares code generated by a Whitesmith's C cross compiler (target: 68hc11) with an unnamed competing product
- I purchased the Whitesmith's product from Intermetrics who sold the product line to Cosmic Software (crazy name but really neat products)
- Note: I used the Whitesmith's C cross compiler here
'C' Source Code
/*
* title : neil_3.c
* purpose: 68hc11 binary generation demo
* host : windows
*/
#define ushrt unsigned short
ushrt one,two,three,three_a;
/*
* use a function to do some top of stack math
*/
ushrt add_them(ushrt a, ushrt b)
{ return(a+b);
}
void main(void)
{ one = 1; /* init globals (ascending) */
two = 2;
three = 3;
three_a = 3;
three_a = add_them(one,two);
}
Output Code Listing From the COSMIC Software Compiler
Notes:
- program code size: 43-0+1=44 bytes
- notice the use of incb (1 byte) instead of ldd (3 bytes) on lines 23 + 26 3. function code: size: 10-0+1=11
bytes
1 ; C Compiler for MC68HC11 [COSMIC Software]
2 ; Version V4.0g - 16 Apr 1997
4 ; 12 ushrt add_them(ushrt a, ushrt b)
4 ; 13 { return(a+b);
5 0000 _add_them:
6 0000 3c pshx
7 pshd
8 0003 30 tsx
9 00000000 OFST: set 0
11 0004 ec00 ldd OFST+0,x
12 0006 e306 addd OFST+6,x
14 0008 38 pulx
15 0009 38 pulx
16 000a 39 rts
17 ; 16 void main(void)
17 ; 17 { one = 1; /* init globals (ascending) */
18 000b _main:
20 000b cc0001 ldd #1
21 000e fd0006 std _one
22 ; 18 two = 2;
23 0011 5c incb
24 0012 fd0004 std _two
25 ; 19 three = 3;
26 0015 5c incb
27 0016 fd0002 std _three
28 ; 20 three_a = 3;
29 0019 fd0000 std _three_a
30 ; 21 three_a = add_them(one,two);
31 001c fc0004 ldd _two
32 pshd
33 0021 fc0006 ldd _one
34 0024 8dda jsr _add_them
35 0026 31 ins
36 0027 31 ins
37 0028 fd0000 std _three_a
38 ; 22 }
39 002b 39 rts
40 xdef _main
41 xdef _add_them
42 switch .bss
43 0000 _three_a:
44 0000 0000 ds.b 2
45 xdef _three_a
46 0002 _three:
47 0002 0000 ds.b 2
48 xdef _three
49 0004 _two:
50 0004 0000 ds.b 2
51 xdef _two
52 0006 _one:
53 0006 0000 ds.b 2
54 xdef _one
55 end
Code Listing From a Competing Compiler
Notes:
- program code size: 49-0+1=50 bytes
- five different products produced almost the same output
- the compiler's optimizer switch was enabled 4. function code size: 10-0+1=11 bytes
1 $ lbra,hc11
2 defseg c_text,class=CODE
3 defseg c_const,class=CODE
4 defseg c_strings,class=CODE
5 defseg c_data,class=CODE
6 defseg c_bss,class=DATA
7 defseg c_rdata,class=CODE
8 defseg c_rbss,class=PAGE0
9 defseg c_temp,class=PAGE0,overlaid
10 defseg c_vectors,start=$FFC0,overlaid
11 seg c_temp
0000& (0004) 12 ctemp rmb 4
13 seg c_rbss
14 seg c_text
15 global _add_them
16 signat _add_them,8250
0000& 30 17 tsx
0001& ED 00 18 std 0,x
19 _add_them
0003& 3C 20 pshx
0004& 30 21 tsx
0005& EC 00 22 ldd 0,x
0007& E3 04 23 addd 4,x
0009& 38 24 pulx
000A& 39 25 rts
26 global _main
27 signat _main,24
28 global _one
29 global _two
30 global _three
31 global _three_a
32 _main
000B& CC 0001 33 ldd #1
000E& FD 0000& 34 std _one
35 ;neil_3.c: 18: two = 2;
0011& CC 0002 36 ldd #2
0014& FD 0006& 37 std _two
38 ;neil_3.c: 19: three = 3;
0017& CC 0003 39 ldd #3
001A& FD 0002& 40 std _three
41 ;neil_3.c: 20: three_a = 3;
001D& CC 0003 42 ldd #3
0020& FD 0004& 43 std _three_a
44 ;neil_3.c: 21: three_a = add_them(one,two);
0023& FE 0006& 45 ldx _two
0026& 3C 46 pshx
0027& FC 0000& 47 ldd _one
002A& BD 0003& 48 jsr _add_them
002D& 38 49 pulx
002E& FD 0004& 50 std _three_a
51 ;neil_3.c: 22: }
0031& 39 52 rts
53 seg c_bss
54 _one
0000& (0002) 55 rmb 2
56 _three
0002& (0002) 57 rmb 2
58 _three_a
0004& (0002) 59 rmb 2
60 _two
0006& (0002) 61 rmb 2
62
63 end
Back to
Home
Neil Rieck
Waterloo, Ontario, Canada.