Object loader syntax suggestion

Hans-Dieter Dreier Ursula.Dreier@ruhr-uni-bochum.de
Wed, 07 Apr 1999 23:54:25 +0200


Object loader syntax
====================

Object loader (short: OL) is an assembler-like language for initial
loading of objects into Ultra's workspace and as a test support.

An OL call takes one parameter (the file name).

Object loader uses a single flat name space and processes its source in
one pass.
Forward declarations are dealt with by fixups as soon as the symbols are
known.

The proposed syntax builds upon the memory layout.
Please see the thread "PS: Memory Layout Proposal" for details.

OL will insert BPs and FPs as required and adjust label values
accordingly.
Binary stuff that is followed by references will also be automatically
padded for proper 4-byte alignment of the next item.

The C comment convention is used.

The last item of the source should be a reference.
The value of this reference will be the result of the OL call.



The syntax consists of these elements:

1. Definition of predefined references
This is used to define special constant values that can be used instead
of references.
The most common example for this is NULL (the NULL referece).
If VM is extended to support special values, these will be defined here
as well.
Form:

<Name of predefined reference> = # <Number>

Example:

NULL = # 0
EXEC = # 1

Usually definitions of predefined references will occur at the start of
the OL source file.


1. Definition of predefined numbers
This is used to define special constant values that can be used instead
of numbers.
They may be used to define MC's ordinal numbers as symbolic constants.
For the moment, there is just one fixed MC table (static C++ array).
Later, it needs to be replaced by some more versatile construction.
Form:

<Name of predefined number> = <Number>

Example:

VM = 0
OL = 1

Usually definitions of predefined numbers will occur at the start of the
OL source file.


2. Memory object boundary
This is used to trigger generation of a new memory object which can hold
multiple (logical) objects.
It must occur before the first object boundary, label or item.

Forms:

[]
[<Flags>]
[<Flags>,<Unused bytes>]

<Flags> and <Unused bytes> are numbers that specify the corresponding
fields of a memory object.
They will default to 0.


3. Object boundary

This is used to trigger generation of a new object.
It must occur before the first item or label.

Form:

#


4. Label

This will introduce a new name (reference) that will be associated with
the current location.

Form:

<Name of new reference> :


5. Reference item

This will generate an item containing a reference.

Form:

<Name of reference>


6. Numerical item

This will generate a 32-bit signed numerical item. For a start, no hex
values will be supported.
Multiple adjacent numerical items will be put into one "binary stuff"
item.
This can be broken up by starting a new object.

Form:

[-]<Digits>


7. Text item

This will generate a 8-bit, null-terminated, string item.
Each text item will be put into its own "binary stuff" item.
Either "" or '' delimiters may be used. If the used delimiter occurs
inside the string, it must be doubled.
No escape sequence (\) like in C is used. If you want a tab or a
newline, you simply write one.




Example for some simple program (assuming a stack VM): "Hello world"


// predefined references

NULL = #0

// predefined offsets into MC table

VM = 0  // VM itself (for function calls)
OL = 1  // object loader
EXIT = 2 // exit MC (terminates VM by exception)
// more MCs...
STDOUT = 23 // console output

[]  // start a new memory object
#  // start a new object
NULL  // the class is not yet needed but the space is reserved - will be
class "method"
Text  // push a reference to the text
STDOUT  // push a reference to STDOUT MC
NULL  // execute pushed STDOUT MC
EXIT  // push exit op
NULL  // execute pushed exit op - terminates VM

Text: "Hello World"



Any suggestions, comments?

--

Regards,

Hans-Dieter Dreier
(Hans-Dieter.Dreier@materna.de)