From 43d8da7aa3525105e9098f5d10d5a5bb43d23cdb Mon Sep 17 00:00:00 2001 From: svenbarth Date: Thu, 18 Oct 2012 20:11:45 +0000 Subject: [PATCH] Replace DBRA instruction for Coldfire with a SUB/BRA combination in the for-loop-code- generation and the assembly helpers in the RTL as DBRA is not supported by Coldfire. git-svn-id: trunk@22740 - --- compiler/m68k/cgcpu.pas | 9 ++++++++- rtl/m68k/m68k.inc | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/compiler/m68k/cgcpu.pas b/compiler/m68k/cgcpu.pas index 0b393bcb6f..1eb5a63b23 100644 --- a/compiler/m68k/cgcpu.pas +++ b/compiler/m68k/cgcpu.pas @@ -1440,7 +1440,14 @@ unit cgcpu; a_label(list,hl); list.concat(taicpu.op_ref_ref(A_MOVE,S_B,hp1,hp2)); a_label(list,hl2); - list.concat(taicpu.op_reg_sym(A_DBRA,S_L,hregister,hl)); + if current_settings.cputype=cpu_coldfire then + begin + { Coldfire does not support DBRA } + list.concat(taicpu.op_const_reg(A_SUB,S_L,1,hregister)); + list.concat(taicpu.op_sym(A_BMI,S_L,hl)); + end + else + list.concat(taicpu.op_reg_sym(A_DBRA,S_L,hregister,hl)); end; { restore the registers that we have just used olny if they are used! } diff --git a/rtl/m68k/m68k.inc b/rtl/m68k/m68k.inc index d007587ab5..8a28cc3590 100644 --- a/rtl/m68k/m68k.inc +++ b/rtl/m68k/m68k.inc @@ -95,7 +95,12 @@ procedure FillChar(var x;count:longint;value:byte); assembler; @LMEMSET4: { fast loop mode section 68010+ } move.b d0,(a0)+ @LMEMSET3: +{$ifdef CPUCOLDFIRE} + sub.l #1,d1 + bmi @LMEMSET4 +{$else} dbra d1,@LMEMSET4 +{$endif} @LMEMSET5: end ['d0','d1','a0']; @@ -137,7 +142,12 @@ asm @LMSTRCOPY56: { 68010 Fast loop mode } move.b (a0)+,(a1)+ @LMSTRCOPY55: +{$ifdef CPUCOLDFIRE} + sub.l #1,d1 + bmi @LMSTRCOPY56 +{$else} dbra d1,@LMSTRCOPY56 +{$endif} @Lend: end; @@ -172,7 +182,12 @@ procedure strconcat(s1,s2 : pointer);[public,alias: 'STRCONCAT']; @Loop: move.b (a1)+,(a0)+ { s1[i] := s2[i]; } @ALoop: +{$ifdef CPUCOLDFIRE} + sub.l #1,d6 + bmi @Loop +{$else} dbra d6,@Loop +{$endif} move.l s1,a0 add.b d0,(a0) { change to new string length } @Lend: @@ -270,12 +285,22 @@ begin @LMOVE01: move.b -(a0),-(a1) { (s < d) copy loop } @LMOVE02: +{$ifdef CPUCOLDFIRE} + sub.l #1,d0 + bmi @LMOVE01 +{$else} dbra d0,@LMOVE01 +{$endif} bra @LMOVE5 @LMOVE03: move.b (a0)+,(a1)+ { (s >= d) copy loop } @LMOVE04: +{$ifdef CPUCOLDFIRE} + sub.l #1,d0 + bmi @LMOVE03 +{$else} dbra d0,@LMOVE03 +{$endif} { end fast loop mode } @LMOVE5: end ['d0','a0','a1'];