🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #2675

TopSpeed and assembler

#2675
From: Marco van de Voort
Date: Tue, 01 Aug 1995 22:49
53 lines
2303 bytes
Hallo granville!

Friday June 30 1995 22:23, granville wrote to All:

 >> Does anyone out there know how to put assembler into a modula-2 program?
 >> (I'm using the TopSpeed modula2 compiler in DOS..version 3.1 I think)

 g>  Why would you need to - it optimises very well ?

Yes, but not that well, for example calculation of CRC32,
assembler : 2.5 - 3 times(depends on pragma) faster than Modula-2 routines
(with the same algoritm!)

And why do you think the shipped libraries are for a large part in assembler?

 g>  I would suggest coding the module in M2 first, debug and optimise
 g> thoroughly, then if you still think a gain is there for the taking, use
 g> either the disassembler, or VID, to check the procedure head and tail code,
 g> then using the SRC\.A files as templates, asm optimise your m2
 g> procedure.

I fully agree with this strategy, and do it myself this way. I also recommend using the profiler.

 g> There are also examples of m2 and C calling conventions in the
 g> \EXAMPLES files. The m2 compilers that DO allow inline Assembler, suggest
 g> you do NOT use it as it bypasses the optimiser!

I think the asm inline part is pretty useless, the few procedures it could be handy are predefined (In,Out etc)

However, the INLINE M2 command IS useful.

by the way:

Question : how can I select on the CpuId pragma in the assembler part of a module?

I need it, because testing of a bitset (IF 5 IN BITSET THEN..) is done with the instruction BT when compiling 386+. The 8086 equivalent is several(>6) instructions long.

So I want to do something like this :

(*%T CpuId 3 *)         (* suppose 3= 386 and higher *)
bt [memory],6
(*%E*)

(*%F CpuId 3 *)         (* else 8086 code *)
  mov ax,[memory]
  and ax,7
  etc
  etc....
(*%E*)

Same with things like Outsb ,insb movsb etc. But mainly because of the BITSET, because the difference is quite big.

Marco  (M.W.T.J.v.d.Voort@stud.tue.nl or MarcoV@stack.urc.tue.nl)
Technical Details
Message-ID: <807534257.AA00869@puddle.fidonet.org>
Path: arc1-ca.pugleaf.net!news.sprintlink.net!psgrain!puddle!internet

Show 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!news.sprintlink.net!psgrain!puddle!internet
Newsgroups: comp.lang.modula2
Subject: TopSpeed and assembler
Message-ID: <807534257.AA00869@puddle.fidonet.org>
Date: Tue, 01 Aug 1995 14:49:03 -0800
X-FTN-To: granville