home *** CD-ROM | disk | FTP | other *** search
- IFND Z80_STRUCT_I
- Z80_STRUCT_I SET 1
- ** The Z80 emulator control structure.
- ** Could be allocated in public memory, and shared between
- ** an emulating process and one or several supervising processes.
- **
- ** Define Z80_ENV_SIZE in 'user.i' if you want that added to the
- ** structure size, otherwise it will be defined to 0. See the bottom
- ** of this file for more details.
-
- ** ------------
-
- IFD VERBOSE
- LIST
- ** Compiling the Z80_struct.i file.
- NOLIST
- ENDC
-
- IFND Z80_INCLUDE
- INCLUDE Z80.i
- ENDC
-
- ** Macro definitions for creating structure offsets:
-
- Z80_STRUCT MACRO ;Begin structure.
- Z80_OFFSET SET 0
- ENDM
-
- Z80_BYTE MACRO ;label
- \1 EQU Z80_OFFSET
- Z80_OFFSET SET Z80_OFFSET+1
- ENDM
-
- Z80_WORD MACRO ;label ;not auto-aligned!
- \1 EQU Z80_OFFSET
- Z80_OFFSET SET Z80_OFFSET+2
- ENDM
-
- Z80_LONG MACRO ;label ;not auto-aligned!
- \1 EQU Z80_OFFSET
- Z80_OFFSET SET Z80_OFFSET+4
- ENDM
-
- Z80_BYTEARR MACRO ;name,size ;array of bytes
- \1 EQU Z80_OFFSET
- Z80_OFFSET SET Z80_OFFSET+\2
- ENDM
-
- ;Set label without bumping the offset
- Z80_LABEL MACRO ;label
- \1 EQU Z80_OFFSET
- ENDM
-
- ;Bump offset without setting a label
- Z80_BUMP MACRO ;nbytes
- Z80_OFFSET SET Z80_OFFSET+\1
- ENDM
-
- ;Set label to distance from other offset to current
- Z80_SIZE MACRO ;label,from_offs
- \1 EQU Z80_OFFSET-\2
- ENDM
-
- Z80_ALIGN_W MACRO ;word-align
- Z80_OFFSET SET (Z80_OFFSET+1)&$fffffffe
- ENDM
-
- ** ============
- ** The entries begin here:
-
- Z80_STRUCT
-
- ;The base address is referred to as TableBase from now on.
-
- ** This longword is for temporary storage, byte swapping and so on.
- ** Presently, it must be at TableBase, since Work and TableB are the
- ** same register.
-
- Z80_LONG Z80_Workspace
-
- ** ------------
- ** Index-accessed stuff. OFFSET FROM TABLEBASE MUST NEVER BE > +127 !
-
- ** Public:
- Z80_BYTEARR Z80_AccessCnt,4*Z80_MEM_CNTNUM
- ;Memory write access counters (longwords).
-
- ;private:
- Z80_BCDSTACKSIZE EQU 7 ;BCD stack (must be word-aligned!)
- Z80_BYTEARR Z80_BCDstack,6*Z80_BCDSTACKSIZE
-
- ** Public:
- Z80_BYTEARR Z80_CntType,Z80_MEM_CNTNUM
- ;Counter type designations (bytes).
- ;Zero for write, nonzero for no write.
-
- Z80_BYTEARR Z80_Parity,256 ;Parity translation table
-
- IFNE Z80_Parity>127
- FAIL Bad offset for indexed object (parity table).
- ENDC
-
- ** end of index-accessed stuff.
- ** ------------
-
- Z80_ALIGN_W
-
- IFD Z80_MAIN
- Z80_LABEL PROT_FIELDS ;Start of stuff that survives coldstart.
- ENDC
-
- ** Public:
- Z80_LONG Z80_Memory ;Pointer to the Z80 address space memory
- Z80_LONG Z80_Cachemem ;Pointer to the cache memory
-
- ** Public:
- Z80_LONG Z80_Flagmem ;Pointer to the flag memory
- Z80_LONG Z80_MemHandler ;Pointer to User Memory Exception Handler
-
- Z80_ALIGN_W
-
- IFD Z80_MAIN
- Z80_SIZE PROT_SIZE,PROT_FIELDS ;End of survive-coldstart stuff
- ENDC
-
- ** Public (read-only):
- Z80_LONG Z80_zero ;Pointer to Z80 address 0. The (signed)
- ;word-sized Z80 registers (like Z80_HL)
- ;can be used as offsets from this base
- ;to access the Z80 memory space.
- Z80_LONG Z80_cachezero ;Corresponds to Z80_Zero in the cache.
- Z80_LONG Z80_flagzero ;Corresponds to Z80_zero in flag memory.
-
- ** Public (read-only):
- Z80_WORD Z80_Running ;Nonzero if running, zero if not
-
- ; Private:
- Z80_WORD Z80_Request ;Request pointer (offset from InstrBase).
- Z80_WORD Z80_ReqLvl ;Current request priority level.
- Z80_WORD Z80_alt_CCR ;This is the internal F' in CCR format
- Z80_WORD Z80_BCD_SP ;Stack pointer for the BCD stack.
-
- ** ------------
-
- ;The CPU status structure begins here.
- ;(All offsets still relative to TableBase.)
-
- ** The public fields:
- **
- ** The label naming conventions are simple: Z80_<register>
- ** The alternative registers are referred to as Z80_alt_<register>
- ** <register> here is one of:
- ** byte-valued A, B, C, D, E, H, L, F, I, R
- ** word-valued HL, IX, IY, SP, PC
- ** special IFF, INTMOD
- ** Accessing HL will affect H and L and vice versa (HL is an 'alias').
- ** Only the word-valued entries are guaranteed to also be word-aligned.
- ** IFF and INTMOD are byte-sized, and should be interpreted as follows:
- ** IFF Bit 7 holds IFF2. Bit 6 holds IFF1. Bits 5-0 are zero.
- ** INTMOD The values in the range -1 to 1 correspond to interrupt
- ** modes 0 to 2, respectively.
-
- ** None of these entries should be written to (and rather not read either)
- ** unless the emulator is stopped, since their contents are then undefined.
- ** Most are never updated or read from except upon exiting and continuing.
-
- Z80_ALIGN_W
- Z80_LABEL Z80_CpuStatus ;offset of substructure start
-
- ;Storage area for 680x0 registers at exit. Remember to change
- ;these labels if you rearrange the register usage.
- ;Movem is of course used to write and restore, therefore it MUST
- ;be at least word-aligned.
- Z80_LABEL Z80_RegStorage
- Z80_BUMP 1 ;d0, high word
- Z80_BYTE Z80_alt_A
- Z80_BUMP 1 ;d0, low word
- Z80_BYTE Z80_A
- Z80_BUMP 1 ;d1, high word
- Z80_BYTE Z80_alt_B
- Z80_BUMP 1 ;d1, low word
- Z80_BYTE Z80_B
- Z80_BUMP 1 ;d2, high word
- Z80_BYTE Z80_alt_C
- Z80_BUMP 1 ;d2, low word
- Z80_BYTE Z80_C
- Z80_BUMP 1 ;d3, high word
- Z80_BYTE Z80_alt_D
- Z80_BUMP 1 ;d3, low word
- Z80_BYTE Z80_D
- Z80_BUMP 1 ;d4, high word
- Z80_BYTE Z80_alt_E
- Z80_BUMP 1 ;d4, low word
- Z80_BYTE Z80_E
- Z80_BUMP 2 ;d5, high word (garbage)
- Z80_LABEL Z80_HL ;HL (for word-access)
- Z80_BYTE Z80_H ;d5, low word
- Z80_BYTE Z80_L
-
- ;d6 (current flags on CCR form) is recalculated at continue.
- ;d7 holds nothing between instructions.
- ;a0 (TableB) always comes as a parameter.
- ;a1 (Pseudo-PC) is recalculated at Continue.
-
- Z80_BUMP 2 ;a2, high word
- Z80_WORD Z80_SP ;a2, low word
-
- ;Private fields
- Z80_LONG Z80_Z0 ;a3
- Z80_LONG Z80_CacheB ;a4
- Z80_LONG Z80_FlagsB ;a5
- Z80_BUMP 4 ;a6 (holds InstrB)
- ;a7 (user sp) is never stored.
-
- ;End of 680x0 register storage
-
- Z80_LABEL Z80_IX ;IX (for word-access)
- Z80_BYTE Z80_XH ;high byte
- Z80_BYTE Z80_XL ;low byte
-
- Z80_LABEL Z80_IY ;IY (for word-access)
- Z80_BYTE Z80_YH ;high byte
- Z80_BYTE Z80_YL ;low byte
-
- Z80_LABEL Z80_alt_HL ;H'L' (for word-access)
- Z80_BYTE Z80_alt_H ;H'
- Z80_BYTE Z80_alt_L ;L'
-
- Z80_WORD Z80_PC ;PC (written/read only at exit/continue)
-
- Z80_BYTE Z80_F ;These flags are calculated upon exit.
- Z80_BYTE Z80_alt_F ; During emulation, they are unused.
-
- Z80_BYTE Z80_IFF ;IFF2 in bit 7, IFF1 in bit 6
- Z80_BYTE Z80_INTMOD ;Interruptmode (-1 to 1) = (modes 0 to 2)
- Z80_BYTE Z80_I ;Interrupt register
- Z80_BYTE Z80_R ;Refresh register
- ;word aligned here
-
- ;These could be inspected. If nonzero, a request has been
- ;received but not yet served.
- Z80_WORD Z80_INT_FF ;INTreq status
- Z80_WORD Z80_NMI_FF ;NMIreq status
- Z80_WORD Z80_RES_FF ;RESETreq status
-
- ;Private fields
- Z80_LABEL Z80_BCD_DATA ;BCD data size is fixed: 6 bytes.
- Z80_WORD Z80_BCD_OP ;BCD operation
- Z80_WORD Z80_BCD_C ;BCD carry in bit 0. Word-sized for shifts.
- Z80_BYTE Z80_BCD_A ;BCD destination
- Z80_BYTE Z80_BCD_B ;BCD source
-
- Z80_SIZE Z80_CpuStatusSize,Z80_CpuStatus
-
- ;The CPU status structure ends here.
-
- ** ------------
- ** Beginning of user environment data area. It is word-aligned,
- ** and has the size (in bytes) defined in Z80_ENV_SIZE, which could
- ** be just about anything, including zero. No entries follow it.
- ** It is intended mainly for accessing from the environment-specific
- ** instructions (see 'impldept.i' and 'generic_macs.i').
-
- Z80_ALIGN_W
-
- IFND Z80_ENV_SIZE
- Z80_ENV_SIZE EQU 0
- ENDC
-
- Z80_BYTEARR Z80_Envdata,Z80_ENV_SIZE
-
- IFNE Z80_Envdata>$7fff
- FAIL Environment data is beyond word-sized offset from TableBase.
- ENDC
-
- ** ------------
- ** The table entries end here.
-
- Z80_LABEL Z80_StructSize
-
- ** ======================================================================
- ENDC ;IFD Z80_STRUCT_I
-