This wiki is being migrated to http://www.github.com/z88dk/z88dk/wiki

User Tools

Site Tools


libnew:z80

Z80.H

Specialized functions for the z80 microprocessor.

DELAY

void z80_delay_ms(uint16_t ms)

Busy-wait exactly ms milliseconds and return. Time will be longer if interrupts occur during the wait. Accurate time delay depends on the “__clock_freq” constant being set properly in the target's clib_target_cfg.asm file.

void z80_delay_tstate(uint16_t tstates)

Busy-wait exactly tstates z80 cycles and return. Time will be longer if interrupts occur during the wait. The time delay measured in seconds will be tstates/fclock. tstates must be >= 141.

INTERRUPT SERVICE ROUTINES

Refer to the library documentation for a complete discussion of interrupts on the z80 and how to create interrupt service routines.

These functions mainly serve to help implement the z80's im2 mode. Changes to interrupts should always be done while interrupts are disabled. None of these functions enable or disable interrupts.

void im2_init(void *im2_table_address)

Sets the location of the im2 vector table to im2_table_address and places the z80 in im2 mode. Note that the least significant byte of im2_table_address is discarded so that the im2 table will always begin on an exact 256-byte page.

void *im2_install_isr(uint16_t vector, void (*isr)(void))

Install the interrupt service routine isr on the im2 vector indicated. Return the old isr formerly registered on that vector. By convention, isrs are registered on even vectors only to avoid overlap of isr addresses in the table. Zilog's peripherals are only capable of producing even interrupt vectors. vector is taken as-is, odd or even, because some systems do have devices interrupting with odd vectors.

void *im2_create_generic_isr(uint16_t num_callbacks, void *address)

Create a generic isr in RAM at address address that can have up to num_callbacks (<128) isr subroutines registered with it. The amount of memory required at address address is (18 + num_callbacks*2) bytes. Returns the next available address after the installed generic isr.

On interrupt, the generic isr will save all registers, call its list of isr subroutines in sequence, restore registers, re-enable interrupts and return.

void *im2_create_generic_isr_8080(uint16_t num_callbacks, void *address)

Create a generic isr in RAM at address address that can have up to num_callbacks (<128) isr subroutines registered with it. The amount of memory required at address address is (18 + num_callbacks*2) bytes. Returns the next available address after the installed generic isr.

On interrupt, the generic isr will only save the main register set (af,bc,de,hl), call its list of isr subroutines in sequence, restore registers, re-enable interrupts and return.

void im2_append_generic_callback(uint16_t vector, void (*callback)(void))

void im2_prepend_generic_callback(uint16_t vector, void (*callback)(void))

int im2_remove_generic_callback(uint16_t vector, void (*callback)(void))

INTERRUPT STATE

uint16_t z80_get_int_state(void)

void z80_set_int_state(uint16_t state)

PORT I/O

void *z80_indr(void *dst, uint16_t port)

void *z80_inir(void *dst, uint16_t port)

uint8_t z80_inp(uint16_t port)

void *z80_otdr(void *src, uint16_t port)

void *z80_otir(void *src, uint16_t port)

void z80_outp(uint16_t port, uint16_t data)

MEMORY

uint8_t z80_bpoke(uint8_t *address, uint8_t byte)

(macro)

uint16_t z80_wpoke(uint16_t *address, uint16_t word)

(macro)

uint32_t z80_lpoke(uint32_t *address, uint32_t dword)

(macro)

uint8_t z80_bpeek(uint8_t *address)

(macro)

uint16_t z80_wpeek(uint16_t *address)

(macro)

uint32_t z80_lpeek(uint32_t *address)

(macro)

libnew/z80.txt · Last modified: 2016/06/29 16:46 (external edit)