gpcas_forwardcom 0.2.0

ForwardCom instruction set architecture (ISA) properties for use with the General Purpose Core Architecture Simulator (GPCAS).
Documentation
// Filename: core.rs
// Author:	 Kai Rese
// Version:	 0.6
// Date:	 21-06-2022 (DD-MM-YYYY)
// Library:  gpcas_forwardcom
//
// Copyright (c) 2022 Kai Rese
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program. If not, see
// <https://www.gnu.org/licenses/>.

//! This module extends the emulator module.
//!
//! It contains most of the actual emulation functionality. The main exception is the decode
//! process, which has its own module in order to keep the scope of each module limited.

mod decode;
mod execute;
mod prepare;
mod set_next_ip;
mod write_results;

pub use decode::*;
pub use execute::execute;
pub use prepare::prepare;
pub use set_next_ip::set_next_ip;
pub use write_results::write_results;

/// Sign-extends an integer value of the specified bit size to 64 bit.
#[inline]
pub fn sign_extend(value: u64, size: u8) -> u64 {
    debug_assert!(size > 0);
    value | ((u64::MAX.wrapping_shl(size as u32)) * ((value >> (size as u64 - 1)) & 0x1))
}