PZ80emu  0.1
Functions
sub.c File Reference

Helper functions for subtraction operations. More...

#include "sub.h"
#include "utils.h"
Include dependency graph for sub.c:

Functions

static void ___sub8_set_carry_flag (uint8_t a, uint8_t b, struct z80 *cpu)
 sets the carry flag based on the provided operands More...
 
static void ___sub8_set_zero_flag (uint8_t a, uint8_t b, struct z80 *cpu)
 sets the zero flag based on the provided operands More...
 
static void ___sub8_set_overflow_flag (uint8_t a, uint8_t b, struct z80 *cpu)
 sets the overflow flag based on the provided operands More...
 
static void ___sub8_set_sign_flag (uint8_t a, uint8_t b, struct z80 *cpu)
 sets the sign flag based on the provided operands More...
 
static void ___sub8_set_half_carry_flag (uint8_t a, uint8_t b, struct z80 *cpu)
 sets the half carry flag based on the provided operands More...
 
static void __sub8_set_flags (uint8_t a, uint8_t b, struct z80 *cpu)
 wrapper to set flags based on the operands of a subtraction operation More...
 
void _cp (uint8_t *reg, struct z80 *cpu)
 set flags as if operand was subtracted from A More...
 
void _sub_a_reg8 (struct z80 *cpu, uint8_t *reg)
 subtracts reg from the A register More...
 
void _sub_a_mem (struct z80 *cpu, uint8_t *memory)
 subtracts the contents of a memory address from the A register More...
 
void _sbc_a_reg8 (struct z80 *cpu, uint8_t *reg)
 subtracts an 8-bit register from the A register with carry More...
 
void _dec8 (uint8_t *n, struct z80 *cpu)
 decrements an 8-bit register More...
 

Detailed Description

Helper functions for subtraction operations.

Author
Peter H. Ezetta
Date
2018-2019

Function Documentation

◆ ___sub8_set_carry_flag()

static void ___sub8_set_carry_flag ( uint8_t  a,
uint8_t  b,
struct z80 cpu 
)
static

sets the carry flag based on the provided operands

Parameters
a
b
cpuz80 CPU object

◆ ___sub8_set_half_carry_flag()

static void ___sub8_set_half_carry_flag ( uint8_t  a,
uint8_t  b,
struct z80 cpu 
)
static

sets the half carry flag based on the provided operands

Parameters
a
b
cpuz80 CPU object

◆ ___sub8_set_overflow_flag()

static void ___sub8_set_overflow_flag ( uint8_t  a,
uint8_t  b,
struct z80 cpu 
)
static

sets the overflow flag based on the provided operands

Parameters
a
b
cpuz80 CPU object

◆ ___sub8_set_sign_flag()

static void ___sub8_set_sign_flag ( uint8_t  a,
uint8_t  b,
struct z80 cpu 
)
static

sets the sign flag based on the provided operands

Parameters
a
b
cpuz80 CPU object

◆ ___sub8_set_zero_flag()

static void ___sub8_set_zero_flag ( uint8_t  a,
uint8_t  b,
struct z80 cpu 
)
static

sets the zero flag based on the provided operands

Parameters
a
b
cpuz80 CPU object

◆ __sub8_set_flags()

static void __sub8_set_flags ( uint8_t  a,
uint8_t  b,
struct z80 cpu 
)
static

wrapper to set flags based on the operands of a subtraction operation

Parameters
a
b
cpuz80 CPU object
Here is the call graph for this function:

◆ _cp()

void _cp ( uint8_t *  reg,
struct z80 cpu 
)

set flags as if operand was subtracted from A

Parameters
regregister to subtract from A
cpuz80 CPU object

The CP instruction sets the flags as if the operand to CP were subtracted from the A register, however the subtraction does not actually occur, and the original value of A is left untouched.

Here is the call graph for this function:

◆ _dec8()

void _dec8 ( uint8_t *  n,
struct z80 cpu 
)

decrements an 8-bit register

Parameters
nregister to decrement
cpuz80 CPU object
Bug:
dec8 isn't operating on flags

◆ _sbc_a_reg8()

void _sbc_a_reg8 ( struct z80 cpu,
uint8_t *  reg 
)

subtracts an 8-bit register from the A register with carry

Parameters
cpuz80 CPU object
regregister to subtract from A
Here is the call graph for this function:

◆ _sub_a_mem()

void _sub_a_mem ( struct z80 cpu,
uint8_t *  memory 
)

subtracts the contents of a memory address from the A register

Parameters
cpuz80 CPU object
memorypointer to memory to subtract from the A register
Here is the call graph for this function:

◆ _sub_a_reg8()

void _sub_a_reg8 ( struct z80 cpu,
uint8_t *  reg 
)

subtracts reg from the A register

Parameters
cpuz80 CPU object
reg8-bit register to subtract from A
Here is the call graph for this function: