cpprisc16  March 16, 2017
 All Namespaces Files Functions Variables Typedefs Macros
Namespaces | Macros | Typedefs | Functions
cpprisc16.hpp File Reference

Instructions set of RiSC16: 8 instructions i_* and 4 pseudo-instructions p_*. More...

#include <cassert>
#include <cstdint>
Include dependency graph for cpprisc16.hpp:

Go to the source code of this file.

Namespaces

 cpprisc16
 

Macros

#define i_beq(a, b, label)
 (Branch if EQual) If R[a] == R[b] then jump to label. More...
 

Typedefs

typedef std::uint16_t cpprisc16::immed_t
 Type for immediate value. More...
 
typedef std::uint16_t cpprisc16::word16_t
 Type for register and memory items. More...
 

Functions

void cpprisc16::i_add (unsigned int result, unsigned int a, unsigned int b)
 R[result] <– R[a] + R[b]. More...
 
void cpprisc16::i_addi (unsigned int result, unsigned int a, immed_t immed6)
 (ADD Immediate) R[result] <– R[a] + immed6 More...
 
void cpprisc16::i_jalr (unsigned int result, unsigned int a)
 (Jump And Link using Register) In the real RiSC16: R[result] <– PC + 1 (where PC = Program Counter), PC <– R[a] (jump to R[a]) but impossible to implement that in this C++ library. More...
 
void cpprisc16::i_lui (unsigned int result, immed_t immed10)
 (Load Upper Immediate) R[result] <– immed10 << 6 More...
 
void cpprisc16::i_lw (unsigned int result, unsigned int a, immed_t immed6)
 (Load Word) R[result] <– Memory[R[a] + immed6] More...
 
void cpprisc16::i_nand (unsigned int result, unsigned int a, unsigned int b)
 R[result] <– R[a] NAND R[b] (== ~(a & b)) More...
 
void cpprisc16::i_sw (unsigned int a, unsigned int result, immed_t immed6)
 (Store Word) Memory[R[result] + immed6] <– R[a] More...
 
void cpprisc16::p_halt (bool print=true)
 If print then call println_all() More...
 
void cpprisc16::p_movi (unsigned int result, immed_t immed)
 (MOV Immediate) R[result] <– immed More...
 
void cpprisc16::p_nop ()
 Do nothing. More...
 
void cpprisc16::p_reset ()
 In the real RiSC16: R[result] <– PC + 1 (where PC = Program Counter), PC <– 0 (jump to 0) but impossible to implement that in this C++ library. More...
 
void cpprisc16::clear_memory ()
 Reset to 0 all memory items and mark them as not used. More...
 
void cpprisc16::clear_nb_executed ()
 Reset the number of executed instructions. More...
 
void cpprisc16::clear_registers ()
 Reset to 0 all registers. More...
 
void cpprisc16::print_mem (unsigned int i)
 Print ith memory item M[i] (without newline). More...
 
void cpprisc16::print_reg (unsigned int a)
 Print the register R[a] (without newline). More...
 
void cpprisc16::print_reg2 (unsigned int a2, unsigned int a1)
 Print the 32 bits value of R[a2]:R[a1] (without newline). More...
 
void cpprisc16::print_value16 (std::uint16_t n)
 Print to stdout the 16 bits value n: hexadecimal representation = binary = decimal = signed decimal (without newline). More...
 
void cpprisc16::print_value32 (std::uint32_t n)
 Print to stdout the 32 bits value n: hexadecimal representation = binary = decimal = signed decimal (without newline). More...
 
void cpprisc16::println_all ()
 Print infos, registers and memory (if used). More...
 
void cpprisc16::println_infos ()
 Print to stdout the number of executed instructions. More...
 
void cpprisc16::println_mem (unsigned int i)
 Print ith memory item M[i]. More...
 
void cpprisc16::println_memory (unsigned int size=0)
 Print memory items. More...
 
void cpprisc16::println_reg (unsigned int a)
 Print the register R[a]. More...
 
void cpprisc16::println_reg2 (unsigned int a2, unsigned int a1)
 Print the 32 bits value of R[a2]:R[a1]. More...
 
void cpprisc16::println_registers ()
 Print all registers items. More...
 
void cpprisc16::println_value16 (std::uint16_t n)
 Print to stdout the 16 bits value n: hexadecimal representation = binary = decimal = signed decimal. More...
 
void cpprisc16::println_value32 (std::uint32_t n)
 Print to stdout the 32 bits value n: hexadecimal representation = binary = decimal = signed decimal. More...
 

Detailed Description

Instructions set of RiSC16: 8 instructions i_* and 4 pseudo-instructions p_*.

(March 15, 2017) Piece of cpprisc16. https://bitbucket.org/OPiMedia/cpprisc16

GPLv3 — Copyright (C) 2017 Olivier Pirson http://www.opimedia.be/

Definition in file cpprisc16.hpp.

Macro Definition Documentation

#define i_beq (   a,
  b,
  label 
)
Value:
{ \
assert(a < cpprisc16::nb_registers); \
assert(b < cpprisc16::nb_registers); \
\
if (cpprisc16::registers[a] == cpprisc16::registers[b]) { goto label; } \
}
word16_t registers[8]
Registers.
Definition: cpprisc16.cpp:43
const unsigned int nb_registers
Number of registers: 8 word16_t items.
Definition: cpprisc16.cpp:28
uint64_t nb_executed
Number of instructions executed.
Definition: cpprisc16.cpp:41

(Branch if EQual) If R[a] == R[b] then jump to label.

Definition at line 30 of file cpprisc16.hpp.