Xemu [doxygen]  hyppo 0a42be3a057156924bc1b626a687bd6e27349c45 @ Sat 19 Mar 02:15:11 CET 2022
Macros | Functions
z8k1.c File Reference
#include "xemu/emutools.h"
#include "z8k1.h"
Include dependency graph for z8k1.c:

Go to the source code of this file.

Macros

#define BEGIN   do{
 
#define END   }while(0);break;
 
#define OPCODE(n)   END case n: BEGIN
 
#define DO_DISASM
 
#define DO_EXEC   1
 
#define FLAG_CARRY   0x80
 
#define FLAG_ZERO   0x40
 
#define FLAG_SIGN   0x20
 
#define FLAG_PV   0x10
 
#define FLAG_DA   0x08
 
#define FLAG_HC   0x04
 
#define F_CARRY_BOOL   (!!(z8k1.flags & FLAG_CARRY))
 
#define F_ZERO_BOOL   (!!(z8k1.flags & FLAG_ZERO))
 
#define F_SIGN_BOOL   (!!(z8k1.flags & FLAG_SIGN))
 
#define F_PV_BOOL   (!!(z8k1.flags & FLAG_PV))
 
#define F_DA_BOOL   (!!(z8k1.flags & FLAG_DA))
 
#define F_HC_BOOL   (!!(z8k1.flags & FLAG_HC))
 
#define FCW_SEG   0x80
 
#define FCW_SYS   0x40
 
#define FCW_EPA   0x20
 
#define FCW_VIE   0x10
 
#define FCW_NVIE   0x08
 
#define FCW_ALL_MASK   (FCW_SEG|FCW_SYS|FCW_EPA|FCW_VIE|FCW_NVIE)
 
#define IS_SEGMENTED_MODE   (z8k1.fcw & FCW_SEG)
 
#define IS_SYSTEM_MODE   (z8k1.fcw & FCW_SYS)
 
#define IS_USER_MODE   (!(IS_SYSTEM_MODE))
 
#define DISASM(fmt, ...)   do { if (XEMU_UNLIKELY(do_disasm)) DEBUGPRINT("%02X:%04X %04X " fmt NL, z8k1.codeseg, pc_orig, opc, __VA_ARGS__); } while(0)
 
#define NOT_EMULATED_OPCODE()   FATAL("ERROR: Opcode not emulated: $%04X at $%02X:%04X", opc, z8k1.codeseg, pc_orig)
 
#define NOT_EMULATED_OPCODE_VARIANT()   FATAL("ERROR: Opcode VARIANT not emulated: $%04X at $%02X:%04X", opc, z8k1.codeseg, pc_orig)
 
#define RESERVED_OPCODE()   FATAL("ERROR: Reserved opcode: $%04X at $%02X:%04X\n", opc, z8k1.codeseg, pc_orig);
 
#define reg8names(n)   __reg8names__[(n) & 0xF]
 
#define reg16names(n)   __reg16names__[(n) & 0xF]
 
#define reg32names(n)   __reg32names__[(n) & 0xF]
 
#define reg64names(n)   __reg64names__[(n) & 0xF]
 
#define ccnames(n)   __ccnames__[(n) & 0xF]
 
#define F_ZERO_BY8(v)   (((v) & 0xFF) ? 0 : FLAG_ZERO)
 
#define F_SIGN_BY8(v)   (((v) & 0x80) ? FLAG_SIGN : 0)
 
#define F_CARRY_BY8(v)   (((v) & 0x100) ? FLAG_CARRY : 0)
 
#define F_OVERFLOW_BY8(ad1, ad2, res)   (((((ad1) & 0x80) == ((ad2) & 0x80)) && (((ad1) & 0x80) != ((res) & 0x80))) ? FLAG_PV : 0)
 
#define F_ZERO_BY16(v)   (((v) & 0xFFFF) ? 0 : FLAG_ZERO)
 
#define F_SIGN_BY16(v)   (((v) & 0x8000) ? FLAG_SIGN : 0)
 
#define F_CARRY_BY16(v)   (((v) & 0x10000) ? FLAG_CARRY : 0)
 
#define F_OVERFLOW_BY16(ad1, ad2, res)   (((((ad1) & 0x8000) == ((ad2) & 0x8000)) && (((ad1) & 0x8000) != ((res) & 0x8000))) ? FLAG_PV : 0)
 
#define F_PARITY_BY8(v)   yay
 
#define F_PARITY_BY16(v)   yay
 
#define F_HALFCARRY_BY8(ad1, ad2, res)   ((((ad1) ^ (ad2) ^ (res)) & 16) ? FLAG_HC : 0)
 
#define REG8INDEX(index)   ((((index)&7)<<1)|(((index)&8)>>3))
 
#define NIB3(n)   (((n) >> 12) & 0xF)
 
#define NIB2(n)   (((n) >> 8) & 0xF)
 
#define NIB1(n)   (((n) >> 4) & 0xF)
 
#define NIB0(n)   ((n) & 0xF)
 
#define OPCNIB3   NIB3(opc)
 
#define OPCNIB2   NIB2(opc)
 
#define OPCNIB1   NIB1(opc)
 
#define OPCNIB0   NIB0(opc)
 

Functions

void z8k1_reset (void)
 
void z8k1_init (void)
 
int z8k1_step (int cycles_limit)
 

Macro Definition Documentation

◆ BEGIN

#define BEGIN   do{

Definition at line 55 of file z8k1.c.

◆ ccnames

#define ccnames (   n)    __ccnames__[(n) & 0xF]

Definition at line 166 of file z8k1.c.

◆ DISASM

#define DISASM (   fmt,
  ... 
)    do { if (XEMU_UNLIKELY(do_disasm)) DEBUGPRINT("%02X:%04X %04X " fmt NL, z8k1.codeseg, pc_orig, opc, __VA_ARGS__); } while(0)

Definition at line 100 of file z8k1.c.

◆ DO_DISASM

#define DO_DISASM

Definition at line 60 of file z8k1.c.

◆ DO_EXEC

#define DO_EXEC   1

Definition at line 61 of file z8k1.c.

◆ END

#define END   }while(0);break;

Definition at line 56 of file z8k1.c.

◆ F_CARRY_BOOL

#define F_CARRY_BOOL   (!!(z8k1.flags & FLAG_CARRY))

Definition at line 69 of file z8k1.c.

◆ F_CARRY_BY16

#define F_CARRY_BY16 (   v)    (((v) & 0x10000) ? FLAG_CARRY : 0)

Definition at line 234 of file z8k1.c.

◆ F_CARRY_BY8

#define F_CARRY_BY8 (   v)    (((v) & 0x100) ? FLAG_CARRY : 0)

Definition at line 229 of file z8k1.c.

◆ F_DA_BOOL

#define F_DA_BOOL   (!!(z8k1.flags & FLAG_DA))

Definition at line 73 of file z8k1.c.

◆ F_HALFCARRY_BY8

#define F_HALFCARRY_BY8 (   ad1,
  ad2,
  res 
)    ((((ad1) ^ (ad2) ^ (res)) & 16) ? FLAG_HC : 0)

Definition at line 240 of file z8k1.c.

◆ F_HC_BOOL

#define F_HC_BOOL   (!!(z8k1.flags & FLAG_HC))

Definition at line 74 of file z8k1.c.

◆ F_OVERFLOW_BY16

#define F_OVERFLOW_BY16 (   ad1,
  ad2,
  res 
)    (((((ad1) & 0x8000) == ((ad2) & 0x8000)) && (((ad1) & 0x8000) != ((res) & 0x8000))) ? FLAG_PV : 0)

Definition at line 235 of file z8k1.c.

◆ F_OVERFLOW_BY8

#define F_OVERFLOW_BY8 (   ad1,
  ad2,
  res 
)    (((((ad1) & 0x80) == ((ad2) & 0x80)) && (((ad1) & 0x80) != ((res) & 0x80))) ? FLAG_PV : 0)

Definition at line 230 of file z8k1.c.

◆ F_PARITY_BY16

#define F_PARITY_BY16 (   v)    yay

Definition at line 238 of file z8k1.c.

◆ F_PARITY_BY8

#define F_PARITY_BY8 (   v)    yay

Definition at line 237 of file z8k1.c.

◆ F_PV_BOOL

#define F_PV_BOOL   (!!(z8k1.flags & FLAG_PV))

Definition at line 72 of file z8k1.c.

◆ F_SIGN_BOOL

#define F_SIGN_BOOL   (!!(z8k1.flags & FLAG_SIGN))

Definition at line 71 of file z8k1.c.

◆ F_SIGN_BY16

#define F_SIGN_BY16 (   v)    (((v) & 0x8000) ? FLAG_SIGN : 0)

Definition at line 233 of file z8k1.c.

◆ F_SIGN_BY8

#define F_SIGN_BY8 (   v)    (((v) & 0x80) ? FLAG_SIGN : 0)

Definition at line 228 of file z8k1.c.

◆ F_ZERO_BOOL

#define F_ZERO_BOOL   (!!(z8k1.flags & FLAG_ZERO))

Definition at line 70 of file z8k1.c.

◆ F_ZERO_BY16

#define F_ZERO_BY16 (   v)    (((v) & 0xFFFF) ? 0 : FLAG_ZERO)

Definition at line 232 of file z8k1.c.

◆ F_ZERO_BY8

#define F_ZERO_BY8 (   v)    (((v) & 0xFF) ? 0 : FLAG_ZERO)

Definition at line 227 of file z8k1.c.

◆ FCW_ALL_MASK

#define FCW_ALL_MASK   (FCW_SEG|FCW_SYS|FCW_EPA|FCW_VIE|FCW_NVIE)

Definition at line 88 of file z8k1.c.

◆ FCW_EPA

#define FCW_EPA   0x20

Definition at line 85 of file z8k1.c.

◆ FCW_NVIE

#define FCW_NVIE   0x08

Definition at line 87 of file z8k1.c.

◆ FCW_SEG

#define FCW_SEG   0x80

Definition at line 83 of file z8k1.c.

◆ FCW_SYS

#define FCW_SYS   0x40

Definition at line 84 of file z8k1.c.

◆ FCW_VIE

#define FCW_VIE   0x10

Definition at line 86 of file z8k1.c.

◆ FLAG_CARRY

#define FLAG_CARRY   0x80

Definition at line 63 of file z8k1.c.

◆ FLAG_DA

#define FLAG_DA   0x08

Definition at line 67 of file z8k1.c.

◆ FLAG_HC

#define FLAG_HC   0x04

Definition at line 68 of file z8k1.c.

◆ FLAG_PV

#define FLAG_PV   0x10

Definition at line 66 of file z8k1.c.

◆ FLAG_SIGN

#define FLAG_SIGN   0x20

Definition at line 65 of file z8k1.c.

◆ FLAG_ZERO

#define FLAG_ZERO   0x40

Definition at line 64 of file z8k1.c.

◆ IS_SEGMENTED_MODE

#define IS_SEGMENTED_MODE   (z8k1.fcw & FCW_SEG)

Definition at line 92 of file z8k1.c.

◆ IS_SYSTEM_MODE

#define IS_SYSTEM_MODE   (z8k1.fcw & FCW_SYS)

Definition at line 93 of file z8k1.c.

◆ IS_USER_MODE

#define IS_USER_MODE   (!(IS_SYSTEM_MODE))

Definition at line 94 of file z8k1.c.

◆ NIB0

#define NIB0 (   n)    ((n) & 0xF)

Definition at line 259 of file z8k1.c.

◆ NIB1

#define NIB1 (   n)    (((n) >> 4) & 0xF)

Definition at line 258 of file z8k1.c.

◆ NIB2

#define NIB2 (   n)    (((n) >> 8) & 0xF)

Definition at line 257 of file z8k1.c.

◆ NIB3

#define NIB3 (   n)    (((n) >> 12) & 0xF)

Definition at line 256 of file z8k1.c.

◆ NOT_EMULATED_OPCODE

#define NOT_EMULATED_OPCODE ( )    FATAL("ERROR: Opcode not emulated: $%04X at $%02X:%04X", opc, z8k1.codeseg, pc_orig)

Definition at line 107 of file z8k1.c.

◆ NOT_EMULATED_OPCODE_VARIANT

#define NOT_EMULATED_OPCODE_VARIANT ( )    FATAL("ERROR: Opcode VARIANT not emulated: $%04X at $%02X:%04X", opc, z8k1.codeseg, pc_orig)

Definition at line 108 of file z8k1.c.

◆ OPCNIB0

#define OPCNIB0   NIB0(opc)

Definition at line 264 of file z8k1.c.

◆ OPCNIB1

#define OPCNIB1   NIB1(opc)

Definition at line 263 of file z8k1.c.

◆ OPCNIB2

#define OPCNIB2   NIB2(opc)

Definition at line 262 of file z8k1.c.

◆ OPCNIB3

#define OPCNIB3   NIB3(opc)

Definition at line 261 of file z8k1.c.

◆ OPCODE

#define OPCODE (   n)    END case n: BEGIN

Definition at line 57 of file z8k1.c.

◆ reg16names

#define reg16names (   n)    __reg16names__[(n) & 0xF]

Definition at line 151 of file z8k1.c.

◆ reg32names

#define reg32names (   n)    __reg32names__[(n) & 0xF]

Definition at line 156 of file z8k1.c.

◆ reg64names

#define reg64names (   n)    __reg64names__[(n) & 0xF]

Definition at line 161 of file z8k1.c.

◆ REG8INDEX

#define REG8INDEX (   index)    ((((index)&7)<<1)|(((index)&8)>>3))

Definition at line 251 of file z8k1.c.

◆ reg8names

#define reg8names (   n)    __reg8names__[(n) & 0xF]

Definition at line 146 of file z8k1.c.

◆ RESERVED_OPCODE

#define RESERVED_OPCODE ( )    FATAL("ERROR: Reserved opcode: $%04X at $%02X:%04X\n", opc, z8k1.codeseg, pc_orig);

Definition at line 109 of file z8k1.c.

Function Documentation

◆ z8k1_init()

void z8k1_init ( void  )

Definition at line 516 of file z8k1.c.

◆ z8k1_reset()

void z8k1_reset ( void  )

Definition at line 487 of file z8k1.c.

◆ z8k1_step()

int z8k1_step ( int  cycles_limit)

Definition at line 520 of file z8k1.c.

Variable Documentation

◆ codeseg

Uint8 codeseg

Definition at line 128 of file z8k1.c.

◆ fcw

Uint8 fcw

Definition at line 126 of file z8k1.c.

◆ flags

Uint8 flags

Definition at line 126 of file z8k1.c.

◆ get_address_mode

int get_address_mode

Definition at line 137 of file z8k1.c.

◆ pc

Uint16 pc

Definition at line 127 of file z8k1.c.

◆ psaofs

Uint16 psaofs

Definition at line 133 of file z8k1.c.

◆ psaseg

Uint8 psaseg

Definition at line 132 of file z8k1.c.

◆ refresh

Uint16 refresh

Definition at line 131 of file z8k1.c.

◆ regs

Uint16 regs[16]

Definition at line 125 of file z8k1.c.

◆ stackptrsys

Uint16 stackptrsys

Definition at line 129 of file z8k1.c.

◆ stackptrusr

Uint16 stackptrusr

Definition at line 129 of file z8k1.c.

◆ stacksegsys

Uint8 stacksegsys

Definition at line 130 of file z8k1.c.

◆ stacksegusr

Uint8 stacksegusr

Definition at line 130 of file z8k1.c.

◆ use_ofs

Uint16 use_ofs

Definition at line 135 of file z8k1.c.

◆ use_seg

Uint8 use_seg

Definition at line 136 of file z8k1.c.