⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spisakbitovafast.cpp

📁 pc paralel port programming
💻 CPP
字号:
// SpisakBitovaFast.cpp: implementation of the CSpisakBitovaFast class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "SpisakBitovaFast.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CSpisakBitovaFast::CSpisakBitovaFast()
    : maskaZaSveBitove_m(0)
    , pomerajMaske_m(0)
    , pinInvertovan_m(0)
{
}

CSpisakBitovaFast::~CSpisakBitovaFast()
{
}

void CSpisakBitovaFast::Dodaj(int bitMaska, int pozicija, bool pinInvertovan)
{
    int pomerenaMaska = bitMaska >> pomerajMaske_m;
    if (pinInvertovan) {
        pinInvertovan_m |= pomerenaMaska;
    }
    maskaZaSveBitove_m |= bitMaska;
}

int CSpisakBitovaFast::FormirajMaskuZaSveBitove(void)
{
    return maskaZaSveBitove_m;
}

int CSpisakBitovaFast::PozicijaBita(int bitMaska)
{
    int pomerenaMaska = bitMaska >> pomerajMaske_m;
    int pomMaska = 0x01;
    for (int i = 0; i < 8; ++i) { // max 8 bitova po registru !!!
        if (pomMaska & pomerenaMaska) {
            return i;
        }
        else {
            pomMaska <<= 1;
        }
    }
    return 0;
}

bool CSpisakBitovaFast::PinInvertovan(int bitMaska)
{
    return ((bitMaska >> pomerajMaske_m) & pinInvertovan_m) ? true : false;
}

int CSpisakBitovaFast::IzdvojiMaskuZaBitSaNajnizomPozicijom(int bitMaska)
{
    int pomerenaMaska = bitMaska >> pomerajMaske_m;
    int pomMaska = 0x01;
    for (int i = 0; i < 8; ++i) { // max 8 bitova za registar !!!
        if (pomMaska & pomerenaMaska) {
            return pomMaska << pomerajMaske_m;
        }
        else {
            pomMaska <<= 1;
        }
    }
    return 0;
}

void CSpisakBitovaFast::InvertujPinoveSaInverznomLogikom(int& sadrzaj)
{
    sadrzaj ^= pinInvertovan_m;
}

void CSpisakBitovaFast::PostaviParametre(int pomeraj)
{
    if (pomeraj > 0) {
        pomerajMaske_m = pomeraj;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -