Sign in Join

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

Mailing lists / fpc-pascal / 2006-08

Ansi strings

6 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Carsten Bager

Here is 2 examples of how the fpc compiler dos when comparing a string constant with a pchar . The first is compiled with the 204 compiler and second one is compiled with the 202 compiler. I am using the compiler on an embedded Arm 7 platform and Ansi strings is not an option.
I want to force the 204 compiler to use short strings but the only option I can se, that have anything to do with strings is the (-Sh use ansistrings) and that is just the opposite of what I want. Any hints?

Carsten

----------------------- 204 --------------------------------- .stabn 68,0,198,.Ll126 - Beas_Do_Text_Write
# [198] if FileName=BeasTyp.COM1name then
ldr r0,.L672
ldr r4,[r0]
sub r0,r11,#120
bl FPC_ANSISTR_DECR_REF
ldr r0,[r11, #-44]
bl fpc_pchar_to_ansistr
str r0,[r11, #-120]
ldr r0,[r11, #-120]
mov r1,r4
bl fpc_ansistr_compare
cmp r0,#0
beq .L665
b .L666
------------------ 202 ------------------------------------- .stabn 68,0,198,.Ll124 - Beas_Do_Text_Write
# [198] if FileName=BeasTyp.COM1name then
ldr r4,.L615
ldr r1,[r11, #-44]
sub r0,r11,#312
bl fpc_pchar_to_shortstr
sub r0,r11,#312
mov r1,r4
bl fpc_shortstr_compare
cmp r0,#0
beq .L610
b .L611

Carsten Bager
Show quoted text 11 lines
Hi, sorry, I cannot answer your question, but may I as: Am Donnerstag, den 31.08.2006, 13:13 +0200 schrieb Carsten Bager: > I am using the compiler on an embedded Arm 7 platform and Ansi > strings is not an option. How can you do this?

The 2.0.2 supports the ARM processor (for Linux). You can download it from the Free Pascal site
(http://www.freepascal.org/download.html)
If you are interested in embedded programming, I will in short time put together a starters kit based on the 2.0.2 compiler. If you are interested send a mail (in plain text) to with the text SUBSCRIBE ARM7

When I have the kit ready, I will send a announcement when and where you can get the starters kit.

Show quoted text 51 lines
In fpc 2.0.2 I see no support for ARM CPU, but I am strongly itnerested in using this processor, too. TIA, Marc $ fpc -i Free Pascal Compiler version 2.0.2 Compiler Date : 2005/11/17 Compiler CPU Target: i386 Supported targets: GO32 V2 DOS extender Linux for i386 OS/2 Win32 for i386 FreeBSD/ELF for i386 Solaris for i386 (under development) Beos for i386 (under development) NetBSD for i386 (under development) Netware for i386(clib) WDOSX DOS extender OpenBSD for i386 (under development) OS/2 via EMX Watcom compatible DOS extenders Netware for i386(libc) Linux for x64_6432 Supported CPU instruction sets: 386 PENTIUM PENTIUM2 PENTIUM3 PENTIUM4 Supported FPU instruction sets: SOFT X87 SSE SSE2 This program comes under the GNU General Public Licence For more information read COPYING.FPC Report bugs,suggestions etc to:
Michael Van Canneyt
to Carsten Bager
Carsten Bager wrote 19 lines
> Hi, > > sorry, I cannot answer your question, but may I as: > > > Am Donnerstag, den 31.08.2006, 13:13 +0200 schrieb Carsten Bager: > >> I am using the compiler on an embedded Arm 7 platform and Ansi >> strings is not an option. > > How can you do this? The 2.0.2 supports the ARM processor (for Linux). You can download it from the Free Pascal site (http://www.freepascal.org/download.html) If you are interested in embedded programming, I will in short time put together a starters kit based on the 2.0.2 compiler. If you are interested send a mail (in plain text) to with the text SUBSCRIBE ARM7

Why not use the newly released 2.0.4 compiler? it supports arm too ?

Michael.

Jonas Maebe
to Carsten Bager: Here is 2 examples of how the fpc compiler dos when comparing a string constant with a…
Carsten Bager wrote
Here is 2 examples of how the fpc compiler dos when comparing a string constant with a pchar . The first is compiled with the 204 compiler and second one is compiled with the 202 compiler.

The reason we now favour ansistring of shortstring in case of pchars is that pchars can be longer than 255 characters. In the particular case you mention (comparing a pchar with a constant string < 255 characters) a shortstring would be possible too, but the type conversion code here does not look at the contents of the nodes, only a their types.

Show quoted text 6 lines
I am using the compiler on an embedded Arm 7 platform and Ansi strings is not an option. I want to force the 204 compiler to use short strings but the only option I can se, that have anything to do with strings is the (-Sh use ansistrings) and that is just the opposite of what I want. Any hints?

You cannot force this other than by explicitly typecasting the pchar to shortstring in the comparison.

Jonas

Carsten Bager
to Jonas Maebe
Show quoted text 23 lines
On 31 aug 2006, at 13:13, Carsten Bager wrote: > Here is 2 examples of how the fpc compiler dos when comparing a > string constant with a pchar . The first is compiled with the 204 > compiler and second one is compiled with the 202 compiler. The reason we now favour ansistring of shortstring in case of pchars is that pchars can be longer than 255 characters. In the particular case you mention (comparing a pchar with a constant string < 255 characters) a shortstring would be possible too, but the type conversion code here does not look at the contents of the nodes, only a their types. > I am using the compiler on an embedded Arm 7 platform and Ansi > strings is not an option. > I want to force the 204 compiler to use short strings but the only > option I can se, that have anything to do with strings is the (-Sh use > ansistrings) and that is just the opposite of what I want. > Any hints? You cannot force this other than by explicitly typecasting the pchar to shortstring in the comparison.

I have discovered that I can use the {$LONGSTRINGS OFF} directive, is this a god way or should I typecast? It would be nice if there were a switch that could be put in the CFG file that forced the compiler to use short strings.

Show quoted text 6 lines
Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Marc Santhoff
to Michael Van Canneyt: Why not use the newly released 2.0.4 compiler? it supports arm too ? Michael.
Michael Van Canneyt wrote 24 lines
On Fri, 1 Sep 2006, Carsten Bager wrote: >> Hi, >> >> sorry, I cannot answer your question, but may I as: >> >> >> Am Donnerstag, den 31.08.2006, 13:13 +0200 schrieb Carsten Bager: >> >>> I am using the compiler on an embedded Arm 7 platform and Ansi >>> strings is not an option. >> >> How can you do this? > > The 2.0.2 supports the ARM processor (for Linux). You can > download it from the Free Pascal site > (http://www.freepascal.org/download.html) > If you are interested in embedded programming, I will in short time > put together a starters kit based on the 2.0.2 compiler. If you are > interested send a mail (in plain text) to with the text > SUBSCRIBE ARM7 Why not use the newly released 2.0.4 compiler? it supports arm too ?

1. I can't switch compiler versions at any time.
2. I don't want to fiddle with two of them (been there done that ;)
3. I'm curious and want to know how this guy does magic with fpc. ;)

4. Until the ARM board is ready I'm looking for anything regarding fpc and arm cpu.
5. I wouldn't have known about Carsten Bager doing something on arm if I did not ask. ... ;))

Marc