home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 25
/
amigaformatcd25.iso
/
-in_the_mag-
/
emulation
/
z80
/
c_stubs.a
next >
Wrap
Text File
|
1998-02-13
|
8KB
|
376 lines
** This file contains the C interface stubs.
** It can be compiled separately and needs no include files.
** =======================================================================
** It is assumed here that the stack looks like this upon entry:
** <return_addr> [,<other_stuff>] [,<parameter_1> [,...] ]
** SP SP+P1OFFS
P1OFFS EQU 4 ;stack offset of parameter 1 at entry
** Sizes of stacked parameters and macros to transfer them to registers:
** (If you change a size, you might need to change the move instruction
** in the macro as well.)
ARG_START MACRO ;initial_offset
ARG_OFFS SET \1+P1OFFS
ENDM
LONGSIZ EQU 4
GETLONG MACRO ;register
move.l ARG_OFFS(a7),\1
ARG_OFFS SET ARG_OFFS+LONGSIZ
ENDM
INTSIZ EQU 4 ;supposed sizeof(int)
GETINT MACRO ;src,dest
move.l ARG_OFFS(a7),\1
ARG_OFFS SET ARG_OFFS+INTSIZ
ENDM
WORDSIZ EQU INTSIZ ;probably promoted to int
GETWORD MACRO ;src,dest
move.l ARG_OFFS(a7),\1
ARG_OFFS SET ARG_OFFS+WORDSIZ
ENDM
BYTESIZ EQU INTSIZ ;probably promoted to int
GETBYTE MACRO ;src,dest
move.l ARG_OFFS(a7),\1
ARG_OFFS SET ARG_OFFS+BYTESIZ
ENDM
PTRSIZ EQU 4 ;size of a pointer
GETPTR MACRO ;src,dest
move.l ARG_OFFS(a7),\1
ARG_OFFS SET ARG_OFFS+PTRSIZ
ENDM
** -----------------------------------------------------------------------
** All Z80_ functions that return a value pass it in d0. If this is not
** what your compiler wants, then edit the stubs. I see no easy way
** to fix that with macros and conditional assembly.
** -----------------------------------------------------------------------
** Z80_Init takes one parameter:
** a0 a pointer to the control structure.
** It returns an error flag in d0.
** C Prototype:
** int Z80_Init(struct Z80_Control *)
XREF Z80_Init
XDEF _Z80_Init
_Z80_Init movem.l a0,-(a7)
ARG_START 1*4
GETPTR a0
jsr Z80_Init
movem.l (a7)+,a0
rts
** ------------
** Z80_Coldstart takes one parameter:
** a0 a pointer to the control structure.
** It returns an error flag in d0.
** C Prototype:
** int Z80_Coldstart(struct Z80_Control *)
XREF Z80_Coldstart
XDEF _Z80_Coldstart
_Z80_Coldstart movem.l a0,-(a7)
ARG_START 1*4
GETPTR a0
jsr Z80_Coldstart
movem.l (a7)+,a0
rts
** ------------
** Z80_Continue takes one parameter:
** a0 a pointer to the control structure.
** It returns an error flag in d0.
** C Prototype:
** int Z80_Continue(struct Z80_Control *)
XREF Z80_Continue
XDEF _Z80_Continue
_Z80_Continue movem.l a0,-(a7)
ARG_START 1*4
GETPTR a0
jsr Z80_Continue
movem.l (a7)+,a0
rts
** ------------
** Z80_NewSettings takes one parameter:
** a0 a pointer to the control structure.
** It returns an error flag in d0.
** C Prototype:
** int Z80_NewSettings(struct Z80_Control *)
XREF Z80_NewSettings
XDEF _Z80_NewSettings
_Z80_NewSettings
movem.l a0,-(a7)
ARG_START 1*4
GETPTR a0
jsr Z80_NewSettings
movem.l (a7)+,a0
rts
** ------------
** Z80_SetByte takes three parameters:
** a0 a pointer to the control structure,
** d0 a word-sized Z80 address,
** d1 a byte value.
** It returns nothing.
** C Prototype:
** void Z80_SetByte(struct Z80_Control *, UWORD addr, BYTE val)
XREF Z80_SetByte
XDEF _Z80_SetByte
_Z80_SetByte movem.l a0/d1,-(a7)
ARG_START 2*4
GETPTR a0
GETWORD d0
GETBYTE d1
jsr Z80_SetByte
movem.l (a7)+,a0/d1
rts
** ------------
** Z80_SetWordLH takes three parameters:
** a0 a pointer to the control structure,
** d0 a word-sized Z80 address,
** d1 a word value.
** It returns nothing.
** C Prototype:
** void Z80_SetWordLH(struct Z80_Control *, UWORD addr, UWORD val)
XREF Z80_SetWordLH
XDEF _Z80_SetWordLH
_Z80_SetWordLH movem.l a0/d1,-(a7)
ARG_START 2*4
GETPTR a0
GETWORD d0
GETWORD d1
jsr Z80_SetWordLH
movem.l (a7)+,a0/d1
rts
** ------------
** Z80_GetByte takes two parameters:
** a0 a pointer to the control structure,
** d0 a word-sized Z80 address.
** It returns a byte value in d0.
** C Prototype:
** BYTE Z80_GetByte(struct Z80_Control *, UWORD addr)
XREF Z80_GetByte
XDEF _Z80_GetByte
_Z80_GetByte movem.l a0,-(a7)
ARG_START 1*4
GETPTR a0
GETWORD d0
jsr Z80_GetByte
movem.l (a7)+,a0
rts
** ------------
** Z80_GetWordLH takes two parameters:
** a0 a pointer to the control structure,
** d0 a word-sized Z80 address.
** It returns a word value in d0.
** C Prototype:
** WORD Z80_GetWordLH(struct Z80_Control *, UWORD addr)
XREF Z80_GetWordLH
XDEF _Z80_GetWordLH
_Z80_GetWordLH movem.l a0,-(a7)
ARG_START 1*4
GETPTR a0
GETWORD d0
jsr Z80_GetWordLH
movem.l (a7)+,a0
rts
** ------------
** Z80_SetBlock takes four parameters:
** a0 a pointer to the control structure,
** d0 a word-sized Z80 address,
** d1 a block size as an unsigned longword,
** d2 a byte value.
** It returns nothing.
** C Prototype:
** void Z80_SetBlock(struct Z80_Control *,
** UWORD start_addr, ULONG size, BYTE val)
XREF Z80_SetBlock
XDEF _Z80_SetBlock
_Z80_SetBlock movem.l a0/d1/d2,-(a7)
ARG_START 3*4
GETPTR a0
GETWORD d0
GETLONG d1
GETBYTE d2
jsr Z80_SetBlock
movem.l (a7)+,a0/d1/d2
rts
** ------------
** Z80_ReadBlock takes four parameters:
** a0 a pointer to the control structure,
** a1 a pointer to the buffer,
** d0 a word-sized Z80 address,
** d1 a block size as an unsigned longword.
** It returns nothing.
** C Prototype:
** void Z80_ReadBlock(struct Z80_Control *,
** void *buffer, UWORD start_addr, ULONG size)
XREF Z80_ReadBlock
XDEF _Z80_ReadBlock
_Z80_ReadBlock movem.l a0/a1/d1,-(a7)
ARG_START 3*4
GETPTR a0
GETPTR a1
GETWORD d0
GETLONG d1
jsr Z80_ReadBlock
movem.l (a7)+,a0/a1/d1
rts
** ------------
** Z80_WriteBlock takes three parameters:
** a0 a pointer to the control structure,
** a1 a pointer to the buffer,
** d0 a word-sized Z80 address,
** d1 a block size as an unsigned longword.
** It returns nothing.
** C Prototype:
** void Z80_WriteBlock(struct Z80_Control *,
** void *buffer, UWORD start_addr, ULONG size)
XREF Z80_WriteBlock
XDEF _Z80_WriteBlock
_Z80_WriteBlock movem.l a0/a1/d1,-(a7)
ARG_START 3*4
GETPTR a0
GETPTR a1
GETWORD d0
GETLONG d1
jsr Z80_WriteBlock
movem.l (a7)+,a0/a1/d1
rts
** ------------
** Z80_SetMemFlag takes four parameters:
** a0 a pointer to the control structure,
** d0 a word-sized Z80 address,
** d1 a block size as an unsigned longword,
** d2 a byte-sized flag value.
** It returns nothing.
** C Prototype:
** void Z80_SetMemFlag(struct Z80_Control *,
** UWORD start_addr, ULONG size, BYTE flag)
XREF Z80_SetMemFlag
XDEF _Z80_SetMemFlag
_Z80_SetMemFlag movem.l a0/d1/d2,-(a7)
ARG_START 3*4
GETPTR a0
GETWORD d0
GETLONG d1
GETBYTE d2
jsr Z80_SetMemFlag
movem.l (a7)+,a0/d1/d2
rts
** ------------
** Z80_GetMemFlag takes two parameters:
** a0 a pointer to the control structure,
** d0 a word-sized Z80 address.
** It returns a signed flag value in d0.
** C Prototype:
** void Z80_GetMemFlag(struct Z80_Control *, UWORD addr)
XREF Z80_GetMemFlag
XDEF _Z80_GetMemFlag
_Z80_GetMemFlag movem.l a0,-(a7)
ARG_START 1*4
GETPTR a0
GETWORD d0
jsr Z80_GetMemFlag
movem.l (a7)+,a0
rts
** ------------
** The requests take one parameter:
** a0 a pointer to the control structure.
** They return nothing.
** C Prototype:
** void Z80_XXXreq(struct Z80_Control *)
XREF Z80_INTreq
XDEF _Z80_INTreq
_Z80_INTreq movem.l a0,-(a7)
ARG_START 4
GETPTR a0
jsr Z80_INTreq
movem.l (a7)+,a0
rts
** ------------
XREF Z80_NMIreq
XDEF _Z80_NMIreq
_Z80_NMIreq movem.l a0,-(a7)
ARG_START 4
GETPTR a0
jsr Z80_NMIreq
movem.l (a7)+,a0
rts
** ------------
XREF Z80_RESETreq
XDEF _Z80_RESETreq
_Z80_RESETreq movem.l a0,-(a7)
ARG_START 4
GETPTR a0
jsr Z80_RESETreq
movem.l (a7)+,a0
rts
** ------------
XREF Z80_EXITreq
XDEF _Z80_EXITreq
_Z80_EXITreq movem.l a0,-(a7)
ARG_START 4
GETPTR a0
jsr Z80_EXITreq
movem.l (a7)+,a0
rts
** ======================================================================