Object-Oriented Asm?
All of the assembler example source I've seen is organized so that code is
in one section (the first), initialized data is in another, and
uninitialized data areas (if any) are in the third. Is this purely a
matter of style, or are there overwhelming technical reasons in favor of
doing things this way?
For example, say I have a code fragment to handle stdout. It would open
Dos.Library and store the results of Output() into an uninitialized data
region. It would handle intelligently any errors. In pseduo-code it would
look like this:
if not defined [dos.library handle]
define it, open it, complain on failure, store it, and
push the close-library routine onto the cleanup stack
jmp 10$
DosName PSTRING 'Dos.Library'
DosHandle DS.L 1
CloseDos … ; Routine to close library
endif 10$:
if not defined [stdout handle]
jsr Output() and store handle
jmp 99$ stdout DS.L 1 99$ ; All done
This approach allows assembly include modules to have initialization and
termination code. Does it give the loader screaming fits? Does it result
in objects spread all over memory? Should I try it and find out myself the
hard way?