8 CPUs

CPUs differ from most other components in that they usually take over the operation of the application once Marshalling is complete. Initialization of the CPU component doesn't begin operation (the TCPU.Run method does). That way, Marshalling can be completed prior to the CPU beginning operation. Functions unique to CPUs are accessed via the TCPU object, provided via the Tcomponent.CPU method.


CPUs support the concept of address spaces. There is always at least one address space (index 0), which is the default address space. An address space is a range of memory addresses. Some CPUs may only support a single address space which is accessed via the Program Counter (or Instruction Pointer). Other CPUs with virtual memory mapping may support a number of address spaces, each of which is indexed via a different register.


CPU's examine/deposit methods access the internal cache of the CPU (if Memory parameter is true) or the registers of the CPU (if Memory parameter is false). See the TCPU.Register_Name and TCPU.Register_Size methods for more information on the CPU registers. A CPU component returns a TCPU* instance when the CPU() method is called.


The TCPU class has the following methods:


boolean Big_Endian()


Returns True if the CPU processes data in a big-endian manner (most-significant bytes at lower addresses), or False if the CPU processes data in a little-endian manner (least significant bytes a re lower addresses).



TUEC Cancel_Breakpoint( int64 Address, integer Space, boolean Physical )


Clears a breakpoint at the specified address in the specified address space. If Physical is true, the address is a physical address, otherwise it is a virtual address.



TUEC Clear_Internal_Watchpoint( int64 Address, boolean Memory, integer Access )


Clears a watchpoint at the specified address. Access is the type of access:

1 = Read or write (input or output)

2 = Read (input)

3 = Write (output)

If Memory is true, the address is an internal cache address. Otherwise it is a register index.



integer Default_Base()


Indicates the specified base used by the CPU instruction set.



tUEC Disassemble( int64 Address, integer Base, integer Size, TCOM_Stream* )


Disassembles the instructions at the specified physical memory address, for the specified number of bytes and directs the output to the passed stream. Constants are shown in the specified base. If Base is 0, the CPU's default base is used.



integer Facility_Code()


This method returns the facility code for this object.



TAssembler* Get_Assembler( TMaster_Assembler* )


This method returns an assembler object for this CPU. It is passed a TMaster_Assembler object. See the section on the Assembler fo details.



integer Get_Clock_Speed()


Returns the CPU clock speed (in KHz).



int64 Get_Current_Address( integer Space, boolean Physical )


Returns the current CPU memory position for the specified address space.



int64 Get_Low_Memory()


Indicates the lowest physical memory address accessible by the CPU.



int64 Get_High_Memory()


Indicates the highest physical memory address accessible by the CPU.



int64 Get_Low_Port()


Indicates the lowest port address accessible by the CPU.



int64 Get_High_Port()


Indicates the highest port address accessible by the CPU.



int64 Get_Low_Virtual_Memory()


Indicates the lowest virtual memory address accessible by the CPU.



int64 Get_High_Virtual_Memory()


Indicates the highest virtual memory address accessible by the CPU.



void Halt()


Halts CPU execution. The effect upon the CPU is implementation-dependent.



boolean Halted()


Returns true if the CPU is in a halted state (non-execution mode).



string Memory_Space_Description( integer Index, boolean Physical )


Returns a description of the memory space with the specified index. It returns NULL for any invalid index. Physical is True for physical memory space and false for virtual address space. Most CPUs make no distinction between physical and virtual memory in this method.



integer Page_Size()


Returns the CPU's memory page size, in bytes. If the CPU doesn't support paging, this returns 0.



string Register_Description( integer Index )


Returns a description of the register associated with the specified index (0 is the first valid index). If the index is not valid, the function returns NULL. This is not the register name, but some additional information about the register. For instance, for a flags register, this would be a break-out of the flags in the register.



string Register_Name( integer Index )


Returns the name corresponding to the register index passed. A null string or NULL result indicates that the index is out of range. Note that all registers start at offset 0. Register 0 is always the current Instruction pointer (IP, PC, etc) and register 1 is always the current Stack pointer (SP).



integer Register_Size( integer Index )


Returns the size (in bits) of the register associated with the passed index. A result of 0 indicates that the index is out of range.



void Restart


Performs a power-on (cold) reset.



void Run()


Begins CPU execution from the current CPU state. Typically one instruction is executed, and then the CPU requests a block from the master clock.



void Run_From_Stream( TCOM_Stream* )


The causes the CPU to execute instructions directly from the passed stream. This is usually for immediate instruction execution from the user interface, thus no profiling is done, no breakpoints apply, and single-stepping does not occur.



TUEC Set_Breakpoint( int64 Address, integer Space, boolean Physical )


Sets a breakpoint at the specified address in the specified address space. When the CPU is about to begin execution at this address, it will generate a breakpoint notice to the UI interface. If Physical is true, the address is a physical address, otherwise it is a virtual address.



void Set_Clock_Speed( integer value )


Sets the CPU clock speed (in KHz).



void Set_Current_Address( integer Space, boolean Physical, int64 Value )


Sets the current CPU memory position for the specified address space. If Physical is true, the address is a physical address, otherwise it is a virtual address.



TUEC Set_Internal_Watchpoint( int64 Address, boolean Memory, integer Access )


Sets a watchpoint at the specified address. When the CPU is about to access this address, it will generate a watchpoint notice to the UI interface. Access is the type of access:

1 = Read or write (input or output)

2 = Read (input)

3 = Write (output)

If Memory is true, the address applies to internal cache. If Memory is false, address is the register.



void Step( boolean Into )


Executes a single instruction based on the current CPU context. This is the same as Run(), but execution doesn't continue after the CPU is unblocked. If Into is true, only a single instruction is excecuted. If Into is false, and the instruction to be executed is a nested instruction (such as a subroutine call), execution continues until the execution returns to the instruction following the call.



void Stop()


Stops CPU execution.



boolean Support_Virtual_Address()


Returns True if the CPU supports virtual address mapping.



int64 Top_Of_Stack( integer Index )


Returns the address of the top of the stack with the specified index. The first valid stack index is 0. For CPUs with only one stack, the stack is index 0.



int64 Translate( integer Space, int64 Address )


Returns the physical address for the passed virtual address in the passed address space. For a CPU with no virtual addresses, this returns the value passed.



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.



The following methods apply to Version 2.2, and later, of the specification:



int Segment_Size( int Index )


Indicates the size (in bits) of the Indexth segment in the last assembled instruction. A value of 0 indicates either an invalid Index or that the information is otherwise not available. Index < 0 is not valid. The result can be used to separate the various segments of assembled instructions. For instance, a 2-byte instruction followed by two 2-byte operands would return 2 for indexes 0, 1, and 2.



string Address_Representation( int Base, int64 Address )


Returns a representation of the passed address, or nil if not supported, or the address is invalid. This is used when addresses are displayed in a format not otherwise supported by CEF. Base is the base to use for any numeric representation.


int64 Translate_Address( Boolean& B, int Base, string Address )

Used to convert an address specification into a linear address value. B is ignored on call and is True on return if the address is a valid format. Base is the base that any numeric portion of the address is assumed to be.


int64 Get_Low_Input_Port( int Space )

Indicates the lowest input port address accessable by the CPU for port space Space. -1 indicates an invalid port space.


int64 Get_High_Input_Port( int Space )

Indicates the highest input port address accessable by the CPU for port space Space. -1 indicates an invalid port space.


int64 Get_Low_Output_Port( int Space )

Indicates the lowest output port address accessable by the CPU for port space Space. -1 indicates an invalid port space.


int64 Get_High_Output_Port( int Space )

Indicates the highest output port address accessable by the CPU for port space Space. -1 indicates an invalid port space.


TCEF_Stack_Interface* Get_Stack_Interface( int Space )

Returns an instance of a stack interface for accessing non-standard stacks for stack space Space. Returns nil if no stack or standard stack handling.



The following methods apply to Version 2.6, and later, of the specification:



TComponent* Get_Target_Memory


Return memory component that the CPU executes/disassembles from and/or assembles to. If the CPU uses the main memory, this should return null. This is used when the CPU has a code store that is separate from main system memory (such as for a microcode engine).


string Address_Representation_Ex( TComponent * C, int Base, int64 Address )


Returns a representation of the passed address, or nil if not supported, or the address is invalid. This is used when addresses are displayed in a format not otherwise supported by CEF. Base is the base to use for any numeric representation. C is the memory component associated with the address (or nil if main memory).


tUnified_Exception* Register_RTS( TRun_Time_System* RTS, int Flags )


Registers a run-time system with the CPU, with the specified notice flags:

Value Mnuemonic Description
0 RTS_Want_Nothing No callback wanted.
1 RTS_Want_Calls Notify on any call.
2 RTS_Want_Jumps Notify on any branch/jump.
4 RTS_Want_Registers Notify on any register access.
8 RTS_Want_Interrupts Notify on any interrupt/trap.
16 RTS_Want_Returns Notify on any return.


TData_Type* Register_Information( int Index )


Returns detailed information about the specified register. A result of nil indicates that the index is out of range. Note that all registers start at offset 0. Note that the returned object is only valid until the next call to Register_Information.


TComponent* Get_Store( int Index )


Returns the data/code store for the specified index. Returns null if there is no separate store for the index, or if the index is out of range. The indexes correspond to the memory space(s) used by Memory_Space_Description. This is used for CPUs that store code and/or data in separate address spaces.


int Get_Target_Address_Space


Return memory address space that the CPU executes/disassembles from and/or assembles to. If the CPU uses the main memory, this should return 0. This is used, for instance, when the assembler directs compiled value to different code and data address spaces.


8.1 TData_Type

8.2 TRun_Time_System