Extension Manual

Embed Size (px)

DESCRIPTION

Manual of extension

Citation preview

  • 7/17/2019 Extension Manual

    1/2

    Files included:

    ExtensionReadMe.txt - this fileLC3Extension.h - A reusable header defining all necessary functions andconstantsExtensionSample.vcproj - A Microsoft Visual Studio .NET project file for building the sampleExtensionSample.cpp - A sample extension for the simulatorExtensionTest.asm - A sample LC-3 program that takes advantage of the sample extension

    What is an extension?An extension lets you add new functionality to the LC3 simulator. An extensionis a DLL that exports two methods: FireInterrupt3 and ExecuteReservedOpcode3.The simulator calls these methods at the appropriate time during the instructioncycle to allow the extension to implement interrupts and/or to provide animplementation for the reserved opcode in the LC3 ISA.

    What must you implement?Your DLL must export FireInterrupt3 and ExecuteReservedOpcode3. The functionprototypes are defined in LC3Extension.h along with other constants that may beuseful in writing your extension. A sample project is also included thatimplements both of these functions. LC3Extension.h is designed to be resusedin your own extension. Each of these methods takes callback methods to

    read and write to the various memory addresses and registers in the LC3 memoryspace at the time of the call.

    ExecuteReservedOpcode3 takes a callback for reading and writing values to theLC3 memory space. An implementation will typically use these callbacks to getthe bits of the current instruction then perform some custom operation giventhose bits.

    FireInterrupt3 returns the interrupt vector for the interrupt that should befired. If no interrupt should be fired, the method returns NO_INTERRUPT.This method takes only the read callback and therefore can not write to theLC3 memory space. Any modifications should be performed by the executingprogram in the interrupt handler. It is often the case that the interrupt

    handler will make use of the reserved opcode to make further calls into theextension.

    The sample programThe included sample program can be compiled with Microsoft Visual Studio .Net.It implements an interrupt, x0081, as a one second timer. The simulatorcalls FireInterrupt3 each time through the instruction cycle in which nointerrupt handler is executing. The sample extension keeps track of theamount of time since it last fired the interrupt. If more than one secondhas passed, it fires the interrupt again.

    The accompanying LC3 application implements an interrupt handler for interruptx0081. The handler executes an instruction that uses the reserved opcode.

    The extension has defined the opcode to return a random number from 0 to 9in the register defined in bits 9 to 11 of the instruction. The LC3 programthen writes that value to the console in the interrupt handler.

    Recommendations for your extensionsDon't cache the callback pointers you receive during the extension calls.They should not be saved and used in other threads after your extensionreturns. They may also change from one call to the next.

    The LC3 has been designed to operate on all 32 bit Windows operating systems

  • 7/17/2019 Extension Manual

    2/2

    with a minimum of access rights. As a result, the simulator does not accessthe registry or require any type of installation. It's expected thatthe simulator will run in a variety of environments, from personal computersto university networks. Therefore it interacts as little as possible withpermissioned system resources and does not take advantage of any functionalityavailable only in more recent operating systems. Please keep this in mindwhen considering who will use your extension and how you intend todistribute it.