gcc port to 6811 :(
John S Gwynne
jsg
Tue Dec 13 02:52:25 GMT 1994
--------
I took the time over this past weekend to build the
Coactive gcc port for the 68hc11. I must say I'm not
impressed with its output. Consider the following
example:
-------- cut here ------
int a[10];
main()
{
int i;
for (i=0; i<10; i++)
a[i]=i;
}
-------- cut here ------
The resulting code (with a -O; higher levels of
optimization didn't do much better) is
-------- cut here ------
1 ;;;-----------------------------------------
2 ;;; Start MC6811 gcc assembly output
3 ;;; gcc compiler compiled on TBD
4 ;;; OPTIONS: -mlong_branch -mnogrom_lib optimize !strength_reduce
5 ;;; OPTIONS: peephole !omit_frame_pointer si
gned-char
6 ;;; Source: t.c
7 ;;; Destination: /usr/tmp/cca10840.s
8 ;;; Compiled: Mon Dec 12 21:02:06 1994
9 ;;; (META)compiled by GNU C version 2.6.3.
10 ;;;-----------------------------------------
11 .area _CODE
12 .globl _main
0000 13 _main:
14 ;;;-----------------------------------------
15 ;;; PROLOGUE for main
16 ;;;-----------------------------------------
0000 18 3C 17 pshy ; Save stack frame
0002 18 30 18 tsy ; Set current stack frame
0004 DE 00 19 ldx *ZD1
0006 3C 20 pshx ; pushed register *ZD1
0007 DE 00 21 ldx *ZD2
0009 3C 22 pshx ; pushed register *ZD2
000A DE 00 23 ldx *ZD3
000C 3C 24 pshx ; pushed register *ZD3
000D DE 00 25 ldx *ZD4
000F 3C 26 pshx ; pushed register *ZD4
0010 DE 00 27 ldx *ZX1
0012 3C 28 pshx ; pushed register *ZX1
0013 DE 00 29 ldx *ZX2
0015 3C 30 pshx ; pushed register *ZX2
31 ;;;END PROLOGUE
0016 BD 00 00 32 jsr ___main ; CALL: (VOIDmode) ___main (0 bytes)
0019 CC 00 00 33 ldd #0
001C DD 00 34 std *ZD2 ; movhi: #0 -> *ZD2
001E CC 00 09 35 ldd #9
0021 DD 00 36 std *ZX2 ; movhi: #9 -> *ZX2
0023 CC 00 00 37 ldd #_a
0026 DD 00 38 std *ZD4 ; movhi: #_a -> *ZD4
0028 CC 00 01 39 ldd #1
002B DD 00 40 std *ZD3 ; movhi: #1 -> *ZD3
002D 41 L5:
002D DC 00 42 ldd *ZD2
002F DD 00 43 std *ZD1 ; movhi: *ZD2 -> *ZD1
0031 DC 00 44 ldd *ZD1
0033 05 45 asld
0034 DD 00 46 std *ZD1 ; ashlhi3: *ZD1 by #1
0036 DC 00 47 ldd *ZD1
0038 D3 00 48 addd *ZD4
003A DD 00 49 std *ZD1 ; addhi3: *ZD1 by *ZD4
003C DC 00 50 ldd *ZD1
003E DD 00 51 std *ZX1 ; movhi: *ZD1 -> *ZX1
0040 DC 00 52 ldd *ZD2
0042 DE 00 53 ldx *ZX1
0044 ED 00 54 std 0,x ; movhi: *ZD2 -> 0,x
0046 DC 00 55 ldd *ZD2
0048 D3 00 56 addd *ZD3
004A DD 00 57 std *ZD2 ; addhi3: *ZD2 by *ZD3
004C DC 00 58 ldd *ZD2
004E 1A 93 00 59 cpd *ZX2 ; cmphi *ZD2 with *ZX2
0051 2E 03 60 bgt .+5
0053 7E 00 2D 61 jmp L5 ; (ble) long branch
0056 38 62 pulx ; Pulling register *ZX2
0057 DF 00 63 stx *ZX2
0059 38 64 pulx ; Pulling register *ZX1
005A DF 00 65 stx *ZX1
005C 38 66 pulx ; Pulling register *ZD4
005D DF 00 67 stx *ZD4
005F 38 68 pulx ; Pulling register *ZD3
0060 DF 00 69 stx *ZD3
0062 38 70 pulx ; Pulling register *ZD2
0063 DF 00 71 stx *ZD2
0065 38 72 pulx ; Pulling register *ZD1
0066 DF 00 73 stx *ZD1
74 ;;;EPILOGUE
0068 18 38 75 puly ; Restore stack frame
006A 39 76 rts ; return from function
77 ;;;-----------------------------------------
78 ;;; END EPILOGUE for main
79 ;;;-----------------------------------------
80 .area _DATA
81 .globl _a
0000 82 _a: .blkb 20
83 ; END
-------- cut here ------
For reference, the code between line 41 and 51 is only 3
instructions (L11: move.l %d0,(%a0); subq.w #4,%a0; dbra
%d0,.L11) for the 68k (with a -O4) and that is with
32-bit integers and addresses.
So, why does the hc11 port look so bad. First, the 68hc11
can not manage the frame pointer as expected by gcc;
hence, all of the pulx/pshx instructions. Second, not
enough 16-bit registers (double accumulators). This is
made up for by "simulated" registers like ZD0, ZD1,...
The result is not very impressive. Even when the int's
are changed to 'signed char's (bytes)', by the time sign
extension is applied for addressing (which uses ZD0 type
registers...), the code is still not very
impressive. Perhaps someone could post the output of ic11
for this program.
Bottom line: I would not recommend gcc for the 68hc11;
use a compiler better optimized for the hc11's
architecture. In contrast, gcc works very well with the
68k family.
John S Gwynne
Gwynne.1 at osu.edu
_______________________________________________________________________________
T h e O h i o - S t a t e U n i v e r s i t y
ElectroScience Laboratory, 1320 Kinnear Road, Columbus, Ohio 43212, USA
Telephone: (614) 292-7981 * Fax: (614) 292-7292
-------------------------------------------------------------------------------
More information about the Diy_efi
mailing list