📄 iportfromram.cpp
字号:
/* Copyright (C) 1995, Tektronix Inc. All Rights Reserved. * * Usage Restrictions * * License is granted to copy, to use, and to make and to use derivative * works for research and evaluation purposes only. * * Disclaimer of Warranty * * These software programs are available to the user without any license * fee or royalty on an "as is" basis. Tektronix Inc. disclaims any and * all warranties, whether express, implied, or statuary, including any * implied warranties or merchantability or of fitness for a particular * purpose. In no event shall the copyright-holder be liable for any * incidental, punitive, or consequential damages of any kind whatsoever * arising from the use of these programs. * * This disclaimer of warranty extends to the user of these programs and * user's customers, employees, agents, transferees, successors, and * assigns. * * The Tektronix Inc. does not represent or warrant that the programs * furnished hereunder are free of infringement of any third-party * patents.*//* IPortFromRam implementation */#include "stdafx.h"#include "IPortFromRam.H"#include "Utilities.H"IPortFromRam::IPortFromRam (char* b, int length) : InputPort(){ bits = b; bits_ptr = 0; bits_length = length; pos = -1; // forces read on first call to read_bit}char IPortFromRam::input_bit ()// returns next bit as a char or BADBIT for an error{ int result = inc_bit (); if (result) return bit2char(); return BADBIT;}char IPortFromRam::input_byte (){ if (pos <= 0) { byte = bits[bits_ptr]; bits_ptr++; if (bits_ptr >= bits_length) bits_ptr = 0; } else { sys_error("can't read_byte; not on byte boundary"); } return byte;}int IPortFromRam::inc_bit ()// increments pos or reads from buffer if necessary{ if (pos <= 0) { byte = bits[bits_ptr]; bits_ptr++; if (bits_ptr >= bits_length) bits_ptr = 0; pos = 7; } else { pos--; } return 1;}char IPortFromRam::bit2char ()// returns ONE or ZERO depending on current bit;{ return (byte & (1 << pos)) ? ONE : ZERO;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -