Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2003-06

68k codegen patch

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Balogh, Karoly (Charlie/iNQ

Hi,

Here is my first fix to the 68k codegenerator. Hope it's ok. It's needed because the original codegenerator sometimes generated instructions like lsl.l #10,d2 which is definitely not a really good idea, and GNU AS screamed... :)

Example code:

Program Bug2;
Var BigArray : Array[0..64,0..255] Of DWord;
    Counter,Counter2  : DWord;
Begin
 For Counter:=0 To 64 Do Begin
   For Counter2:=0 To 255 Do Begin
     BigArray[Counter,Counter2]:=1;
    End;
  End;
End.

Compiled (without my patch):

movel #0,_COUNTER
.L5:
movel #0,_COUNTER2
.L10:
movel _COUNTER,%d2
lea _BIGARRAY,%a2
lsll #10,%d2 <--- WHOOPS!!!
movel _COUNTER2,%d3
lea (%a2,%d2.l),%a3
lsll #2,%d3
movel #1,(%a3,%d3.l)
cmpl #255,_COUNTER2
bcc .L9
addql #1,_COUNTER2
jmp .L10
.L9:
cmpl #64,_COUNTER
bcc .L4
addql #1,_COUNTER
jmp .L5
.L4:

Same code compiled, with my patch:

movel #0,_COUNTER
.L5:
movel #0,_COUNTER2
.L10:
movel _COUNTER,%d2
lea _BIGARRAY,%a2
moveql #10,%d0 <- better huh? :)
lsll %d0,%d2 <-
movel _COUNTER2,%d3
lea (%a2,%d2.l),%a3
lsll #2,%d3
movel #1,(%a3,%d3.l)
cmpl #255,_COUNTER2
bcc .L9
addql #1,_COUNTER2
jmp .L10
.L9:
cmpl #64,_COUNTER
bcc .L4
addql #1,_COUNTER
jmp .L5
.L4:

Patch attached. Should be applied to /compiler/m68k/cgmem.pas in the fixes branch.

Bye,

Charlie/iNQ .:%[ Cybernetic Hydraulic Android Responsible for ]%:. .:%[ Logical Infiltration and Exploration ]%:. .:%[ Member of TeamOS/2 Hungary ]%:. .:%[ Member of Hungarian Amiga User Group ]%:.

Reply by email