[fpc-pascal] Embedded ARM7 and long strings

2013-07-24 Thread Carsten Bager
I am using the FPC compiler to compile embedded ARM7 code (LPC21xx / LPC23xx).
For this purpose, I use the 2.05 compiler, and it is working without problems 
at all.
However, because we are using the 2.62 compiler on other platforms, I have 
compiled a new
system unit for the ARM7 platform with the 2.62 compiler. I then ran into this 
problem.

The old compiler uses "fpc_chararray_to_shortstr" to comvert from an array of 
char to a
shortstring. That works OK.

The 2.62 compiler wants to use "fpc_chararray_to_ansistr" to the same job, and 
that is a
problem because my ARM7 system unit do not support ansistrings (and should not).

The {$LONGSTRINGS OFF} directive is given at the beginning of the program, and 
that
eliminates any problems with "long strings" using the 2.05 compiler. That does 
not seem to
work with the new compiler.

Is there a way around this problem?

Carsten



FPC 2.05
# [38] Val(pChar16(LineDataOfset)^,NameDataOfset,p);
sub r5,r11,#568
ldr r0,.L57
ldr r4,[r0]
mov r3,#1
mov r2,#15
mov r1,r4
sub r0,r11,#824
bl  fpc_chararray_to_shortstr
sub r1,r11,#824
mov r0,#4
mov r2,r5
bl  fpc_val_sint_shortstr
ldr r1,.L68
str r0,[r1]
ldr r0,.L71
sub r3,r11,#568
mov r2,#2
.L72:
ldrbr1,[r3], #1
subsr2,r2,#1
strbr1,[r0], #1
bne .L72

FPC 2.62
# [38] Val(pChar16(LineDataOfset)^,NameDataOfset,p);
sub r0,r11,#628
bl  FPC_ANSISTR_DECR_REF
mov r0,#0
str r0,[r11, #-628]
ldr r0,.Lj13
ldr r1,[r0]
sub r0,r11,#628
mov r3,#1
mov r2,#15
bl  fpc_chararray_to_ansistr
ldr r1,[r11, #-628]
sub r2,r11,#116
mov r0,#4
bl  fpc_val_sint_ansistr
ldr r1,.Lj70
str r0,[r1]
ldrbr0,[r11, #-116]
ldr r1,.Lj73
strbr0,[r1]
ldrbr0,[r11, #-115]
strbr0,[r1, #1]
.stabn 68,0,39,_$LINEINFO$_Ll9 -




unit lineinfo;
{$LONGSTRINGS OFF}
{$Assertions off}
{$RANGECHECKS OFF}
{$OVERFLOWCHECKS OFF}
{$S- STACK CHECKING OFF}


interface

procedure GetLineInfo(addr:pointer; var 
FuncStringListPointer,SrcStringListPointer:pChar;
var line:longWord);


implementation
uses
  LineInfoTyp;

var
  data_beg_src:byte; external name '__data_beg_src__';
  data_beg:byte; external name '__data_beg__';
  data_end:byte; external name '__data_end__';
  LineDataOfset,EndLineDataOfset,NameDataOfset:Longint; {Skal være 
longint}
  p:integer;

Type
  Char16=array[0..15] of char;
  pChar16=^Char16;
  pArm7LineInfo=^Arm7LineInfo_typ;

procedure GetLineInfo(addr:pointer; var 
FuncStringListPointer,SrcStringListPointer:pChar;
var line:longWord);
Begin
  LineDataOfset:=(Longint(@data_end)-Longint(@data_beg))+Longint(@data_beg_src);
  if (byte(LineDataOfset) and $0F)<>0 then
LineDataOfset:=(LineDataOfset and $FFF0) +$10;
  if pChar16(LineDataOfset)^ = cLineDataOfsetString then
  begin
LineDataOfset:=LineDataOfset+16;
Val(pChar16(LineDataOfset)^,NameDataOfset,p);
if p=0 then
begin
  LineDataOfset:=LineDataOfset+16;
  NameDataOfset:=NameDataOfset+LineDataOfset;
  EndLineDataOfset:=NameDataOfset;
  if pChar16(NameDataOfset)^ = cNameDataOfsetString then
  begin
NameDataOfset:=NameDataOfset+32;
while LineDataOfsetlongword(addr) then
  begin
LineDataOfset:=LineDataOfset-16;
line:=pArm7LineInfo(LineDataOfset)^.line;

longint(FuncStringListPointer):=longint(pArm7LineInfo(LineDataOfset)^.FuncStringListPointer
)+NameDataOfset;

longint(SrcStringListPointer):=longint(pArm7LineInfo(LineDataOfset)^.SrcStringListPointer)+
NameDataOfset;
exit;
  end;
  LineDataOfset:=LineDataOfset+16;
end;
  end else runerror(48);{Error finding Str. Ofset}
end else runerror(49);  {Error in val of str. Of.}
  end else runerror(50);{Error finding Data Ofset}
End;

end.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] RE: FPIDE 1.0.6

2013-07-24 Thread Mark Morgan Lloyd

Pierre Free Pascal wrote:

  The version of the IDE is different from the compiler version.

Could you please tell us the compiler version?
It can be found in "Help|About" menu entry.

Even compiler version 2.4.0 already has IDE version 1.0.12...
Thus I suspect that 1.0.6 corresponds to a really old compiler.
It will be difficult to get feedback on outdate releases...


/If/ that's the case, then he's got FPC 2.0.2.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal