Contur 2
Educational OS kernel simulator
Loading...
Searching...
No Matches
program_builder.h File Reference

Inline Block construction helpers for assembling bytecode programs. More...

#include <cstdint>
#include "contur/core/types.h"
#include "contur/arch/block.h"
#include "contur/arch/instruction.h"
#include "contur/arch/interrupt.h"

Go to the source code of this file.

Namespaces

namespace  contur

Functions

Block contur::movImm (std::uint8_t reg, RegisterValue value) noexcept
 Loads an immediate value into a register.
Block contur::movReg (std::uint8_t dst, std::uint8_t src) noexcept
 Copies the value of one register into another.
Block contur::addImm (std::uint8_t reg, RegisterValue value) noexcept
 Adds an immediate value to a register (dst = dst + value).
Block contur::addReg (std::uint8_t dst, std::uint8_t src) noexcept
 Adds the value of one register to another (dst = dst + src).
Block contur::subImm (std::uint8_t reg, RegisterValue value) noexcept
 Subtracts an immediate value from a register (dst = dst - value).
Block contur::subReg (std::uint8_t dst, std::uint8_t src) noexcept
 Subtracts the value of one register from another (dst = dst - src).
Block contur::mulImm (std::uint8_t reg, RegisterValue value) noexcept
 Multiplies a register by an immediate value (dst = dst * value).
Block contur::mulReg (std::uint8_t dst, std::uint8_t src) noexcept
 Multiplies a register by the value of another register (dst = dst * src).
Block contur::divImm (std::uint8_t reg, RegisterValue value) noexcept
 Divides a register by an immediate value (dst = dst / value).
Block contur::divReg (std::uint8_t dst, std::uint8_t src) noexcept
 Divides a register by the value of another register (dst = dst / src).
Block contur::readMem (std::uint8_t reg, MemoryAddress addr) noexcept
 Reads a value from a physical memory address into a register.
Block contur::writeMem (std::uint8_t reg, MemoryAddress addr) noexcept
 Writes a register value to a physical memory address.
Block contur::compareImm (std::uint8_t reg, RegisterValue value) noexcept
 Compares a register against an immediate value and sets flags.
Block contur::compareReg (std::uint8_t reg, std::uint8_t other) noexcept
 Compares two registers and sets flags.
Block contur::jumpEqual (RegisterValue target) noexcept
 Jumps to target if the last compare was equal.
Block contur::jumpNotEqual (RegisterValue target) noexcept
 Jumps to target if the last compare was not equal.
Block contur::jumpGreater (RegisterValue target) noexcept
 Jumps to target if the last compare was greater.
Block contur::jumpLess (RegisterValue target) noexcept
 Jumps to target if the last compare was less.
Block contur::jumpGreaterEqual (RegisterValue target) noexcept
 Jumps to target if the last compare was greater or equal.
Block contur::jumpLessEqual (RegisterValue target) noexcept
 Jumps to target if the last compare was less or equal.
Block contur::interrupt (Interrupt code) noexcept
 Raises a software interrupt.
Block contur::nop () noexcept
 No-op — advances the program counter by one.
Block contur::halt () noexcept
 Halts the process unconditionally.

Detailed Description

Inline Block construction helpers for assembling bytecode programs.

Each function produces one Block (the single memory-cell type the interpreter fetches and executes). state=0 → immediate operand; state=1 → register-indirect.

Definition in file program_builder.h.