14.1.1 TMaster_Assembler reference

TMaster_Assembler contains the following methods:


void Add_Reference( string Name, integer Size, int64 Address )


Adds a named reference to the back-patch table. See Add_Reference_Ex for details.



TUEC Add_Symbol( string Name, TSymbol_Record* P )


Adds a symbol to symbol table in the current scope. Name contains the name of the symbol and P contains specific information about the symbol.



TUEC Assemble( TCOM_Stream* Input, TCOM_Stream* Output, TCOM_Stream* Listing, TAssembler_Status* Status )


This method is equivalent to the Assemble_Ex method with the Flags parameter set to 0.



void Backpatch( TAssembler_Status* Status, TCOM_Stream* Stream )


Apply all items in the back-patch table. Should be called after assembly is complete.



TUEC Evaluate( string X, int64& Value )


Evaluates an expression, returning the numeric value in Value. This method exists only for backwards compatibility. It is equivalent to calling Evaluate_Ex with a PC_Adjustment value of 0.



TUEC Expand( string Source, string Res, integer& Res_Length, TAssembler_Status* Status )


This method is used during assembly by a TAssembler to insert assembly source in-place. For instance, translating a directive into a standard directive, or doing macro expansions, etc. If the expanded item is a directive that results in output, Res will be that output and Res_Length will be the size of that data, in bytes. Use In_Line if several lines of assembly (such as a macro definition) need to be inserted.



integer Facility_Code()


Returns the facility code for this assembler (see UEH).



boolean Get_Case_Sensitive()


Returns True if case sensitivity to identifier names is on.



TSymbol_Record* Get_Symbol( string Name )


Returns the symbol record for the identifier in Name. Returns NULL, if Name is undeclared.



string Get_Token()


Returns the next token in the input stream during an assembly. Returns a null string if an error occurs (such as no more input). This is useful for assemblers which need more input for a directive which is continued on additional lines.



string Grab_Line()


Returns entire current (remaining) input line from the token stream.



void In_Line( TCom_Stream* Input )


Inserts the data from the passed stream into the current token stream. Used Expand to insert only a single line.



void Log_Error( string Text, integer Severity )


Logs an assembly error. Severity indicates the seriousness of the error:

0 = Informational

1 = Warning

2 = Error

3 = Fatal error (abort assembly)



void Map( int64 Address )


Map current token position to the passed address.



string Peek_Token( boolean Same-Line )


Returns the next token from the token stream without removing the token from the stream.



void Pop_Scope()


Ends the current symbol table scope. All Symbols in the current scope are lost and the previous scope becomes the current scope.


void Push_Scope()


Begins a new symbol table scope.



void Put_Token( string Token )


Returns a token to the input stream during an assembly.



void Set_Case_Sensitive( boolean C )


Sets case sensitivity on identifier names.



void UnMap()


Removes the previous mapping added with Map().



integer Version()


Returns the version of the CEF specification that the object adheres to. This is the major.minor version times 10. For instance, a value of 20 indicates version 2.0.



void Add_Reference_Ex( string Name, integer Size, int64 Address, integer Context, integer Flags )


Adds a named reference to the back-patch table.


Name is the symbol name.
Size is the size of the item, in bytes. If less than 0, this is interpreted as a packed bit range, where the low 16 bits indicate the starting bit (0 is the lowest significant bit) and the high 16 bits (minus the sign bit) indicate the number of bits involved.
Context is supplied by the calling code and is returned via the Backpatching method of Tassembler.
Flags is reserved for future use.


void Set_Assembler_Context( TCEF_Assembler_Context* Value )


Sets the assembler context object for the master assembler.



TCEF_Assembler_Context* Get_Assembler_Context ()


Returns the assembler context object for the master assembler. If one is not assigned, the method returns NULL.



Void Terminate()


Destructs the assembler object.



The following methods are supported in master assemblers conforming to version 2.2, or later, of the specification.


Boolean Leading_Whitespace()


Returns True if the current token line began with space or tab character(s).



TUEC Assemble_Ex( TCOM_Stream* Input, TCOM_Stream* Output, TCOM_Stream* Listing, TAssembler_Status* Status, integer Flags )


Assembles code from the Input stream, directing the image data to the Output stream, and placing any list output to the Listing stream. Note that Listing can be NULL if no listing is desired. Output can be NULL to do a syntax-check-only assembly. Status is used to log information. Flags are bit flags indicating processing options:

Value

Mnuemonic

Description

1

ASF_Immediate_Mode

Assembly is in immediate mode. No forward declarations should be allowed.

2

ASF_Want_Symbol_Table

Provide Symbol table listing.

4

ASF_Want_XRef

Provide Cross-reference listing.

8

ASF_Generate_Virtual

Generate into physical address space (rather than virtual).

16

ASF_Disassemble

Disassembly is using assembly to get information on instruction.

32

ASF_Extended

Passed stream is a TCEF_Stream, otherwise a TCOM_Stream.

64+

Reserved.



TUEC Evaluate_Ex( string X, int64& Value ; int64 PC_Adjustment )


Evaluates an expression, returning the numeric value in Value. PC_Adjustment is a value to add to any reference to the current program counter. This is useful for assemblers which must evaluate expressions potentially including references to the program counter, when the assembler has implicitly changed the program counter. For instance, a word instruction followed by a program counter-relative value when that value is relative to the program counter after the instruction has been fetched (in which case 2 would be passed to PC_Adjustment). Return codes:

Value

Mnuemonic

Meaning

0

MasterAssemblerErr_Success

Success

1

MasterAssemblerErr_Invalid_Digits

Invalid digits for current radix.

2

MasterAssemblerErr_Illegal_Expression

Illegal expression.

3

MasterAssemblerErr_Unterminated_String_Literal

Unterminated string literal.

4

MasterAssemblerErr_Undefined_Symbol

Reference to undefined symbol.


The following methods are supported in assemblers conforming to version 2.5, or later, of the specification.


integer Get_Base()


Returns the current base (radix).




void Set_Base( integer Value )



Set the current base (radix) to Value.


The following methods are supported in assemblers conforming to version 2.6, or later, of the specification.


void Register_Extension( TAssembler_Extension* Extension )


Registers an assembler extension.