From: gturgeon@meol.mass.edu (Gregoire Turgeon)
Subject: Re: 3D game engine for PB?
On 10 May 1998 06:05:35 GMT, guymacon@deltanet.com (Guy Macon) wrote:
>I have a subscription to the Developer Network, but the C programmers
>in my dept. use it a lot more than I do. I am a hardware expert, and
>I do simple coding only (moving a robot arm, testing a CD for flatness,
>that sort of thing). I find PB to be just about perfect for this
>sort of work. My question is what to do when I need to put a little
>bit of assembly language code in a PB program. Is my best choice to
>just ignore all assemblers and do it in inline code from the PB
>environment? That's what I do now, despite access to any assembler
>I want to use. Would I be better off using a "real" assembler?
>Remember, we are talking about very small and tight Assembly Language
>loops embedded in a PowerBasic program.
I've found only two compelling reasons for bringing in $LINKed
assembler code.
First, if a substantial sequence of 32-bit instructions is required,
then linking an OBJ is worth the overhead of the call to the routine.
PB also places OBJ code in a separate code segment, which adds to
overhead. In some cases, though, access to 32-bit registers is well
worth the additional complexity. If only a few 386+ instructions are
required, the inline assembler works just fine. In such cases, I
write the ASM for TASM, assemble to generate a listing file, then just
plug the listing file's opcode entries into the PB inline assembler
code. This is a larger-scale example of the same thing that Bob Zale
suggested.
The other case when using a separate assembler has proven valuable
involves the macro capability of a full-feature assembler. Converting
code from C or Pascal or BASIC to assembler often is easier if you can
"add total, next sum" instead of adding ax to dx and trying to keep
straight the contents of each.
PowerBASIC's inline assembler can do much that's not always apparent.
To cite only one example, a near routine is easy to specify simply by
using "! call near Target" and using "! retn" to return from Target.
As always, simpler is better. One tool is better than two, as long as
the tool does what's required, and quickly enough. And if the choice
of tools isn't limited by cost--what luxury.
--
Greg Turgeon
*** QwkNews (tm) v2.1
* [TN71] alt.lang.powerbasic POWER_BAS Gateway
--- GEcho 1.20/Pro
---------------
* Origin: Toast House Remote (1:100/560.2)
|