Browse Source

* avr: take advantage of sbiw in mod/div_word
+ test

florian 11 months ago
parent
commit
5c91c89aea
3 changed files with 9 additions and 3 deletions
  1. 9 1
      rtl/avr/math.inc
  2. 0 1
      tests/test/cg/tdivz1.pp
  3. 0 1
      tests/test/cg/tdivz2.pp

+ 9 - 1
rtl/avr/math.inc

@@ -30,7 +30,7 @@ asm
   cp R24, R17
 {$else CPUAVR_16_REGS}
   cp R24, R1
-{$endif CPUAVR_16_REGS}  
+{$endif CPUAVR_16_REGS}
   brne .LNonZero
 {$ifdef CPUAVR_HAS_JMP_CALL}
   call fpc_divbyzero
@@ -96,8 +96,12 @@ asm
   cp R24, R17
   cpc R25, R17
 {$else CPUAVR_16_REGS}
+{$ifdef CPUAVR_HAS_ADIW}
+  sbiw R24,0
+{$else CPUAVR_HAS_ADIW}
   cp R24, R1
   cpc R25, R1
+{$endif CPUAVR_HAS_ADIW}
 {$endif CPUAVR_16_REGS}
   brne .LNonZero
 {$ifdef CPUAVR_HAS_JMP_CALL}
@@ -136,8 +140,12 @@ asm
   cp R24, R17
   cpc R25, R17
 {$else CPUAVR_16_REGS}
+{$ifdef CPUAVR_HAS_ADIW}
+  sbiw R24,0
+{$else CPUAVR_HAS_ADIW}
   cp R24, R1
   cpc R25, R1
+{$endif CPUAVR_HAS_ADIW}
 {$endif CPUAVR_16_REGS}
   brne .LNonZero
 {$ifdef CPUAVR_HAS_JMP_CALL}

+ 0 - 1
tests/test/cg/tdivz1.pp

@@ -28,7 +28,6 @@ var
   int64res : int64;
   int64cnt : int64;
 begin
-
   { RIGHT : LOC_REFERENCE }
   { LEFT : LOC_REGISTER   }
   int64res := 1;

+ 0 - 1
tests/test/cg/tdivz2.pp

@@ -26,7 +26,6 @@ var
   longres : longint;
   longcnt : longint;
 begin
-
   longres := 1;
   longcnt := 0;
   longres := longres div longcnt;