14.2 TAssembler methods:
void Initialize( TMaster_Assembler* )
Informs the assembler the a new assembly operation is beginning. This assembly will use the passed master assembler.
void Terminate
Informs the assembler that the current assembly operation is now complete.
TUEC Assemble( string inputs, string &outputs, string &machines, integer &machinel, int64 &address, integer &Segment, TAssembler_Status* Status )
This method is equivalent to the Assemble_Ex method with the Flags parameter set to 0.
integer Default_Radix()
Returns the default radix (base) of numeric literals.
integer Default_Size()
Returns the default size of numeric literals, in bits.
integer Facility_Code()
Returns the facility code for this assembler (see UEH).
string Source_Extensions()
Returns a bar-delimited list of source file extensions. The first one is the default. Example: "asm|mac|txt"
string Valid_Symbol_Initial()
Returns a list of valid characters for starting a symbol name.
string Valid_Symbol_After()
Returns a list of valid characters for a symbol name, past the first.
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.
boolean Backpatching( string Name, int64 Address, int64& Value, integer& Size, integer Context, integer Options, Tassembler_Status* Status )
Called by the master assembler just before it backpatches an address. If the function returns False, the master assembler doesn't perform the backpatch. Otherwise it does. Name is the expression that was evaluated for this backpatch, Address is the address of the backpatch data, Value is the data to write to Address, and Size is the size of the backpatch, in bytes. Context and Options are the values passed to the Add_Reference_Ex method of the master assembler.
The following methods are supported in TAssemblers conforming to version 2.2, or later, of the specification.
string Normalize_Expression( string Expression, boolean Numeric, TAssembler_Status* Status )
This method is called by the Master Assembler when it is about to evaluate an expression. This allows the CPU's assembler to handle any special syntax, etc, by converting the expression to a "normalized" expression that can be understood by the master assembler. If the CPU's assembler doesn't handle this it should simply pass back the passed-in value.
TUEC Assemble_Ex( TCOM_Stream* Input, TCOM_Stream* Output, TCOM_Stream* Listing, TAssembler_Status* Status, integer Flags )
This method assembles the source code in the inputs string. If inputs is a null string, the assembler should fetch the data from the master assembler (Get_Token method). Formatted output (if any) is returned in outputs, which is assumed to be in a human-readable form. Upon return, machines contains the generated machine code for the instruction(s) passed. machinel is the length of the data in machines. address is the target memory address where the machines data is to go. Segment is the current destination segment for the data in machines. It has the following values:
0 = Default code segment
1 = Default data segment
other = CPU-dependent or user-defined segments
machinel, address, and Segment are passed the current values from the master assembler,
but the called assembler may change them. address is virtual
(physical if virtual addressing not supported by CPU). Status is the
status object to be used to log assembly status. Flags are bit flags indicating processing options:
Value |
Description |
1 |
Assembly is in immediate mode. No forward declarations should be allowed. |
2 |
Generate symbol table. Note that this can be overriden in the source file. |
4 |
Generate cross-reference table. Note that this can be overriden in the source file. |
8 |
Generate assembled code into the physical address space. If not set, code is assembled into the virtual address space. |
16+ |
Reserved. |
Assembler Context
The assembler context is used to keep track of symbols defined during assembly. It is used both by the master assembler and also by any
application that wishes to make use of symbol information after assembly. Essentially, the assembler context is a symbol table manager.
During assembly, all symbol manipulation should be done through the Master Assembler rather than directly through the assembler context so that the Master Assembler has the option of keeping additional symbol information. TCEF_Assembler_Context has the following methods.
int Add_Mapping( char* Filename, int64 Address, int Line )
Associates a memory address with a Filename and Line number. The line number is 1-based. The method returns a context which can be passed to Delete_Mapping.
TUEC Add_Symbol( char* Name, TSymbol_Record* P )
Adds a symbol to the current scope with the data specified in P. The return value's code field is one of the following:
Value |
Meaning |
0 |
Success |
1 |
Invalid symbol name |
2 |
Reserved name |
3 |
Multiply defined symbol |
void Delete( char* Sym )
Deletes the symbol with the specified name from the current scope, or the most recent scope in which it was defined.
void Delete_Mapping( int Index )
Deletes the mapping added with Add_Mapping. Index is the mapping context returned by Add_Mapping.
int Find( char* Sym, int64& Addr, int& Flg, int& D_T, int& Siz, void*& Dat )
Returns information on the specified symbol in the current, or nearest, scope. Sym is the symbol name and the rest of the parameters are ignored on call. On return, Addr is the address/value of the symbol, Flg is symbol flags, D_T is data type, Siz is the size (in bytes), and Dat is user-defined data. Method return values:
Value |
Meaning |
0 |
Success |
1 |
Invalid symbol name |
4 |
Undefined reference |
5 |
No more matches |
int Mapping( int64 Address, char*& Filename )
Returns filename and line number corresponding to the passed address. If there is no mapping, it returns -1.
void Pop_Level()
Ends the current symbol table scope level. All Symbols in the current scope are lost and the previous scope becomes the current scope.
void Push_Level()
Begins a new symbol table scope level.
bool Symbol_Value( char* Name, int64& Value )
Get value associated with passed symbol. If symbol is unknown, it returns False.
Bool Symbol_Size( char* Name, int& Value )
Get size associated with passed symbol. If symbol is unknown, it returns False.
bool Get_Case_Sensitive()
Returns True if the symbols are case-sensitive.
void Set_Case_Sensitive( bool Value )
If Value is true, the symbol table is case-sensitive. If false, it is case-insensitive
The following methods are supported in assembler context objects conforming to version 2.2, or later, of the specification.
integer Find_First( string& var Sym, int64& Addr, integer& Flag, integer& data_type, integer& Size, void* Data )
Finds the first symbol (alphanumerically) defined in the symbol table. All paramters are ignored on call and filled with the data for the first symbol on return. See Find method for details on the return value of the method.
integer Find_Next( string& var Sym, int64& Addr, integer& Flag, integer& data_type, integer& Size, void* Data )
Finds the next symbol (alphanumerically) after the preceding Find_First or Find_Next call. All paramters are ignored on call and filled with the data for the first symbol on return. See Find method for details on the return value of the method.
The following methods are supported in TAssemblers conforming to version 2.2, or later, of the specification.
int64 Begin_Assembly()
Informs the assembler that an assembly operation is about to begin. The return value is a context that is passed to Finish_Assembly.
TUEC Finish_Assembly( int64 Context, string &outputs, string &machines, integer &MachineL, int64 &Address, TAssembler_Status* Status, integer Flags )
Informs the assembler that the last assembly operation has completed. The value from Begin_Assembly is passed. See Assemble_Ex for flags meanings.
int64 Request_Data( int64 Address, int64 Size )
When the master assembler is about to allocate data (eg due to a .DB directive), it calls the CPU assembler with the address and size of the data. The assembler can then adjust the address, if necessary, and return the address to which the data is to be placed. If there is no place for the data, -1 is returned.