diff options
author | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2013-03-25 23:55:47 +0000 |
---|---|---|
committer | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2013-03-25 23:55:47 +0000 |
commit | 63c34beadbf2a9cfd52aa91445f0124cc2a60079 (patch) | |
tree | fcbfee4007b76dd3b25fd09ca40ab17d86bac808 /rtl/inc | |
parent | f72adbe90246a30eb4e8186e1b3b9815dc53bf09 (diff) | |
download | fpc-63c34beadbf2a9cfd52aa91445f0124cc2a60079.tar.gz |
+ added Str() helpers for 32-bit ints for 16/8-bit CPUs
git-svn-id: http://svn.freepascal.org/svn/fpc/branches/i8086@24008 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'rtl/inc')
-rw-r--r-- | rtl/inc/astrings.inc | 24 | ||||
-rw-r--r-- | rtl/inc/compproc.inc | 19 | ||||
-rw-r--r-- | rtl/inc/sstrings.inc | 53 | ||||
-rw-r--r-- | rtl/inc/ustrings.inc | 22 |
4 files changed, 118 insertions, 0 deletions
diff --git a/rtl/inc/astrings.inc b/rtl/inc/astrings.inc index beef6d4a84..7ef49249f5 100644 --- a/rtl/inc/astrings.inc +++ b/rtl/inc/astrings.inc @@ -1190,6 +1190,30 @@ end; {$endif CPU64} +{$if defined(CPU16) or defined(CPU8)} +Procedure fpc_AnsiStr_LongWord(v : LongWord;Len : SizeInt; out S : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING});[Public,Alias : 'FPC_ANSISTR_LONGWORD']; compilerproc; {$IFNDEF VER2_0} Inline; {$ENDIF} +Var + SS : ShortString; +begin + str(v:Len,SS); + S:=SS; + {$ifdef FPC_HAS_CPSTRING} + SetCodePage(s,cp,false); + {$endif FPC_HAS_CPSTRING} +end; + +Procedure fpc_AnsiStr_LongInt(v : LongInt; Len : SizeInt; out S : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING});[Public,Alias : 'FPC_ANSISTR_LONGINT']; compilerproc; {$IFNDEF VER2_0} Inline; {$ENDIF} +Var + SS : ShortString; +begin + str (v:Len,SS); + S:=SS; + {$ifdef FPC_HAS_CPSTRING} + SetCodePage(s,cp,false); + {$endif FPC_HAS_CPSTRING} +end; +{$endif CPU16 or CPU8} + Procedure Delete(Var S : RawByteString; Index,Size: SizeInt); Var LS : SizeInt; diff --git a/rtl/inc/compproc.inc b/rtl/inc/compproc.inc index b00832afdc..da4776b2f6 100644 --- a/rtl/inc/compproc.inc +++ b/rtl/inc/compproc.inc @@ -125,6 +125,25 @@ procedure fpc_AnsiStr_Currency(c : currency;len,fr : SizeInt;out s : RawByteStri procedure fpc_UnicodeStr_int64(v : int64;len : SizeInt;out s : UnicodeString); compilerproc; {$endif FPC_HAS_FEATURE_WIDESTRINGS} {$endif CPU64} +{$if defined(CPU16) or defined(CPU8)} + procedure fpc_shortstr_longword(v : longword;len : SizeInt;out s : shortstring); compilerproc; + procedure fpc_shortstr_longint(v : longint;len : SizeInt;out s : shortstring); compilerproc; + procedure fpc_chararray_longword(v : longword;len : SizeInt;out a : array of char); compilerproc; + procedure fpc_chararray_longint(v : longint;len : SizeInt;out a : array of char); compilerproc; + {$ifdef FPC_HAS_FEATURE_ANSISTRINGS} + procedure fpc_ansistr_longword(v : longword;len : SizeInt;out s : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc; + procedure fpc_ansistr_longint(v : longint;len : SizeInt;out s : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc; + {$endif FPC_HAS_FEATURE_ANSISTRINGS} + + {$ifdef FPC_HAS_FEATURE_WIDESTRINGS} + {$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING} + procedure fpc_widestr_longword(v : longword;len : SizeInt;out s : widestring); compilerproc; + procedure fpc_widestr_longint(v : longint;len : SizeInt;out s : widestring); compilerproc; + {$endif ndef FPC_WIDESTRING_EQUAL_UNICODESTRING} + procedure fpc_UnicodeStr_longword(v : longword;len : SizeInt;out s : UnicodeString); compilerproc; + procedure fpc_UnicodeStr_longint(v : longint;len : SizeInt;out s : UnicodeString); compilerproc; + {$endif FPC_HAS_FEATURE_WIDESTRINGS} +{$endif CPU16 or CPU8} {$ifdef FPC_HAS_FEATURE_WIDESTRINGS} {$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING} {$ifndef FPUNONE} diff --git a/rtl/inc/sstrings.inc b/rtl/inc/sstrings.inc index 2adf56618f..9b8e0707b0 100644 --- a/rtl/inc/sstrings.inc +++ b/rtl/inc/sstrings.inc @@ -448,6 +448,23 @@ end; {$endif CPU64} +{$if defined(CPU16) or defined(CPU8)} +procedure fpc_shortstr_longword(v : longword;len : SizeInt;out s : shortstring);[public,alias:'FPC_SHORTSTR_LONGWORD']; compilerproc; +begin + int_str_unsigned(v,s); + if length(s)<len then + s:=space(len-length(s))+s; +end; + + +procedure fpc_shortstr_longint(v : longint;len : SizeInt;out s : shortstring);[public,alias:'FPC_SHORTSTR_LONGINT']; compilerproc; +begin + int_str(v,s); + if length(s)<len then + s:=space(len-length(s))+s; +end; +{$endif CPU16 or CPU8} + { fpc_shortstr_sInt must appear before this file is included, because } { it's used inside real2str.inc and otherwise the searching via the } @@ -869,6 +886,42 @@ end; {$endif CPU64} +{$if defined(CPU16) or defined(CPU8)} + +procedure fpc_chararray_longword(v : longword;len : SizeInt;out a : array of char);compilerproc; +var + ss : shortstring; + maxlen : SizeInt; +begin + int_str_unsigned(v,ss); + if length(ss)<len then + ss:=space(len-length(ss))+ss; + if length(ss)<high(a)+1 then + maxlen:=length(ss) + else + maxlen:=high(a)+1; + fpc_shortstr_chararray_intern_charmove(ss,a,maxlen); +end; + + +procedure fpc_chararray_longint(v : longint;len : SizeInt;out a : array of char);compilerproc; +var + ss : shortstring; + maxlen : SizeInt; +begin + int_str(v,ss); + if length(ss)<len then + ss:=space(len-length(ss))+ss; + if length(ss)<high(a)+1 then + maxlen:=length(ss) + else + maxlen:=high(a)+1; + fpc_shortstr_chararray_intern_charmove(ss,a,maxlen); +end; + +{$endif CPU16 or CPU8} + + {$ifndef FPUNONE} procedure fpc_chararray_Float(d : ValReal;len,fr,rt : SizeInt;out a : array of char);compilerproc; var diff --git a/rtl/inc/ustrings.inc b/rtl/inc/ustrings.inc index 908920de4f..45162e0b60 100644 --- a/rtl/inc/ustrings.inc +++ b/rtl/inc/ustrings.inc @@ -1557,6 +1557,28 @@ end; {$endif CPU64} +{$if defined(CPU16) or defined(CPU8)} + +Procedure fpc_UnicodeStr_LongInt(v : LongInt; Len : SizeInt; out S : UnicodeString);compilerproc; +Var + SS: ShortString; +begin + Str (v:Len,SS); + S:=UnicodeString(SS); +end; + + +Procedure fpc_UnicodeStr_LongWord(v : LongWord;Len : SizeInt; out S : UnicodeString);compilerproc; +Var + SS: ShortString; +begin + str(v:Len,SS); + S:=UnicodeString(SS); +end; + +{$endif CPU16 or CPU8} + + function UnicodeToUtf8(Dest: PChar; Source: PUnicodeChar; MaxBytes: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif} begin if assigned(Source) then |