Re: [fpc-pascal] case statement
statement list = statement { ";" statement } statementlist itself is not explained; I assume "statementlist" to be the same as "statement list" It is included in the definition of the try...except statement. ELSE/OTHERWISE I assume that came historically; the first implementation of a PASCAL compiler I have seen had no else or otherwise in the case startement. Some ater dialects introduced ELSE, other dialect(s) used OTHERWISE, FPC then allowed both. Ambiguity: It is so. I was a bit astonished. i := 4 ; case i of 1, 2: if odd ( i ) then write ( 'odd' ) else write ( 'even' ) ; end ; produces nothing, else is part of the if statement, in case of ambiguity the nearest possibility is used. i := 4 ; case i of 1, 2: if odd ( i ) then write ( 'odd' ) ; else write ( 'even' ) ; end ; produces the print 'even', else is part of the case statement As I read the syntax of the case statement in ref.pdf, the semicolon before the else is not even allowed. the syntax is (see below) case-statement = "CASE" expression "OF" case { ";" case } [ else-part ] [ ";" ] . if you change that to case-statement = "CASE" expression "OF" case { ";" case } [ ";" ] [ else-part [ ";" ] ] . then you have what the compiler does. I never had the problem because before the else I always inserted a ";" - Original Message - From: "Adriaan van Os via fpc-pascal" To: "FPC-Pascal users discussions" Cc: "Adriaan van Os" Sent: Thursday, December 14, 2023 4:53 PM Subject: [fpc-pascal] case statement I am looking in detail at the syntax diagrams in the Freepascal Language Reference (version 3.2.0) Section 13.2.2 discusses the case-statement. Translated to EBNF (WSN) the syntax is case-statement = "CASE" expression "OF" case { ";" case } [ else-part ] [ ";" ] . case = constant [ ".." constant ] { "," constant [ ".." constant ] } ":" statement . else-part = [ "ELSE" | "OTHERWISE" ] statementlist . If this is correct (and the compiler really allows it) then a semicolon between and is not required. Consequently, there is an ambiguity between an if-then-else statement (as last statement of the ) and an if-then statement (as last statement of the ) and an . This is extremely dangerous and I feel that at least the Language Reference should warn against it. Even with an obliged semicolon, I always use "OTHERWISE instead of ELSE, but that's my personal preference. By the way, the Language Reference doesn't specify what a is. Regards, Adriaan van Os ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Range check error warning.
z := x AND y is a bitwise AND (not (foldhiddenmask or currentfoldhiddenmask)) results in dec: -193hex: ff3f bin: 0011 this AND hex: $ff (bin: 1 ) gives bin: 0011 AND bin: bin: 0011 the result now definitely fits in a byte The operators NOT, AND, OR, XOR (applied to integers) should be mentioned somewhere in the documentation, maybe the explanation there is clearer - Original Message - From: "fredvs via fpc-pascal" To: Cc: "fredvs" Sent: Tuesday, March 24, 2020 8:59 PM Subject: Re: [fpc-pascal] Range check error warning. what about foldlevelmask = (not (foldhiddenmask or currentfoldhiddenmask)) and $ff ; Ha, this one fpc 3.3.1 like it! No more warning nor error. May I ask you what "and $ff" does, is it the same as "abs()" or keep it the negative value? Many thanks. Fre;D - Many thanks ;-) -- Sent from: http://free-pascal-general.1045716.n5.nabble.com/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Range check error warning.
what about foldlevelmask = (not (foldhiddenmask or currentfoldhiddenmask)) and $ff ; instead of the " f... := byte(...) " line ? - Original Message - From: "fredvs via fpc-pascal" To: Cc: "fredvs" Sent: Tuesday, March 24, 2020 1:08 AM Subject: [fpc-pascal] Range check error warning. Hello. With fpc 3.3.1 there is this warning: "Warning: (4110) Range check error while evaluating constants (-193 must be between 0 and 255)" Here the code pointed by the warning: const foldhiddenbit = 7; foldhiddenmask = 1 shl foldhiddenbit; currentfoldhiddenbit = 6; currentfoldhiddenmask = 1 shl currentfoldhiddenbit; foldlevelmask = byte(not (foldhiddenmask or currentfoldhiddenmask)); >Here the warning I dont understand how the compiler can find -193 as value for foldlevelmask... Fre;D - Many thanks ;-) -- Sent from: http://free-pascal-general.1045716.n5.nabble.com/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Variant part in objects?
Do it like this: type obj = object vars : record case boolean of end ; end ; - Original Message - From: "Ryan Joseph via fpc-pascal" To: "FPC-Pascal users discussions" Cc: "Ryan Joseph" Sent: Sunday, November 24, 2019 3:18 PM Subject: [fpc-pascal] Variant part in objects? Is there a reason that objects don't support variant sections like with records? Maybe they mess with the VMT table when virtual methods are added? I just posted my "advanced objects" patch (https://bugs.freepascal.org/view.php?id=36350) and all it does is add "class operators" to objects but I was curious about the variant records because it appears to be the only other thing from records that aren't in objects. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] LongBool True = -1
Afaik, the bool types (longbool, wordbool, bytebool) come from the C language and are mostly used to interface with C libraries (for example: windows). The definitions there are: 0 means FALSE, anything else means TRUE. Normally C routines return a dword/word/byte filled with ones for TRUE and expect something not 0 as TRUE. So, the definition comes from C. As long Pascal programmers want to use libraries written in C, this definition should not be changed in the Pascal compiler. Regards Gerhard - Original Message - From: "Sven Barth via fpc-pascal"To: Cc: "Sven Barth" Sent: Friday, May 18, 2018 7:22 AM Subject: Re: [fpc-pascal] LongBool True = -1 Am 17.05.2018 um 23:26 schrieb Anthony Walter: I am working with some a glib library that expects gboolean to be positive 1 for true, yet FPC emits -1 for true. Is there a compiler flag to force boolean types to emit 1 instead of -1? If so, would there possibly be any side effects with other pascal code? Why don't you use the glib2 unit which declares a correct gBoolean type (using Boolean32 which had been introduced for that purpose) and accordingly defined gTRUE and gFALSE? Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Variant record consistency
I assume, my response was a bit unclear. If you code it like this, you should get a runtime-error or compiler-error if the two variants are not same-sized, and I assume, this is what you wanted. - Original Message - From: "Gerhard Scholz" <g...@g--s.de> To: "FPC-Pascal users discussions" <fpc-pascal@lists.freepascal.org> Sent: Sunday, August 07, 2016 8:00 PM Subject: Re: [fpc-pascal] Variant record consistency if same size is necessary, I would do it like this: const topDataQword= 29; topNameChar= 231; type Tfnord1 = array[0..topDataQword] of qword ; Tfnord2 = record name: array[0..topNameChar] of char; inode: qword end ; Tfnord= record case boolean of false: (data: Tfnord1); true: (ni : Tfnord2) end; and, in the code: if sizeof(tfnord1) <> sizeof(tfnord2) then halt(4711); or, in the data type xxtest = array [ 1..ord(sizeof(tfnord1) = sizeof(tfnord2)) ] of boolean ; - Original Message - From: "Mark Morgan Lloyd" <markmll.fpc-pas...@telemetry.co.uk> To: <fpc-pascal@lists.freepascal.org> Sent: Sunday, August 07, 2016 6:11 PM Subject: [fpc-pascal] Variant record consistency Given a declaration const topDataQword= 29; topNameChar= 231; type Tfnord= record case boolean of false: (data: array[0..topDataQword] of qword); true: (name: array[0..topNameChar] of char; inode: qword) (* For recovery if name is changed *) end; is it possible to enforce a rule that the two record variants must be the same size? -- 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/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Variant record consistency
if same size is necessary, I would do it like this: const topDataQword= 29; topNameChar= 231; type Tfnord1 = array[0..topDataQword] of qword ; Tfnord2 = record name: array[0..topNameChar] of char; inode: qword end ; Tfnord= record case boolean of false: (data: Tfnord1); true: (ni : Tfnord2) end; and, in the code: if sizeof(tfnord1) <> sizeof(tfnord2) then halt(4711); or, in the data type xxtest = array [ 1..ord(sizeof(tfnord1) = sizeof(tfnord2)) ] of boolean ; - Original Message - From: "Mark Morgan Lloyd"To: Sent: Sunday, August 07, 2016 6:11 PM Subject: [fpc-pascal] Variant record consistency Given a declaration const topDataQword= 29; topNameChar= 231; type Tfnord= record case boolean of false: (data: array[0..topDataQword] of qword); true: (name: array[0..topNameChar] of char; inode: qword) (* For recovery if name is changed *) end; is it possible to enforce a rule that the two record variants must be the same size? -- 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/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Free Pascal 2.6.4-rc1 released!
I downloaded ftp://freepascal.stack.nl/pub/fpc/beta/2.6.4-rc1/i386-win32/fpc-2.6.4rc1.i386-win32.exe The setup the said: The setup files are corrupted. Please obtain a new copy of the program. I did that; the second copy also didn't work. Greetings Gerhard - Original Message - From: Bart bartjun...@gmail.com To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Thursday, December 19, 2013 11:44 PM Subject: Re: [fpc-pascal] Free Pascal 2.6.4-rc1 released! On 12/19/13, Marco van de Voort mar...@stack.nl wrote: ftp://freepascal.stack.nl/pub/fpc/beta/2.6.4-rc1/ I get a Permission denied for that URL. Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: ++ and -- ( and +=, -=, ...)
Semantically, it's not the same, but a += b can be replaced by inc ( a, b ) ; It's readable, it looks like normal standard Pascal; and it's clear that the address of a is calculated only once. If a,b are not ordinals, inc could be overloaded. Greetings Gerhard - Original Message - From: Graeme Geldenhuys gra...@geldenhuys.co.uk To: fpc-pascal@lists.freepascal.org Sent: Wednesday, July 31, 2013 12:54 PM Subject: Re: [fpc-pascal] Re: ++ and -- ( and +=, -=, ...) On 2013-07-30 22:42, leledumbo wrote: People who uses C style short unreadable code approach usually state they get more optimized code, yet the compiler is actually able to produce the same with optimizations turned on. No, I simply prefer to use += and -= because it is easier to read the code (for me at least). But with the added restrictions applied in recent FPC releases (eg: those shortcuts don't work with properties any more) I am slowly forced to move back to the verbose a := a + b syntax. :-/ Regards, Graeme. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] ++ and -- ( and +=, -=, ...)
I tried it now with locals and globals, but with the same results. The code: program plusas ; type t = array [ 1..10 ] of longint ; var i : longint ; a : t ; function incg ( var i : longint ) : longint ; //inc(i),return the incremented i begin inc ( i ) ; result := i ; end ; procedure l ; var i : longint ; a : t ; function incl ( var i : longint ) : longint ; //inc(i),return the incremented i begin inc ( i ) ; result := i ; end ; begin i := 1 ; a[i] := a[i] + 3 ; a[i] += 3 ; a[incg ( i )] += 3 ; a[incl ( i )] += 3 ; end ; begin i := 1 ; a[i] := a[i] + 3 ; a[i] += 3 ; a[incg ( i )] += 3 ; end. Very obviously the += is implemented as a kind of macro, if the index is a function, it is called twice with surprising result. According to the FPC manual (I just looked it up), which says: a += b Adds b to a, and stores the result in a. Remark: These constructions are just for typing convenience, they don't generate different code. this is the expected result, I must admit. From my common sense thinking, i would have expected something like: a[incg ( i )] += 3 ; translates to P := @ a[incg ( i )] ; P^ := P^ + 3 ; I have no C compiler since I don't like C, but I would like to know how C compilers handle +=. The GNU C manual says: += Adds the two operands together, and then assign the result of the addition to the left operand. Could be understood ambiguous also. I know the += from Algol68, where it is defined very exact: op (hplusab, +:=) =(ref int a, int b) ref int :a := a + b; or, in pascal-like terms operator += ( var a : longint ; b : longint ) z : longint ; begin a := a + b ; z := a ; end ; Exact definitions normally give less surprising results. So I think I will forget += etc. - Original Message - From: Jonas Maebe jonas.ma...@elis.ugent.be To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Tuesday, July 30, 2013 10:41 PM Subject: Re: [fpc-pascal] ++ and -- ( and +=, -=, ...) On 30 Jul 2013, at 22:17, Gerhard Scholz wrote: Beside of the question, if ++,--,+=,etc. fit into Pascal or not, there stays the question: is it a plus? I expected that a[i] += 3 compiles better than a[i] := a[i] + 3 I expected that the computation of a[i] is done only once, but the produced code is the same, the address of a[i] is computed twice. So the whole construct is only a typing saving. Compilation done with FP 2.6.2, winxp, 32-bit) Syntax and generated code are in principle unrelated. The reason you don't get the optimised version of the code, is probably because you used global variables. Make the array and i local, and you will see that in both cases the address of a[i] is calculated only once. Constructs involving global variables are harder to analyse for side-effects, so they are simply not optimised at all in many cases by FPC. Constructs like I++, ++I are nice shortcuts (and sometimes the code can be better readable), but have only a real value, if the produced code is a bit optimized. That was true in the eighties when C statements were pretty much directly mapped to assembler. Nowadays, they make code actually harder to optimise because they introduce side-effects in the middle of expressions. Adding a particular syntax to a programming language in order to work around a (realistically solvable) weakness of the optimiser is an extremely bad approach to language design. Jonas___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] ++ and -- ( and +=, -=, ...)
(If +=, -= etc. would have been copied from Algol68 and not from C, it would have been written +:= -:=, which looks more pascal-like. And the acceptance for these constructs would be wider, I assume. Just an optical note to that theme). Beside of the question, if ++,--,+=,etc. fit into Pascal or not, there stays the question: is it a plus? I expected that a[i] += 3 compiles better than a[i] := a[i] + 3 I expected that the computation of a[i] is done only once, but the produced code is the same, the address of a[i] is computed twice. So the whole construct is only a typing saving. Compilation done with FP 2.6.2, winxp, 32-bit) Constructs like I++, ++I are nice shortcuts (and sometimes the code can be better readable), but have only a real value, if the produced code is a bit optimized. standard: i := i + 1 ; a[i] := 3 with ++: a[++i] := 3 ; Could save one (or two) assembler statements! And now let's wait for people who want to see a[++i++] := 2 in the language! Gerhard - Original Message - From: Marco van de Voort mar...@stack.nl To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Tuesday, July 30, 2013 8:37 PM Subject: Re: [fpc-pascal] Re: ++ and -- In our previous episode, Mattias Gaertner said: Also +=, etc are not true operators in FPC like they are in e.g. C++, but they are internally translated to a := a + b, etc. So potential sideeffects need to be remembered here. That's not entirely true. For example a:=a+b is allowed for properties, while a+=b is not allowed for properties. I think Sven meant that a is only evaluated once. (in case it is an expression). Not that it operates on all types. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
Here is a unit that could be useful. Works with pentium and Win32; not tested with other CPUs or operating system. I hope you have 7zip, or I will create a zip file. Greetings Gerhard - Original Message - From: Daniel Gaspary dgasp...@gmail.com To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Saturday, March 09, 2013 9:52 PM Subject: [fpc-pascal] Set size limit Hi, I am trying to create a Set Type... TMyEnum = (me1, me2, me3); // more than 500 elements TMySet = set of TMyEnum; ...but I get the following error: Error: illegal type declaration of set elements [1] The problem seems to be that TMyEnum has more than 256 elements. Can I specify such Set with some compiler option ? My fpc is pre 2.6, any change on new versions concerning Sets limits? Thanks. [1] A more specific message would help too. :) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ubigset.7z Description: Binary data ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
Sorry, there are some changes neccessary: drop the reference to unit uAsms delete the line FillOnes ( ... it was there for debugging purposes - Original Message - From: Gerhard Scholz g...@g--s.de To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Cc: dgasp...@gmail.com Sent: Monday, March 11, 2013 7:42 PM Subject: Re: [fpc-pascal] Set size limit Here is a unit that could be useful. Works with pentium and Win32; not tested with other CPUs or operating system. I hope you have 7zip, or I will create a zip file. Greetings Gerhard - Original Message - From: Daniel Gaspary dgasp...@gmail.com To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Saturday, March 09, 2013 9:52 PM Subject: [fpc-pascal] Set size limit Hi, I am trying to create a Set Type... TMyEnum = (me1, me2, me3); // more than 500 elements TMySet = set of TMyEnum; ...but I get the following error: Error: illegal type declaration of set elements [1] The problem seems to be that TMyEnum has more than 256 elements. Can I specify such Set with some compiler option ? My fpc is pre 2.6, any change on new versions concerning Sets limits? Thanks. [1] A more specific message would help too. :) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Compiled program is a virus (seems to be internal linker problem)
Platform: Win32, FPC2.7.1, Virusscanner Avira Free Antivirus The compiled program is assumed to be a virus. Name:TR/Crypt.XPACK.Gen2 (according to Avira, shall be a trojan) Compile line: ppc386 -vv -al -CioOrt -Cs600-gclt -Mobjfpc -O1 -OpPENTIUM With the external linker ( -Xe ) the program is not a virus and works. Shall I make a bug report from that? I think I can not produce a small test program, the problem occurs only with one program, others do compile without problem. Gerhard ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Compiled program is a virus (seems to be internallinker problem)
@Martin: Compile line: ppc386 -vv -al -CioOrt -Cs600 -Mobjfpc -O1 -OpPENTIUM (dropping the -gclt) helped. It seems you were right. Gerhard - Original Message - From: Martin laza...@mfriebe.de To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Monday, February 11, 2013 10:08 PM Subject: Re: [fpc-pascal] Compiled program is a virus (seems to be internallinker problem) On 11/02/2013 20:22, Gerhard Scholz wrote: Platform: Win32, FPC2.7.1, Virusscanner Avira Free Antivirus The compiled program is assumed to be a virus. Name:TR/Crypt.XPACK.Gen2 (according to Avira, shall be a trojan) Compile line: ppc386 -vv -al -CioOrt -Cs600-gclt -Mobjfpc -O1 -OpPENTIUM With the external linker ( -Xe ) the program is not a virus and works. Shall I make a bug report from that? I think I can not produce a small test program, the problem occurs only with one program, others do compile without problem. IMHO, should be reported to the AV manufacturer. btw, if you strip debug info, is it still reported? Because Kaspersky had/has that problem. And several other AV seems to get signatures from the same source. On report they updated their signatures. Apparently whitelisted. The reported exe, now is fine. A byte by byte identical exe, with the exception of one single digit, in a textual date string differing, is still reported. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Compiled program is a virus (seems to be internallinker problem)
I switched to AVAST free Antivirus now, the problem does not occur here. This is not a pascal question, but maybe can give me a hint if AVAST is good or which software is more recommendable. (I do not really trust the tests I find in the internet because I do not know who pays them) Gerhard - Original Message - From: Gerhard Scholz g...@g--s.de To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Monday, February 11, 2013 11:07 PM Subject: Re: [fpc-pascal] Compiled program is a virus (seems to be internallinker problem) @Martin: Compile line: ppc386 -vv -al -CioOrt -Cs600 -Mobjfpc -O1 -OpPENTIUM (dropping the -gclt) helped. It seems you were right. Gerhard - Original Message - From: Martin laza...@mfriebe.de To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Monday, February 11, 2013 10:08 PM Subject: Re: [fpc-pascal] Compiled program is a virus (seems to be internallinker problem) On 11/02/2013 20:22, Gerhard Scholz wrote: Platform: Win32, FPC2.7.1, Virusscanner Avira Free Antivirus The compiled program is assumed to be a virus. Name:TR/Crypt.XPACK.Gen2 (according to Avira, shall be a trojan) Compile line: ppc386 -vv -al -CioOrt -Cs600-gclt -Mobjfpc -O1 -OpPENTIUM With the external linker ( -Xe ) the program is not a virus and works. Shall I make a bug report from that? I think I can not produce a small test program, the problem occurs only with one program, others do compile without problem. IMHO, should be reported to the AV manufacturer. btw, if you strip debug info, is it still reported? Because Kaspersky had/has that problem. And several other AV seems to get signatures from the same source. On report they updated their signatures. Apparently whitelisted. The reported exe, now is fine. A byte by byte identical exe, with the exception of one single digit, in a textual date string differing, is still reported. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: [fpc-announce] Feature announcement: Type helpers
Hello, I tried to compile the example: type TLongIntHelper = type helper for LongInt class procedure Test; static; end; class procedure TLongIntHelper.Test; begin Writeln('Test'); end; var i: LongInt; begin i.Test; $12345678.Test; LongInt.Test; end. Result: 0:25:46,51 G:\ob\syncdirsppc386 -vv -al -CioOrt -Cs600 -gclt -Mobjfpc -O1 -OpPENTIUM -Fuu:\ -FuM:\u -FuC:\c\-u -FiC:\c\-u -Fuz:\-u -Fiz:\-u -FuP:\gs\tp55\includes -Fuf:\-u -Fiu:\ -FiM:\u -FiP:\gs\tp55\includes -Fif:\-u -FE. thelper thelper.pas(2,33) Error: Identifier not found helper thelper.pas(2,33) Error: Error in type definition thelper.pas(2,33) Error: Can't create unique type from this type thelper.pas(2,33) Fatal: Syntax error, ; expected but FOR found Fatal: Compilation aborted The compiler is freshly generated from the SVN Does the compiler expect special options to invoke the record helper feature? Gerhard - Original Message - From: Sven Barth pascaldra...@googlemail.com To: fpc-annou...@lists.freepascal.org Cc: fpc-pascal@lists.freepascal.org; FPC developers' list fpc-de...@lists.freepascal.org Sent: Wednesday, February 06, 2013 10:49 AM Subject: [fpc-announce] Feature announcement: Type helpers Hello Free Pascal community! I'm pleased to announce the addition of type helpers which extend the existing helper concept with the ability to extend primitive types. Motivation: With class and record helpers the possibility was created to extend classes and records with types without subclassing the type (which wouldn't be possible with records anyway). This allows to add e.g. methods to types in units that you can't influence or where you can't influence with type is instantiated (e.g. the TStrings descendant used in TMemo). Now it is logical to extend this also to other types supported by Pascal, but here more driven by the possibility to group methods together and have them appear to belong to the primitive type. While this does not bring the concepts of boxing of managed languages/environments like Java and .NET to Pascal it does nevertheless look this way. Syntax: The declaration of type helpers looks as follows: TYPENAME = type helper[(BASEHELPER)] for EXTENDEDTYPE DECLARATIONS end; Like class and record helpers they support all visibility sections and you can define methods, properties and constructors. Inside methods declared in the helper Self will be of the extended type's type and it's value can also be changed. Similar to record helpers class methods MUST be declared as static. Usage: A type helper is active if it is in scope. This means it must either have been declared in the same unit before the code which wants to use the helper or it needs to be declared in a used unit. As with class and type helpers only one helper for a given type can be active and thus you need to keep in mind the scoping rules when using helpers (e.g. the current unit is searched in the order implementation section then interface section (if the code is in the implementation section) and then the used units are searched from right to left and each unit from top to bottom). In some cases the meaning of a type depends on the compiler settings the helper is compiled with. E.g. the type Integer is either a ShortInt or a LongInt depending on the current mode (fpc/tp vs. objfpc/delphi) and the type String is different depending on the switches {$H+/-} and {$modeswitch unicodestring}. This needs to be kept in mind when working with these generic types. Another special case is the type Extended on platforms that don't support that type (and thus it will be defined as Double). Additionally a type declared as NewType = type OldType is considered a completly independant type as it is the case with e.g. operator overloads as well. If a helper for the type is in scope you can simply invoke it's methods or properties like you'd do on classes or records. Let's suppose we have a helper with method ToString: String for the type LongInt in scope then it will look like this: === example begin === var i: LongInt; begin Writeln(i.ToString); end. === example end === Additionally to invoking type helpers on variables they can also be used on constants though special care needs to be taken that the correct type is used. E.g. the constant 200 will be handled as a Byte whereas 20 will be handled as SmallInt. Also the type of string constants depends on the current mode switch (especially {$H+/-} and {$modeswitch unicodestring}) and also the content of the string. E.g. in case of {$mode objfpc}{$H+} a string containing unicode characters will be handled as a UnicodeString constant and thus only helpers for UnicodeString will apply. For the following example let's assume the helper from the previous example is in scope again: === example begin === begin Writeln($12345678.ToString); end. === example end === Additionally addresses (e.g. @i) (type: Pointer)
Re: [fpc-pascal] Linker Error: what does this mean?
Sorry, I forgot how to file a bug report. Either somebody explains me, please, or uses this information: I created a smaller test program which produces the same error. The test files can be found here: http://mewal.com/test.zip (161 kB) or http://mewal.com/test.7z (21 kB) If someone wants to have it, of course I can also mail the files. Gerhard - Original Message - From: Tomas Hajny xhaj...@hajny.biz To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Thursday, January 24, 2013 9:32 AM Subject: Re: [fpc-pascal] Linker Error: what does this mean? On Wed, January 23, 2013 23:56, Gerhard Scholz wrote: Hello, thanks for the hint with the -Xe parameter (the external linker is damned slow!), now it compiles. . I'm glad that the external linker helped. Indeed, slowness of the external linker is one of reasons for using the internal one by default. If the external and internal linkers behave differently here, it would be the best to file a bug report so that the internal linker may get fixed. However, it is necessary to include a (reference to) source code allowing reproduction of the issue. Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Linker Error: what does this mean?
Hello, thanks for the hint with the -Xe parameter (the external linker is damned slow!), now it compiles. The difference in the object file size seems to be the different amount of stored debug information; the declared structures have the same size (SIZEOF(...) is the same. Thanks for the help. Greetings Gerhard - Original Message - From: Tomas Hajny xhaj...@hajny.biz To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Wednesday, January 23, 2013 1:00 AM Subject: Re: [fpc-pascal] Linker Error: what does this mean? On 23 Jan 13, at 0:01, Gerhard Scholz wrote: The files are completed compiled with FPC, no renaming of VPascal object files. The only explanation I have that it must have to do with the size of the file; the .o has 8 MB and just defines some CONST and VAR structures, no code. Assuming (again ;-) - you haven't provided such information) that you refer to the Win32 platform - could you disable internal linking (add -Xe parameter)? Interesting (maybe): the .O which ppc386 made has 8.380.376 bytes, the .OBJ made by vp has 7.002.097 bytes. This difference in size could be due to different alignment rules. Again, judging what goes wrong is difficult without being able to reproduce it... Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Linker Error: what does this mean?
Question: what's the reason for this error? Linking .\read.exe Error: Failed reading coff file, illegal reloctype $ while reading .\U_UNIDAT The program compiles wonderfully with VirtualPascal; I wanted to recompile it with FPC. Gerhard ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] printing each Friday the 13 using Pascal
a quick and dirty solution - Original Message - From: ik To: FPC-Pascal users discussions Sent: Monday, August 06, 2012 1:19 PM Subject: [fpc-pascal] printing each Friday the 13 using Pascal Hi list, A friend of mine started a hobby project: Printing every Friday the 13, in a range of 5 years. I lack of the time for doing it at the moment, and I wish to add to his github also Pascal (and show how much simpler it is then C) implementation. Is there anyone here that might be interested in this ? Ido ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal Friday13.pas Description: Binary data ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Creating video files
VirtualDub(Mod) accepts as input a series of BMP (name000.bmp,name001.bmp,name002.bmp,...) You can give it a script file for execution. The best is to do it by hand once and save the script, then you know what your program must generate. - Original Message - From: Krzysztof dib...@wp.pl To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Wednesday, June 20, 2012 7:22 PM Subject: Re: [fpc-pascal] Creating video files Ffmpeg looks similar like Mencoder project. So I have some solutions for output encoding, but there is a problem how to send frames to this encoders. Mencoder can encode video from series of PNG files, but can't find similar option in ffmpeg. Anyone know something about RAW video format? It seems that this is some standard and most of players / encoders can handle it. I could use it as input for ffmpeg/mencoder but need some bindings / tips for FPC 2012/6/20 Flávio Etrusco flavio.etru...@gmail.com: Apart from _the_ multi-platform commandline video converter, ffmpeg? http://ffmpeg.org/ It's the back-end for WinFF (and most other utilities like these). Also, I would expect VirtualDub to run fine with WINE. -Flávio On Wed, Jun 20, 2012 at 11:00 AM, Krzysztof dib...@wp.pl wrote: Hmm, external application is nice idea. But VirtualDub is windows only. Anyone know multi-platform comandline video converter? What I found is Mencoder. I must test it 2012/6/20 Gerhard Scholz g...@g--s.de: In my opinion, the easiest way is to create a series of BMP's and then use VirtualDub or VirtualDubMod (I think it's at Sourceforge). Greetings - Original Message - From: Krzysztof dib...@wp.pl To: fpc-pascal fpc-pascal@lists.freepascal.org Sent: Tuesday, June 19, 2012 3:53 PM Subject: [fpc-pascal] Creating video files Hi, I would like to write video (created from series of bitmaps) to some popular video formats like avi, flv. Is this possible? Has FPC bindings for video librarys? I googled that WinFF (http://winff.org/html_new/) is written in FPC and Lazarus, so I supose that some bindings exists but can't find any in http://wiki.freepascal.org/Multimedia_Programming Regards. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Creating video files
In my opinion, the easiest way is to create a series of BMP's and then use VirtualDub or VirtualDubMod (I think it's at Sourceforge). Greetings - Original Message - From: Krzysztof dib...@wp.pl To: fpc-pascal fpc-pascal@lists.freepascal.org Sent: Tuesday, June 19, 2012 3:53 PM Subject: [fpc-pascal] Creating video files Hi, I would like to write video (created from series of bitmaps) to some popular video formats like avi, flv. Is this possible? Has FPC bindings for video librarys? I googled that WinFF (http://winff.org/html_new/) is written in FPC and Lazarus, so I supose that some bindings exists but can't find any in http://wiki.freepascal.org/Multimedia_Programming Regards. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] 2.4.0: Some lines are not compiled (just thrown away)
Thanks. I tried to report via the bugs page at freepascal.org, but I didn't find the link to enter a fresh bug; maybe I just didn't see it. Gerhard - Original Message - From: Jonas Maebe jonas.ma...@elis.ugent.be To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Friday, February 12, 2010 7:13 PM Subject: Re: [fpc-pascal] 2.4.0: Some lines are not compiled (just thrown away) On 24 Jan 2010, at 21:10, Gerhard Scholz wrote: Some lines are ignored. An IF-clause is ignored. Versin 2.2.4 runs o.k. Fixed. Please report bugs at http://bugs.freepascal.org in the future so they can't be forgotten. Jonas___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] 2.4.0: Some lines are not compiled (just thrown away)
Some lines are ignored. An IF-clause is ignored. Versin 2.2.4 runs o.k. The program: program rangtest ; type trange = 0..2030 ; ytrange = 1990..2030 ; CONST lrange = low ( trange ) ; hrange = high ( trange ) ; ylrange = low ( ytrange ) ; yhrange = high ( ytrange ) ; var bbb : trange ; kkk : longint ; xyzzy : array [ ytrange, 1..100 ] of record xyzp : longint ; xyzb : boolean ; end ; begin (*$r+,s+,o+*) bbb := 0 ; kkk := 1 ; IF ( bbb = ylrange ) // this IFstatement can not be found in the assembler file AND ( bbb = yhrange ) // and the program stops with range error THEN begin // WITH xyzzy[bbb,kkk] DO BEGIN xyzp := 2 ; xyzb := True ; END ; end else writeln ( 'out' ) ; end. OS: WinXP Output of the compiler: Free Pascal Compiler version 2.4.0 [2009/12/18] for i386 Copyright (c) 1993-2009 by Florian Klaempfl Note: Switching assembler to default source writing assembler Target OS: Win32 for i386 Compiling rangtest.pas rangtest.pas(34,12) Warning: unreachable code rangtest.pas(16,5) Note: Local variable xyzzy is assigned but never used Assembling rangtest Linking .\rangtest.exe 35 lines compiled, 0.1 sec , 35952 bytes code, 1728 bytes data 1 warning(s) issued 2 note(s) issued 1 Datei(en) kopiert. 1 Datei(en) kopiert. the assembler file (only the part from BEGIN to WITH) # [rangtest.pas] # [22] begin (*$r+,s+,o+*) call FPC_INITIALIZEUNITS # Register eax,ecx,edx released # Register ax allocated .stabn 68,0,22,.Ll2 - _main .Ll2: movw $0,%ax # Register eax allocated movl $0,%eax # Register eax released # Register dx allocated .stabn 68,0,23,.Ll3 - _main .Ll3: # [23] bbb := 0 ; movw $0,%dx # Register ecx allocated .stabn 68,0,24,.Ll4 - _main .Ll4: # [24] kkk := 1 ; movl $1,%ecx # Register eax allocated .stabn 68,0,28,.Ll5 - _main ## ## Here should be some result of the IF ! the 2.2.4 version does not drop these lines ## .Ll5: # [28] WITH xyzzy[bbb,kkk] DO movzwl %dx,%eax subl $1990,%eax cmpl $40,%eax # Register eax released jbe .Lj9 call FPC_RANGEERROR .Lj9: ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Origin of FPC features
Bitpacked Structures: The first time I've seen bitpacked structures (arrays records) was on the pascal compiler for Control Data machines, about 1980. If I remember right, it was the original ETH Zürich compiler, made by someone of the Wirth staff. ( the keyword BITPACKED was not used, it was done by PACKED) GPC also has bitpacked stuctures. Greetings Gerhard - Original Message - From: leledumbo To: fpc-pascal@lists.freepascal.org Sent: Tuesday, February 10, 2009 5:56 AM Subject: [fpc-pascal] Origin of FPC features I'm writing a paper about FPC and I need references where each language feature comes from. So far, these are my what I know (some are guessing though): Feature Original Dialect Additional Information Separate compilation UCSD Pascal Unit based, not module (like Extended Pascal) Primitive OOP Turbo Pascal C++ like Modern OOP (including exceptions) Delphi Java like, though FPC was born before Java ;-) Assembler integration UCSD? Turbo? ATT and Intel External references UCSD? Turbo? - Operator overloading Pascal-XSC - Function / Procedure overloading Delphi - Dynamic arrays Delphi - Variants Delphi - Arrays as parameter enhancements Delphi Open arrays, partial arrays Bitpacked Structures Native FPC - Generics Native FPC - Thread Programming Native FPC? Delphi? Bringing threads to language level In case I miss something that you know, please add. Note that these features are related with language construct, not technical one (i.e. compiling speed, makefiles). -- View this message in context: Origin of FPC features Sent from the Free Pascal - General mailing list archive at Nabble.com. -- ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fast integer multiplication and one asm questio
For learning some basics of assembler you should download the NASM, it is bundled with a documentation; more documentation should be found at the intel sides. Or e.g. try http://www.agner.org/assem But keep in mind that the exact syntax differs from assembler to assembler. Also a good idea is to compile (little) pascal programs and look at the generated code (compile with the option -al) A general assembler tutorial here would overflow this mail list. Gerhard -Ursprüngliche Nachricht- Von: Pianoman [EMAIL PROTECTED] An: fpc-pascal@lists.freepascal.org Gesendet: Dienstag, 2. August 2005 17:22 Betreff: [fpc-pascal] fast integer multiplication and one asm questio Hi, the UI32x32To64 function is great but is amazingly short. How can I Specify which varriables in function will be accessed. In this function for example it accesses a and b but source says mull (I don't know why not mul I didnt find mull instruction in any assembly book) and %eax why mull %eax multiplies a,b is it on the stack or why? If i would like to multiply a,b,c what would look source code then? Thanx for response to those quite stupid assembly question(I am only beginner in asm :) Pianoman - Original Message - From: [EMAIL PROTECTED] To: fpc-pascal@lists.freepascal.org Sent: Tuesday, August 02, 2005 12:00 PM Subject: fpc-pascal Digest, Vol 12, Issue 2 Send fpc-pascal mailing list submissions to fpc-pascal@lists.freepascal.org To subscribe or unsubscribe via the World Wide Web, visit http://lists.freepascal.org/mailman/listinfo/fpc-pascal or, via email, send a message with subject or body 'help' to [EMAIL PROTECTED] You can reach the person managing the list at [EMAIL PROTECTED] When replying, please edit your Subject line so it is more specific than Re: Contents of fpc-pascal digest... Today's Topics: 1. Re: lazarus crash at start (Jesus Reyes) 2. Re: fast integer multiplication (Gerhard Scholz) 3. Can a program find out how it was started? ([EMAIL PROTECTED]) 4. Re: Can a program find out how it was started? (Moz) -- Message: 1 Date: Mon, 1 Aug 2005 11:21:10 -0500 (CDT) From: Jesus Reyes [EMAIL PROTECTED] Subject: Re: [fpc-pascal] lazarus crash at start To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=iso-8859-1 --- Peter Vreman [EMAIL PROTECTED] escribió: At 01:12 1-8-2005, you wrote: Trying to find why lazarus crashes at start in win98 I found a courious problem, global variable IsConsole is true when it should be false as lazarus is built as a gui application. Digging I found that IsConsole is set in two functions in wprt0.as: _mainCRTStartup sets to true and _WinMainCRTStartup sets to False, this cause a wrong setup of standard Output that DebugLn (lclprocs.pas) use to emit debug messages. It seems that this functions are 'used' in the linker script, for example ld .--verbose shows that by default a ENTRY(_mainCRTStartup) it's used. I looked into the generated lazarus link.res file and didn't find a ENTRY section so I guess it uses the default and that's why even when lazarus is a gui app, it's linked as a console app. To demostrate this I modified the link.res script to inculde ENTRY(_WinMainCRTStartup) section and then linked, the resulting lazarus.exe file now behaves as a gui app and won't crash at start. It seems that WriteResponseFile lacks the code to add the ENTRY section to the link.res script but I don't know if it's supposed to be there or should it be in another stage, any comments? You need to use {$apptype gui} or use the -WG parameter. For the compiler it is not known if the application needs a console or not. Peter Lazarus is already compiled with -WG Jesus Reyes A. __ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ¡gratis! Regístrate ya - http://correo.yahoo.com.mx/ -- Message: 2 Date: Mon, 1 Aug 2005 23:58:04 +0200 From: Gerhard Scholz [EMAIL PROTECTED] Subject: Re: [fpc-pascal] fast integer multiplication To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=iso-8859-1 ... The code generated for the above sample is: # [16] c:=a*b; movlU_P$PROJECT1_A,%edx movlU_P$PROJECT1_B,%eax mull%edx movl$0,%edx movl%eax,U_P$PROJECT1_C movl%edx,U_P$PROJECT1_C+4 What I want is the above code, but without the movl $0,%edx instruction. Is there a way to do this (wihtout using fpc_mul_qword). Only assembler for now. Any suggestions how the compiler could be told to generate such code? ... function UI32x32To64(A,B: Longword): QWord
Re: [fpc-pascal] fast integer multiplication
... The code generated for the above sample is: # [16] c:=a*b; movlU_P$PROJECT1_A,%edx movlU_P$PROJECT1_B,%eax mull%edx movl$0,%edx movl%eax,U_P$PROJECT1_C movl%edx,U_P$PROJECT1_C+4 What I want is the above code, but without the movl $0,%edx instruction. Is there a way to do this (wihtout using fpc_mul_qword). Only assembler for now. Any suggestions how the compiler could be told to generate such code? ... function UI32x32To64(A,B: Longword): QWord; assembler; register; nostackframe; asm mull %edx end; It is fast but certainly much less than if it were inlined. My suggestion would be: FUNCTION lmul ( CONST a, b : LongInt ) : int64 ; inline ; BEGIN {$ifdef cpu86} ASM movla,%eax imull b movl%eax,lmul movl%edx,lmul+4 END ; {$else} {$ifdef cpu68k} lmul := int64 ( a ) * b ; {$else} {$ifdef cpusparc} lmul := int64 ( a ) * b ; {$else} {$ifdef cpualpha} lmul := int64 ( a ) * b ; {$else} {$ifdef cpupowerpc} lmul := int64 ( a ) * b ; {$else} lmul := int64 ( a ) * b ; {$endif} {$endif} {$endif} {$endif} {$endif} END ; and similar for unsigned mul. (shortened here; full code in ulmul.pas; liitle test in tmuls.pas, timing routines in wtimer/tdrsc1) Is portable so code doesn't need to be rewritten when compiled for other processors (but not optimal then) Tested only on i386. Seems to be faster than standard multiplication (interesting: significantly faster for signed mul than for unsigned mul), can be assembly-coded in the branches for the other cpus (if there are opcodes for such a multiplication - I don't know), could go to unit math.pp. It seems that routines which contain assembler are not inlined; on the day somebody finds a trick to inline such code they should be really fast. Gerhard ULMUL.pas Description: Binary data tmuls.pas Description: Binary data WTIMER.pas Description: Binary data TDRSC1.pas Description: Binary data ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] showing source linenumbers on exceptions
Hi, compilation with the parameter -gl should do your job: ppc386 -gl myprogram (if your compiler name is ppc386, else insert your name instead Gerhard -Ursprüngliche Nachricht- Von: Bartek [EMAIL PROTECTED] An: fpc-pascal@lists.freepascal.org Gesendet: Montag, 27. Juni 2005 22:51 Betreff: [fpc-pascal] showing source linenumbers on exceptions hi, how can i show source line numbers, when an exception occurs, like sysutils do? ... An unhandled exception occurred at $0040E9B5 : EInOutError : Invalid filename $0040E9B5 TDXF__LOAD, line 271 of dxffile.pas $0040EFFA TDXF__CREATE, line 329 of dxffile.pas $0040F24A TPAPER__CREATE, line 48 of dxfpaper.pas $00401459 INIT_OBJECTS, line 63 of e:/_development/work/dxf2mcr.pas $00401529 INITPROC, line 87 of e:/_development/work/dxf2mcr.pas $00401F1F INIT_FRAMEWORK, line 107 of E:/_development/units/uframe_sdlogl.pas ... the only thing i found is the ShowExeption proc. but this does not write what i expected. ... exception at 0040EA45: Invalid filename. ... is there a possibility to do this on my own? if found the proc: ... Procedure CatchUnhandledException (Obj : TObject; Addr: Pointer; FrameCount: Longint; Frames: PPointer);[public,alias:'FPC_BREAK_UNHANDLED_EXCEPTION']; ... but i don't how to set FrameCount and Frames. thanks in advance bartek ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Optimize code for speed
I don't know why my email has been destroyed a bit (my assumption is that this is done by the list manager program). Example 2 should have looked as this (now in one line): 2: begin StrList3.add (do.something); end Why everything after .add did vanish I don't know. - Original Message - From: Gerhard Scholz [EMAIL PROTECTED] To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Friday, June 10, 2005 12:46 PM Subject: Re: [fpc-pascal] Optimize code for speed - Original Message - From: L505 [EMAIL PROTECTED] To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Friday, June 10, 2005 10:18 AM Subject: [fpc-pascal] Optimize code for speed ... 1. begin M yString=Do.Something StrList3.add(MyString); end 2. begin StrList3.add end I assume you mean: 1: begin M yString=Do.Something StrList3.add(MyString); end 2: begin S trList3.add end ... ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Optimize code for speed
- Original Message - From: L505 [EMAIL PROTECTED] To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Friday, June 10, 2005 10:18 AM Subject: [fpc-pascal] Optimize code for speed ... 1. begin M yString=Do.Something StrList3.add(MyString); end 2. begin StrList3.add end I assume you mean: 1: begin M yString=Do.Something StrList3.add(MyString); end 2: begin StrList3.add (do.something); end The waste of one little variable is not so important since when you leave that procedure the local variables vanish. Version 2 should be a little bit faster. If you KNOW the string is going to be short, is shortstring and better, or is ansistring better? Generally shortstring should be faster. But if you have both shortstrings and ansistrings in your program: every conversion (e.g. by assignment) from one to the other costs a lot. So, when you are forced to have some ansistrings, normally it's the best to use only ansistrings. If you KNOW the integer is going to be short, is it better to specify a ShortInt? Depends on the machine: in i386-code longints (int32) seem to be preferred: better handled by the compiler, and faster executed (should be at least on pentium). On older 386 integer and shortint was better. On other processors I don't know. But if you have to keep a lot of data (e.g. array [ 1..100 ] of an_integer_type), then space considerations might be more important than speed. I myself like the range constructs, e.g. var j : 1..23, when I know the variable cannot senseful be outside that range. So debugging is done by the program itself (with $R+,O+) Is the default compiler setting regular strings, or ansistrings? (If I understand the compiler source correctly) in delphi mode: ansistrings, otherwise: normal strings Is a boolean faster than an integer who you just set as 0 and 1? Should be the same: a boolean is an ENUM with the values ( FALSE, TRUE ) which map to the values 0 and 1 as far as I remember that was the original definition: type boolean = false, true ) ; To check what is better (e.g. your example above), you should produce a little test program containing both of your versions and compile it with the option -al to get the assembler source. Look at that source. That version which produces less code normally should also be the faster one. Gerhard ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Past list archives
Sorry, that list mentioned below: http://www.freepascal.org/mailist.html is dead. (Objekt nicht gefunden! Der angeforderte URL konnte auf dem Server nicht gefunden werden.) Greetings Gerhard - Original Message - From: Jonas Maebe [EMAIL PROTECTED] To: Mike's Mail [EMAIL PROTECTED]; FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Sunday, May 29, 2005 2:38 PM Subject: Re: [fpc-pascal] Past list archives On 25 May 2005, at 14:47, Mike's Mail wrote: Is there an active link for the archives that works, or who would I contact to report the link, so it may be fixed? Yes, working links can be found on http://www.freepascal.org/ maillist.html Jonas PS: please turn off html posting in your mail client, it causes your posts to be held for approval (because the rule that stops such mails it also stops all viruses I know of) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal