68hc11 Cross-Compiler Test 2
- 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 on this project
'C' Source Code
/*
* title : neil_2.c
* purpose: 68hc11 binary generation demo
* host : Windows
*/
#define uchr unsigned char
uchr one,two,three,three_a;
/*
* use a function to do some top of stack math
*/
uchr add_them(uchr a, uchr b)
{ return(a+b);
}
void main(void)
{ one = 1; /* init globals (ascending data) */
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 ldab (2 bytes) on lines 23 + 26
- function code size: 10-0+1=11 bytes
1 ; C Compiler for MC68HC11 [COSMIC Software]
2 ; Version V4.0g - 16 Apr 1997
4 ; 12 uchr add_them(uchr a, uchr 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 e601 ldab OFST+1,x
12 0006 eb07 addb OFST+7,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 data) */
18 000b _main:
20 000b c601 ldab #1
21 000d f70003 stab _one
22 ; 18 two = 2;
23 0010 5c incb
24 0011 f70002 stab _two
25 ; 19 three = 3;
26 0014 5c incb
27 0015 f70001 stab _three
28 ; 20 three_a = 3;
29 0018 f70000 stab _three_a
30 ; 21 three_a = add_them(one,two);
31 001b f60002 ldab _two
32 001e 4f clra
33 pshd
34 0021 f60003 ldab _one
35 0024 8dda jsr _add_them
36 0026 31 ins
37 0027 31 ins
38 0028 f70000 stab _three_a
39 ; 22 }
40 002b 39 rts
41 xdef _main
42 xdef _add_them
43 switch .bss
44 0000 _three_a:
45 0000 00 ds.b 1
46 xdef _three_a
47 0001 _three:
48 0001 00 ds.b 1
49 xdef _three
50 0002 _two:
51 0002 00 ds.b 1
52 xdef _two
53 0003 _one:
54 0003 00 ds.b 1
55 xdef _one
56 end
Code Listing From a Competing Compiler
Notes:
- program code size: 45-0+1 = 46 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,8249
0000& 30 17 tsx
0001& E7 00 18 stab 0,x
19 _add_them
0003& 34 20 des
0004& 30 21 tsx
0005& E6 00 22 ldab 0,x
0007& EB 03 23 addb 3,x
0009& 31 24 ins
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& C6 01 33 ldab #1
000D& F7 0000& 34 stab _one
35 ;neil_2.c: 18: two = 2;
0010& C6 02 36 ldab #2
0012& F7 0003& 37 stab _two
38 ;neil_2.c: 19: three = 3;
0015& C6 03 39 ldab #3
0017& F7 0001& 40 stab _three
41 ;neil_2.c: 20: three_a = 3;
001A& C6 03 42 ldab #3
001C& F7 0002& 43 stab _three_a
44 ;neil_2.c: 21: three_a = add_them(one,two);
001F& F6 0003& 45 ldab _two
0022& 37 46 pshb
0023& F6 0000& 47 ldab _one
0026& BD 0003& 48 jsr _add_them
0029& 31 49 ins
002A& F7 0002& 50 stab _three_a
51 ;neil_2.c: 22: }
002D& 39 52 rts
53 seg c_bss
54 _one
0000& (0001) 55 rmb 1
56 _three
0001& (0001) 57 rmb 1
58 _three_a
0002& (0001) 59 rmb 1
60 _two
0003& (0001) 61 rmb 1
62
63 end
Back to
Home
Neil Rieck
Waterloo, Ontario, Canada.