|
| |
|
|
Assembly language
Assembly
language is one of my most recent acquistions
of programming languages. It has many attractions:
it offers an unmatched level of control, with
the processor and FPU being given instructions
directly; and, once optimised, is the fastest
method of achieving a logical operation. It
is possible to construct programs from scratch
by using a stand-alone assembler, such as MASM,
but this is incredibly laborious, simple operations
such as the initiation and access of an array
being turned into a feat of organisation and
logic. Instead, I prefer to use small snippets
of assembly code incorporated into my Pascal
programs, particularly in those routines which
are heavy on calculation and include little
mundane code for the manipulation of variables.
Hence, a more efficient program can be produced,
with the bulk code operated by Pascal and only
the most calculation intensive sections being
converted to optimised assembler; and experimentation
has shown that this can give a nine-fold increase
in the speed of a program. Currently, the background
rendering device in Trooper II, all of the high
resolution graphics engine, the texture mapper
of my 3D engine, and the function iterator for
the Mandelbrot generator are all coded in assembler,
and I have come accross many situations where
the Pascal, even if completely tight FOR
loops are employed, is simply not fast enough
to accomplish the task for a given frame rate.
In these cases, the integration of in-line assembly
code into the Pascal programs can give sufficient
speed to make that operation viable. My standard
procedure for the conversion of a complex logical
procedure into optimised assembler is to write
out that routine in Pascal, test until I am
certain it is performing to expectation, and
then to convert the Pascal directly into a crude
assembler. This can be tested again, to ensure
complete conversion, before the code is optimised.
By the use of DB $66 tags, the 16 bits
recognised by Pascal can be treated as the wole
32-bit registers, allowing extremely fast clearing
and copying operation for images. I essentially
learnt assembler out of necessity for fast code;
and during this process I found The
Art of Assembly
Language an indespensible guide,
providing an exaustive guide that allowed me
to procure a secure grasp on the 80x86 and the
FPU within a few weeks. Stand by for a download
of the standalone Assembler, MASM on this page
- in the meantime, an assembler, TASM, is incorporated
into the Pascal
6.0 editor.
|
|
|
| |
|