8080-Emulator  0.1
An Intel 8080 emulator for Space Invaders
Classes | Macros | Typedefs | Functions | Variables
opcodes_8080.h File Reference

C wrappers for major opcodes. Broken from cpu_8080 to better manage codebase. More...

#include <inttypes.h>
#include "cpu_8080.h"
#include "memory_8080.h"
Include dependency graph for opcodes_8080.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  instt_8080_op
 a struct to define the meta data for intel 8080 opcode. Contains the binding to the functor and the cycles it takes to complete. More...
 

Macros

#define ILLEGAL_OP   DEBUG_PRINT("%s\n", "Illegal OP!");
 

Typedefs

typedef int(* OP_WRAP) (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 wrapping for all the CPU opcodes for emulation and easy calling.
 

Functions

uint8_t * ref_byte_reg (cpu_state *cpu, uint8_t reg_identifier)
 The bit pattern designating one of the registers A,B,C,D,E,H,L (DDD=destination, SSS=source) 111 -> ACC, 000—101 -> B,C,D,E,H,L. This function returns a reference to the bytes which helps simulate the register. More...
 
uint16_t * ref_short_reg (cpu_state *cpu, uint8_t reg_identifier)
 The bit pattern designating one of the register pairs B,D,H,SP 00—11 -> B,D,H,SP. This function returns a reference to the short which helps simulate the register. More...
 
uint8_t condition_check (cpu_state *cpu, condition_flags condition_identifier)
 perform condition check on the cpu register state More...
 
void set_flags (cpu_state *cpu, uint32_t final_state, uint8_t flags)
 Set the flags PSW status. More...
 
void aux_flag_set_add (cpu_state *cpu, uint32_t base_val, uint32_t diff)
 sets the aux flag for all operations. Must convert all ops to a addition operation (compressed). Does base_val + diff to recalc the result. So for -ve bass -ve num's 2 complement. More...
 
uint8_t compress_PSW (program_status_word psw)
 Compress program_status_word into a uint8_t as per flag_bits. More...
 
program_status_word decompress_PSW (uint8_t status)
 Inflate the uint8_t into a program_status_word by using flag_bits as the mapping. More...
 
int UNDEFINED_OP_WRAP (UNUSED cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 Undefined OPCODE Functor. More...
 
int NOP_WRAP (UNUSED cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 Wrapper over No Op. More...
 
int LXI_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 Load register pair immediate. More...
 
int JMP_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 (PC) (byte 3) (byte 2) – Control is transferred to the instruction whose address is specified in byte 3 and byte 2 of the current instruction. More...
 
int MVI_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 Move Immediate. More...
 
int CALL_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 The current PC (pointer to next instruction) is move to the top of SP and the SP is decremented to make space for the pointer. Next, the new start of function address is moved to PC. More...
 
int LDAX_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 Load accumulator indirect: The content of the memory location, whose address is in the register pair rp, is moved to register A. More...
 
int MOV_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 All different kinds of move operations: More...
 
int HLT_WRAP (UNUSED cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 The processor is stopped. The registers and flags are unaffected. More...
 
int INX_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 (Increment register pair) (rh) (rl) <– (rh) (rl) + 1 The content of the register pair rp is incremented by one. More...
 
int DCR_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 (Decrement Register) The content of register r is decremented by one. More...
 
int JCon_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 Conditional JMP statements. More...
 
int RET_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 (Return) (PCl) ((SP)); (PCH) ((SP) + 1); (SP) (SP) + 2; The content of the memory location whose address is specified in register SP is moved to the low-order eight bits of register PC. More...
 
int RCon_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 Conditional version of RET_WRAP More...
 
int CMP_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 Comparison operation. More...
 
int CPI_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 Compare A with(-) (byte 2) More...
 
int PUSH_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 The content of content register, is moved into the memory whose address is specified by the SP. Note: for RP-11b it transforms into PUSH PSW. More...
 
int POP_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 The content of the memory location, whose address is specified by the SP is pused into content Reg. Note: for RP-11b it transforms into POP PSW. More...
 
int DAD_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 (Add register pair to Hand L) (H) (L) ..- (H) (L) + (rh) (rl) The content of the register pair rp is added to the content of the register pair Hand L. The result is placed in the register pair Hand L. More...
 
int XCHG_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 Xchanges HL <--> DE. More...
 
int OUT_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 Copies a byte of data from ACC to PORT. More...
 
int IN_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 Copies a byte of data from the PORT defined by byte(2) to ACC. More...
 
int STAX_WRAP (cpu_state *cpu, UNUSED UNUSED uint16_t base_PC, uint8_t op_code)
 Store *(RP) <- A. More...
 
int ANA_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 (A) = (A) /\ (r) The content of register r is logically anded with the content of the accumulator. The result is placed in the accumulator. The CY flag is cleared More...
 
int LHLD_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (L) <– ((byte 3)(byte 2)) (H) <– ((byte 3) (byte 2) + 1) More...
 
int ANI_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (AND immediate) (A) = (A) & (byte 2) More...
 
int STA_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 *((byte 3)(byte 2)) = ACC More...
 
int INR_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 (increment Reg) (r) <- (r) + 1 More...
 
int RRC_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (Rotate Right) (An) <- (An-1); (A7) <- A0 (Cy) <- (A0) More...
 
int LDA_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (Load Accumulator direct) (A) = *((byte 3)(byte 2)) More...
 
int XRA_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (Exclusive OR Register) (A) = (A) ^ (r) More...
 
int EI_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 Enable Interrupts. More...
 
int DI_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 Disable Interrupts. More...
 
int SHLD_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (L) --> ((byte 3)(byte 2)) (H) --> ((byte 3) (byte 2) + 1) More...
 
int DCX_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (reg pair) = (reg pair) - 1 More...
 
int RLC_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (Rotate left) (An+l) <– (An) ; (AO) <– (A7); (CY) <– (A7) More...
 
int RAL_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (Rotate left through carry) (An+1) <– (An) ; (CY) <– (A7) ; (AO) <– (CY) More...
 
int RAR_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (Rotate right through carry) (An) <– (An+l) ; (CY) <– (AO) ; (A7) <– (CY) More...
 
int CCon_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 Ccondition addr (Condition call) If (CCC), ((SP) -1) (PCH) ((SP) - 2) (PCl) (SP) (SP) - 2 (PC) (byte 3) (byte 2) More...
 
int SBI_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (Subtract immediate with borrow) (A) <– (A) - (byte 2) - (CY) The contents of the second byte of the instruction and the contents of the CY flag are both subtracted from the accumulator. The result is placed in the accumulator More...
 
int ADD_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 (Add Register) (A) <– (A) + (r) The content of register r is added to the content of the accumulator. The result is placed in the accumulator. More...
 
int ADI_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (Add Immediate) (A) <– (A) + (byte 2) The content of the second byte of the instruction is added to the content of the accumulator. The result is placed in the accumulator More...
 
int ADC_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 (Add Register with carry) (A) <– (A) + (r) + (CY) The content of register r and the content of the carry bit are added to the content of the accumulator. The result is placed in the accumulator More...
 
int ACI_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (Add immediate with carry) (A) <– (A) + (byte 2) + (CY) The content of the second byte of the instruction and the content of the CY flag are added to the contents of the accumulator. The result is placed in the accumulator More...
 
int SUB_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 (Subtract Register) (A) <– (A) - (r) The content of register r is subtracted from the content of the accumulator. The result is placed in the accumulator. More...
 
int SUI_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (Subtract immediate) (A) <– (A) - (byte 2) The content of the second byte of the instruction is subtracted from the content of the accumulator. The result is placed in the accumulator More...
 
int SBB_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 (Subtract Register with borrow) (A) <– (A) - (r) - (CY) The content of register r and the content of the CY flag are both subtracted from the accumulator. The result is placed in the accumulator. More...
 
int ORA_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 (OR Register) (A) <– (A) | (r) The content of register r is inclusive-OR'd with the content of the accumulator. The result is placed in the accumulator. The CY and AC flags are cleared. More...
 
int XTHL_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (Exchange stack top with Hand L) (L) <--> ((SP)) ; (H) <--> ((SP) + 1) ; More...
 
int PCHL_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (Jump Hand l indirect - move Hand L to PC) (PCH) <– (H) (PCl) <– (l) The content of register H is moved to the high-order eight bits of register PC. The content of register l is moved to the low-order eight bits of register PC. More...
 
int ORI_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (OR Immediate) (A) <– (A) V (byte 2) The content of the second byte of the instruction is inclusive-OR'd with the content of the accumulator. The result is placed in the accumulator. The CY and AC flags are cleared. More...
 
int XRI_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (Exclusive OR Immediate) (A) <– (A) ^ (byte 2) The content of the second byte of the instruction is exclusive-O R'd with the content of the accumu lator. The result is placed in the accumulator. The CY and AC flags are cleared. More...
 
int CMA_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 Complement accumulator (A) <- (~A) More...
 
int CMC_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 Complement carry (CY) <- (!CY) More...
 
int STC_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 Set Carry (CY) <- (1) More...
 
int DAA_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (Decimal Adjust Accumulator) More...
 
int RST_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, uint8_t op_code)
 (Restart) ((SP) - 1) <– (PCH); ((SP) - 2) <– (PCl); (SP) <– (SP) - 2; (PC) <– 8* (NNN); More...
 
int SPHL_WRAP (cpu_state *cpu, UNUSED uint16_t base_PC, UNUSED uint8_t op_code)
 (Exchange stack top with H and L) (L) <--> ((SP)); (H) <--> ((SP) + 1); The content of the L register is exchanged with the content of the memory location whose address is specified by the content of register SP. The content of the H register is exchanged with the content of the memory location whose address is one more than the content of register SP. More...
 

Variables

instt_8080_op opcode_lookup [0x100]
 A jump table indexed by an Intel 8080 instruction opcode, containing: More...
 

Detailed Description

C wrappers for major opcodes. Broken from cpu_8080 to better manage codebase.

Author
Pranay Garg (prana.nosp@m.yga@.nosp@m.andre.nosp@m.w.cm.nosp@m.u.edu)
Version
0.1
Date
2020-12-24

Macro Definition Documentation

◆ ILLEGAL_OP

#define ILLEGAL_OP   DEBUG_PRINT("%s\n", "Illegal OP!");

Macro to print about Illegal Operation

Function Documentation

◆ ACI_WRAP()

int ACI_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(Add immediate with carry) (A) <– (A) + (byte 2) + (CY) The content of the second byte of the instruction and the content of the CY flag are added to the contents of the accumulator. The result is placed in the accumulator

Parameters
cpu
base_PC
op_code
Returns
int

◆ ADC_WRAP()

int ADC_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

(Add Register with carry) (A) <– (A) + (r) + (CY) The content of register r and the content of the carry bit are added to the content of the accumulator. The result is placed in the accumulator

Parameters
cpu
base_PC
op_code
Returns
int

◆ ADD_WRAP()

int ADD_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

(Add Register) (A) <– (A) + (r) The content of register r is added to the content of the accumulator. The result is placed in the accumulator.

Parameters
cpu
base_PC
op_code
Returns
int

◆ ADI_WRAP()

int ADI_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(Add Immediate) (A) <– (A) + (byte 2) The content of the second byte of the instruction is added to the content of the accumulator. The result is placed in the accumulator

Parameters
cpu
base_PC
op_code
Returns
int

◆ ANA_WRAP()

int ANA_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

(A) = (A) /\ (r) The content of register r is logically anded with the content of the accumulator. The result is placed in the accumulator. The CY flag is cleared

Parameters
cpu
base_PC
op_code
Returns
int

◆ ANI_WRAP()

int ANI_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(AND immediate) (A) = (A) & (byte 2)

Parameters
cpu
base_PC
op_code
Returns
int

◆ aux_flag_set_add()

void aux_flag_set_add ( cpu_state cpu,
uint32_t  base_val,
uint32_t  diff 
)

sets the aux flag for all operations. Must convert all ops to a addition operation (compressed). Does base_val + diff to recalc the result. So for -ve bass -ve num's 2 complement.

Todo:
not sure if this is correct.
Parameters
cpu
base_valthe initial value
diffthe value to be added to the base

◆ CALL_WRAP()

int CALL_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

The current PC (pointer to next instruction) is move to the top of SP and the SP is decremented to make space for the pointer. Next, the new start of function address is moved to PC.

Parameters
cpu
base_PC
op_code
Returns
int

◆ CCon_WRAP()

int CCon_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

Ccondition addr (Condition call) If (CCC), ((SP) -1) (PCH) ((SP) - 2) (PCl) (SP) (SP) - 2 (PC) (byte 3) (byte 2)

Parameters
cpu
base_PC
op_code
Returns
int

◆ CMA_WRAP()

int CMA_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

Complement accumulator (A) <- (~A)

Parameters
cpu
base_PC
op_code
Returns
int

◆ CMC_WRAP()

int CMC_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

Complement carry (CY) <- (!CY)

Parameters
cpu
base_PC
op_code
Returns
int

◆ CMP_WRAP()

int CMP_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

Comparison operation.

Parameters
cpu
base_PC
op_code
Returns
int

◆ compress_PSW()

uint8_t compress_PSW ( program_status_word  psw)

Compress program_status_word into a uint8_t as per flag_bits.

Parameters
psw
Returns
uint8_t

◆ condition_check()

uint8_t condition_check ( cpu_state cpu,
condition_flags  condition_identifier 
)

perform condition check on the cpu register state

Parameters
cpu
condition_identifierdifferent condition checks for JMP, conditional OPS
Returns
uint8_t 1 if the condition is true, 0 if false

◆ CPI_WRAP()

int CPI_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

Compare A with(-) (byte 2)

Parameters
cpu
base_PC
op_code
Returns
int

◆ DAA_WRAP()

int DAA_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(Decimal Adjust Accumulator)

Parameters
cpu
base_PC
op_code
Returns
int

◆ DAD_WRAP()

int DAD_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

(Add register pair to Hand L) (H) (L) ..- (H) (L) + (rh) (rl) The content of the register pair rp is added to the content of the register pair Hand L. The result is placed in the register pair Hand L.

Note
: Only the CY flag is affected.
Parameters
cpu
base_PC
op_code
Returns
int

◆ DCR_WRAP()

int DCR_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

(Decrement Register) The content of register r is decremented by one.

Note
All condition flag except CY are affected.
Parameters
cpu
base_PC
op_code
Returns
int

◆ DCX_WRAP()

int DCX_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(reg pair) = (reg pair) - 1

Parameters
cpu
base_PC
op_code
Returns
int

◆ decompress_PSW()

program_status_word decompress_PSW ( uint8_t  status)

Inflate the uint8_t into a program_status_word by using flag_bits as the mapping.

Parameters
status
Returns
program_status_word

◆ DI_WRAP()

int DI_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

Disable Interrupts.

Parameters
cpu
base_PC
op_code
Returns
int

◆ EI_WRAP()

int EI_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

Enable Interrupts.

Parameters
cpu
base_PC
op_code
Returns
int

◆ HLT_WRAP()

int HLT_WRAP ( UNUSED cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

The processor is stopped. The registers and flags are unaffected.

Parameters
cpu
base_PC
op_code
Returns
int

◆ IN_WRAP()

int IN_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

Copies a byte of data from the PORT defined by byte(2) to ACC.

Parameters
cpu
base_PC
op_code
Returns
int

◆ INR_WRAP()

int INR_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

(increment Reg) (r) <- (r) + 1

Parameters
cpu
base_PC
op_code
Returns
int

◆ INX_WRAP()

int INX_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

(Increment register pair) (rh) (rl) <– (rh) (rl) + 1 The content of the register pair rp is incremented by one.

Note
No condition flags are affected.
Parameters
cpu
base_PC
op_code
Returns
int

◆ JCon_WRAP()

int JCon_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

Conditional JMP statements.

Parameters
cpu
base_PC
op_code
Returns
int

◆ JMP_WRAP()

int JMP_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

(PC) (byte 3) (byte 2) – Control is transferred to the instruction whose address is specified in byte 3 and byte 2 of the current instruction.

Parameters
cpu
base_PC
op_code
Returns
int

◆ LDA_WRAP()

int LDA_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(Load Accumulator direct) (A) = *((byte 3)(byte 2))

Parameters
cpu
base_PC
op_code
Returns
int

◆ LDAX_WRAP()

int LDAX_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

Load accumulator indirect: The content of the memory location, whose address is in the register pair rp, is moved to register A.

Parameters
cpu
base_PC
op_code
Returns
int
Note
only register pairs rp=B (registers B and C·) or rp=D (registers D and E) may be specified

◆ LHLD_WRAP()

int LHLD_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(L) <– ((byte 3)(byte 2)) (H) <– ((byte 3) (byte 2) + 1)

Parameters
cpu
base_PC
op_code
Returns
int

◆ LXI_WRAP()

int LXI_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

Load register pair immediate.

Parameters
cpu
base_PC
op_code
Returns
int

◆ MOV_WRAP()

int MOV_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

All different kinds of move operations:

  • Move Register
  • Move from Memory (*HL -> Reg)
  • Move to memory (Reg -> *HL) The immediate versions are in the MVI_WRAP function
Parameters
cpu
base_PC
op_code
Returns
int

◆ MVI_WRAP()

int MVI_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

Move Immediate.

Parameters
cpu
base_PC
op_code
Returns
int

◆ NOP_WRAP()

int NOP_WRAP ( UNUSED cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

Wrapper over No Op.

Parameters
cpuCpu state
base_PCpointer to the location of the instruction start
op_codeof the instruction under execution
Returns
int 1 of success, 0 if fail

◆ ORA_WRAP()

int ORA_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

(OR Register) (A) <– (A) | (r) The content of register r is inclusive-OR'd with the content of the accumulator. The result is placed in the accumulator. The CY and AC flags are cleared.

Parameters
cpu
base_PC
op_code
Returns
int

◆ ORI_WRAP()

int ORI_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(OR Immediate) (A) <– (A) V (byte 2) The content of the second byte of the instruction is inclusive-OR'd with the content of the accumulator. The result is placed in the accumulator. The CY and AC flags are cleared.

Parameters
cpu
base_PC
op_code
Returns
int

◆ OUT_WRAP()

int OUT_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

Copies a byte of data from ACC to PORT.

Parameters
cpu
base_PC
op_code
Returns
int

◆ PCHL_WRAP()

int PCHL_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(Jump Hand l indirect - move Hand L to PC) (PCH) <– (H) (PCl) <– (l) The content of register H is moved to the high-order eight bits of register PC. The content of register l is moved to the low-order eight bits of register PC.

Parameters
cpu
base_PC
op_code
Returns
int

◆ POP_WRAP()

int POP_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

The content of the memory location, whose address is specified by the SP is pused into content Reg. Note: for RP-11b it transforms into POP PSW.

Parameters
cpu
base_PC
op_code
Returns
int

◆ PUSH_WRAP()

int PUSH_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

The content of content register, is moved into the memory whose address is specified by the SP. Note: for RP-11b it transforms into PUSH PSW.

Parameters
cpu
base_PC
op_code
Returns
int

◆ RAL_WRAP()

int RAL_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(Rotate left through carry) (An+1) <– (An) ; (CY) <– (A7) ; (AO) <– (CY)

Parameters
cpu
base_PC
op_code
Returns
int

◆ RAR_WRAP()

int RAR_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(Rotate right through carry) (An) <– (An+l) ; (CY) <– (AO) ; (A7) <– (CY)

Parameters
cpu
base_PC
op_code
Returns
int

◆ RCon_WRAP()

int RCon_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

Conditional version of RET_WRAP

Parameters
cpu
base_PC
op_code
Returns
int

◆ ref_byte_reg()

uint8_t* ref_byte_reg ( cpu_state cpu,
uint8_t  reg_identifier 
)

The bit pattern designating one of the registers A,B,C,D,E,H,L (DDD=destination, SSS=source) 111 -> ACC, 000—101 -> B,C,D,E,H,L. This function returns a reference to the bytes which helps simulate the register.

Parameters
cpu
reg_identifier
Returns
uint8_t* (uint8_t*)-1 if illegal or address otherwise

◆ ref_short_reg()

uint16_t* ref_short_reg ( cpu_state cpu,
uint8_t  reg_identifier 
)

The bit pattern designating one of the register pairs B,D,H,SP 00—11 -> B,D,H,SP. This function returns a reference to the short which helps simulate the register.

Parameters
cpu
reg_identifier
Returns
uint16_t* (uint16_t*)-1 if illegal or address otherwise

◆ RET_WRAP()

int RET_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

(Return) (PCl) ((SP)); (PCH) ((SP) + 1); (SP) (SP) + 2; The content of the memory location whose address is specified in register SP is moved to the low-order eight bits of register PC.

Parameters
cpu
base_PC
op_code
Returns
int

◆ RLC_WRAP()

int RLC_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(Rotate left) (An+l) <– (An) ; (AO) <– (A7); (CY) <– (A7)

Parameters
cpu
base_PC
op_code
Returns
int

◆ RRC_WRAP()

int RRC_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(Rotate Right) (An) <- (An-1); (A7) <- A0 (Cy) <- (A0)

Parameters
cpu
base_PC
op_code
Returns
int

◆ RST_WRAP()

int RST_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

(Restart) ((SP) - 1) <– (PCH); ((SP) - 2) <– (PCl); (SP) <– (SP) - 2; (PC) <– 8* (NNN);

Parameters
cpu
base_PC
op_code
Returns
int

◆ SBB_WRAP()

int SBB_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

(Subtract Register with borrow) (A) <– (A) - (r) - (CY) The content of register r and the content of the CY flag are both subtracted from the accumulator. The result is placed in the accumulator.

Parameters
cpu
base_PC
op_code
Returns
int

◆ SBI_WRAP()

int SBI_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(Subtract immediate with borrow) (A) <– (A) - (byte 2) - (CY) The contents of the second byte of the instruction and the contents of the CY flag are both subtracted from the accumulator. The result is placed in the accumulator

Parameters
cpu
base_PC
op_code
Returns
int

◆ set_flags()

void set_flags ( cpu_state cpu,
uint32_t  final_state,
uint8_t  flags 
)

Set the flags PSW status.

Parameters
cpu
final_statethe final value
flagsto be set

◆ SHLD_WRAP()

int SHLD_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(L) --> ((byte 3)(byte 2)) (H) --> ((byte 3) (byte 2) + 1)

Parameters
cpu
base_PC
op_code
Returns
int

◆ SPHL_WRAP()

int SPHL_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(Exchange stack top with H and L) (L) <--> ((SP)); (H) <--> ((SP) + 1); The content of the L register is exchanged with the content of the memory location whose address is specified by the content of register SP. The content of the H register is exchanged with the content of the memory location whose address is one more than the content of register SP.

Parameters
cpu
base_PC
op_code
Returns
int

◆ STA_WRAP()

int STA_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

*((byte 3)(byte 2)) = ACC

Parameters
cpu
base_PC
op_code
Returns
int

◆ STAX_WRAP()

int STAX_WRAP ( cpu_state cpu,
UNUSED UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

Store *(RP) <- A.

Parameters
cpu
base_PC
op_code
Returns
int

◆ STC_WRAP()

int STC_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

Set Carry (CY) <- (1)

Parameters
cpu
base_PC
op_code
Returns
int

◆ SUB_WRAP()

int SUB_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
uint8_t  op_code 
)

(Subtract Register) (A) <– (A) - (r) The content of register r is subtracted from the content of the accumulator. The result is placed in the accumulator.

Parameters
cpu
base_PC
op_code
Returns
int

◆ SUI_WRAP()

int SUI_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(Subtract immediate) (A) <– (A) - (byte 2) The content of the second byte of the instruction is subtracted from the content of the accumulator. The result is placed in the accumulator

Parameters
cpu
base_PC
op_code
Returns
int

◆ UNDEFINED_OP_WRAP()

int UNDEFINED_OP_WRAP ( UNUSED cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

Undefined OPCODE Functor.

Parameters
cpuCpu State
base_PCpointer to the location of the instruction start
op_codeof the instruction under execution
Returns
int 1 of success, 0 if fail

◆ XCHG_WRAP()

int XCHG_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

Xchanges HL <--> DE.

Parameters
cpu
base_PC
op_code
Returns
int

◆ XRA_WRAP()

int XRA_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(Exclusive OR Register) (A) = (A) ^ (r)

Parameters
cpu
base_PC
op_code
Returns
int

◆ XRI_WRAP()

int XRI_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(Exclusive OR Immediate) (A) <– (A) ^ (byte 2) The content of the second byte of the instruction is exclusive-O R'd with the content of the accumu lator. The result is placed in the accumulator. The CY and AC flags are cleared.

Parameters
cpu
base_PC
op_code
Returns
int

◆ XTHL_WRAP()

int XTHL_WRAP ( cpu_state cpu,
UNUSED uint16_t  base_PC,
UNUSED uint8_t  op_code 
)

(Exchange stack top with Hand L) (L) <--> ((SP)) ; (H) <--> ((SP) + 1) ;

Parameters
cpu
base_PC
op_code
Returns
int

Variable Documentation

◆ opcode_lookup

instt_8080_op opcode_lookup[0x100]

A jump table indexed by an Intel 8080 instruction opcode, containing:

  • functor = function pointer
  • cycle_count = number of instruction it takes 8080 to exec
  • Instruction length [1,3]