A
A
Artyom Smirnov2018-11-24 18:28:27
assembler
Artyom Smirnov, 2018-11-24 18:28:27

(Assembler) How to extract 2 bits from a word, make and, or etc. between them. and the results of how to place the bits in a variable?

How to pull out 2 specific bits from a word (16 bits), perform 16 logical operations like and, or on them, then put each result as a bit into a 16-bit word? The task was: "Implement logical arithmetic, in which 16 logical variables would be stored in one word."
Some C++ code below.

#include "pch.h"
#include <iostream>
#include "stdio.h"
using namespace std;

int main()
{
    setlocale(0, "");
    unsigned short int number;
    short int b1, b2, result;


    cout << "Введите число от 0 до 65535: " << endl;
    cin >> number;
    cout << "Введите индекс бита от 0 до 15:" << endl;
    cin >> b1;
    cout << "Введите индекс бита от 0 до 15:" << endl;
    cin >> b2;

    __asm {

        mov ax, number

    }



    cout << result << endl;

    system("PAUSE");

    return 0;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2018-11-24
@freeExec

Check setting of bit 6
bool bit6IsSet = word & (1 << 6);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question