PowerD makes it possible to use different types of functions. First
function type is normal linked library function which allows LIST
using. All used arguments are loaded into the stack in inverse order
and then the function is called:
LPROC is mostly used by C compilers, it parses arguments inverted from its definition:
this moves to stack c then, b and then a, if You use a list as a last argument, all list
items will be inserted to stack in same order:
LPROC x(u,v,w:LIST OF LONG)
this moves to stack f, e, d, c, b and a. This is quite dull when you want use something
this will copy 3 to a, 2 to b, 1 to c and 0 to d.
Second is PowerD procedure compatible stack loading. It loads arguments in right order
but don't (currently) allows the LISTs. These are also used for external procedures:
This is quite more intelligent, but it doesn't allow inline lists as a last argument,
you can of course use normal lists (closed in: ).
works correctly, moves 0 to a, 1 to b, 2 to c and 3 to d.
Last one is best suited for assembler routines, which doesn't use stack (it is slower
than registers). Here is the limitation gave by count of registers on the cpu (MC68k
allows 8 data, 5 address registers (don't use a6 and a7) and 8 float registers. PPC
allows about 8 data/address registers and 13 float registers.):
RPROC procname(args with registers)(results)[='asm']
As you can see, it is possible to add an assembler source after RPROC definition, this
way you can generate inlined functions. Be careful about the assembler source you must
adhere right syntax:
- each line starts with tabulator '\t' or some spaces or a label
- each line must be ended with linefeed '\n'
- you must use right instruction set
- it is absolutely not affected by PowerD, it will be only copied instead of the
- it is normal string, so you can use multi line strings
- the total size of the string must be shorter than 320 characters, if You need more, use
How to build linked library:
First you have to generate object files, each object file should
contain only one function. This may be done with OPT OBJECT in
PowerD case. If you want to create an assembler routines, use export
keyword (usually xdef). Copy all these objects into a single drawer,
open shell, set there the drawer and enter 'join #?.o as xxx.lib', where
xxx is your library name. Then copy this file into 'd:lib' drawer.
Finaly you should write a module for this lib. This way is possible to
generate linked libraries from PowerD, Assembler, C etc. objects, just
select right function definition (LPROC/EPROC/RPROC).
LPROC printf(fmt:PTR TO CHAR,args:LIST)
EPROC PrintF(fmt:PTR TO CHAR,args:PTR)
RPROC PrintF(a0:PTR TO CHAR,a1:LIST)