register.h header - ylab-nsu/cdm16-llvm-neo GitHub Wiki

#include <cdm/register.h>

Functions for accessing the special registers of the processor.

reg_t type

typedef unsigned int reg_t;

Integer type that represents a value stored in a register.

Note

Also defined in <cdm/ivt.h>.

psr_t enum

typedef enum : reg_t {
  PS_NONE = 0x0,
  PS_NEGATIVE = 0x1,
  PS_ZERO = 0x2,
  PS_OVERFLOW = 0x4,
  PS_CARRY = 0x8,
  PS_INTERRUPT = 0x8000,
} psr_t;

Processor status register bit field.

Variants:

  • PS_NONE - no flags
  • PS_NEGATIVE - arithmetic negative flag (N)
  • PS_ZERO - arithmetic zero flag (Z)
  • PS_OVERFLOW - arithmetic overflow flag (V)
  • PS_CARRY - arithmetic carry flag (C)
  • PS_INTERRUPT - interrupt enable flag (I)

Note

Also defined in <cdm/ivt.h>.

context_t struct

typedef struct {
    reg_t r0;
    reg_t r1;
    reg_t r2;
    reg_t r3;
    reg_t r4;
    reg_t r5;
    reg_t r6;
    reg_t fp;
    reg_t pc;
    psr_t ps;
} context_t;

Processor context, excluding the stack pointer. Matches the layout of the context pushed onto the stack when an ISR is entered. A pointer to context_t is passed as a parameter to ISRs. See isr_t.

Fields:

  • r0-r6 - general purpose registers
  • fp - frame pointer register (FP)
  • pc - program counter register (PC)
  • ps - processor status register (PSR)

Note

Also defined in <cdm/ivt.h>.

ldps() function

psr_t ldps(void);

Gets the current value of the status register (PSR).
Lowered into the ldps $rd instruction.

stps() function

void stps(psr_t value);

Sets the value of the status register (PSR).
Lowered into the stps $rd instruction.

ldpc() function

reg_t ldpc(void);

Gets the value of the program counter register (PC).
Lowered into the ldpc $rd instruction.

ldsp() function

reg_t ldsp(void);

Gets the value of the stack pointer register (SP).
Lowered into the ldsp $rd instruction.

ldfp() function

reg_t ldfp(void);

Gets the value of the frame pointer register (FP).
Lowered into the move fp, $rd instruction.

⚠️ **GitHub.com Fallback** ⚠️