[Coco] 6309 microprocessor project - 10-19-2003 # 2

John Collyer johncollyer at zoominternet.net
Sun Oct 19 18:20:00 EDT 2003


6309 microprocessor project.

Hello,

The enhanced instruction opcode $11FF will as before let you run code, but
this code will be Intel 32 bit flat assembly code. You return to the
emulator after your finished with the code by specifying a 80386 return
instruction.  The 80386 code should be located right after the enhanced
instruction opcode $11FF in memory.  All this can be accomplished because
win32 lets us allocate memory designated as read/write/execute.  If you are
concerned about security you can set a switch not allowing enhanced opcodes.

You interface with enhanced instruction opcode by using opcode $11FF and
register x pointing to a memory block containing your 80386 virtual
registers (Register X contains the address of the first virtual register in
the memory block of your 80386 virtual registers).  The virtual registers
should be defined as follows and must be in this order in the memory block.

* My virtual 80386 registers

v86_eax fcb 0,0,0,0         * 32 bit register
v86_ebx fcb 0,0,0,0         * 32 bit register
v86_ecx fcb 0,0,0,0         * 32 bit register
v86_edx fcb 0,0,0,0         * 32 bit register
v86_edi fcb 0,0,0,0         * 32 bit register
v86_esi fcb 0,0,0,0         * 32 bit register
v86_ebp fcb 0,0,0,0         * 32 bit register

The 80386 code should be placed right after the opcode $11FF in your program
as data.  How you get the 80386 code into data and the correctness of that
data remains the programmers problem and the enhanced instruction opcode is
only a interface allowing you to execute the data that contains 80386 code.
When you finish executing the 80386 code use a "ret" instruction to return
to your program.  Note that this means you must load the 80x86 register SI
with your 6809 re-entry address before issuing a RET.

Here is a example:

BeginEx pshs u              *
        leau v86_eax,pcr    * Point to My virtual registers
        ldy #28             * sizeof virtual register data block
        ldq #$0FFFFFFFF     * This is simulated register data
storedata stq ,u            * Save data in virtual registers block
        leau 4,u            * Point to next virtual register in block
        leay -1,y           * count it
        bne storedata       * store all data
        leax v86_eax,pcr    * Point to My virtual registers data block
        fdb $11FF           * Call the win 32 code below
                            *
* My 32 bit code            * esi points here = program counter
                            *
        fcb $00,$00         * mov eax,0         ;simulate 32bit code
        fcb $83,$C6,06      * add esi,00000006  ;add size of this 32bit
                            *                   ;code into esi = program
counter
        fcb $C3             * ret               ;return

* We returned from 32bit code here

        ldq v86_eax         * Get virtual register eax
        tstw                * Any return value?
        beq quit            * No,
        exg w,d             * Exchange words
        stq v86_eax         * Save it

quit    os9 F$Exit          * Done

        end BeginEx         * done with example

* My virtual 80386 registers

v86_eax fcb 0,0,0,0         * 32 bit register
v86_ebx fcb 0,0,0,0         * 32 bit register
v86_ecx fcb 0,0,0,0         * 32 bit register
v86_edx fcb 0,0,0,0         * 32 bit register
v86_edi fcb 0,0,0,0         * 32 bit register
v86_esi fcb 0,0,0,0         * 32 bit register
v86_ebp fcb 0,0,0,0         * 32 bit register

Note: You must keep this order for the 80386 virtual registers and you must
supply the data block of virtual 80386 registers with register "x" pointing
to it to call the enhanced instruction opcode $11FF correctly.  The enhanced
opcode saves the 80386 registers, after you return into the virtual 80386
register memory block you supplied with register "x" pointing to it, when
you called the enhanced opcode $11FF.

More later.

John Collyer




More information about the Coco mailing list