Article View: comp.lang.modula2
Article #2676TopSpeed and assembler.
From: Marco van de Voort
Date: Tue, 01 Aug 1995 22:49
Date: Tue, 01 Aug 1995 22:49
57 lines
3017 bytes
3017 bytes
Hallo Scott! Sunday July 02 1995 16:54, Scott Cornwall wrote to All: SC> We consider it essential to call assembler from TopSpeed Modula-2. For that SC> extra bit of performance in a critical procedure. It is actually quite SC> easy once you have the calling conventions worked out, and as Jim says, SC> look at what is in the TopSpeed source , this is probably your best SC> example. Do you know how optimize routines for e.g. 80386+? Preferably with a (*%F (*%T alike statement with pragma CpuId. (this one doesn't exist in CoreFile.inc). I've searched for this in the library sources, but could not find it. Maybe to prevent recompiling all the library's after a processor change. SC> You can knock a lot of cycles out of Modula-2 code, even though it does SC> optimise very well. No optimizer has the power of the human brain. It can SC> be a time consuming job though. I FULLY agree with this. I optimized even a very small routine like below. It became smaller,safer (check on HIGH(S) didn't exist in the original concept) and faster. PROCEDURE StrStr(VAR S : ARRAY OF CHAR;C:CHAR;Size:CARDINAL); (* Old Basic routine String$, fill string "S" with Size times C. *) VAR A : CARDINAL; BEGIN IF Size>HIGH(S) THEN Size:=HIGH(S); END; FOR A:=0 TO Size-1 S[A]:=C; END; IF Size #HIGH(S) THEN S[Size]:=CHR(0); END; END StrStr; >> Unlike other compilers, there is no -in-line- assembler in TopSpeed, >> but the full 3.1 package does have an assembler ( but little documentation >> !). You however have full control over the parametertransfer. Unlike Borland Pascal. (Correct me if I'm wrong, I'm not fully sure, about this) I have a feeling that the code for a complete asm. procedure is larger than the code the programmer wrote. Extra instructions are added to load the parameters, because this extra code is generated by the compiler, it's probably not optimal. You could work an hour to save some cycli in a important loop, and the real pain in the ass is the parameter transfer. SC> My main criticism of TopSpeeds assembler is the lack of macros. And you can SC> do inline assembler if you need it, but you have to use machine code. I also miss (full, like borland) inline assembler. Extra modules complicate the routines (e.g. loading different segment; I usually work in Large), and cost several bytes. It's not clear what belongs to one module and what to another. I tried to maintain the convention used in the library sources. If xxxx is the module name, the assembler routines that belong to that module are called Corexxxx. Marco (M.W.T.J.v.d.Voort@stud.tue.nl or MarcoV@stack.urc.tue.nl)
Technical Details
Message-ID:
<807534257.AA00870@puddle.fidonet.org>Path:
arc1-ca.pugleaf.net!newsfeed.internetmci.com!psgrain!puddle!internetShow Full Headers
Complete Article Headers
From: Marco.van.de.Voort@p18.f402.n284.z2.fidonet.org (Marco van de Voort) Path: arc1-ca.pugleaf.net!newsfeed.internetmci.com!psgrain!puddle!internet Newsgroups: comp.lang.modula2 Subject: TopSpeed and assembler. Message-ID: <807534257.AA00870@puddle.fidonet.org> Date: Tue, 01 Aug 1995 14:49:04 -0800 X-FTN-To: Scott Cornwall