Bit Manipulation Flashcards

1
Q

operand instruction for logical and

A

AND

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

operand instruction for logical or

A

ORR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

operand instruction for logical not

A

MVN

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

operand instruction for logical exclusive or

A

EOR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what instruction can be used to set

A

AND

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what does set mean

A

change to 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what does clear mean

A

change to 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

uses for bit manipulation

A

working with floats]

writing code that controls hardware eg turn on/off LEDS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

if you have X AND 0 what will this result in

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

if you have X AND 1 what will this result in

A

X

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

if we want to clear bits in positions 3 and 4, what do we do

A

use AND

with a mask which contains all 1s and only 0s in the positions we want to clear

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what does the BIC function do

A

clears with the mask we have already defined

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

if we want to set bits in positions 3 and 4, what do we do

A

use ORR

with a mask which contains all 0s and only 1s in the positions we want to set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

if you have X OR 1 what will this result in

A

1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

if you have X OR 0 what will this result in

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what function can be used to invert certain bits

A

EOR

17
Q

if we want to invert bits in positions 3 and 4, what do we do

A

use EOR,

with a mask with 1s in the positions we want to invert and 0s everywhere else

18
Q

how can bit manipulation be used for difference between upper and lower case letters

A

only difference between upper and lower case letters is the 6th bit (because 0x20 difference)

we can convert to upper case by clearing 6th bit
we can convert to lower case by setting 6th bit

19
Q

what instruction is used for a logical shift left

A

LSL

20
Q

when a 32 bit is shifted to the left where does the MSB go

A

discarded

21
Q

when a 32 but is shifted to the left what does the LSB change to

A

0

22
Q

by how many bit positions can you shift

A

from 0 to 31

23
Q

Logical shift left is the same as

A

Multiplying by 2n.

An effective way to perform multiplication by powers of 2

24
Q

what instruction is used for logical shift right

A

LSR

25
Q

what is the MSB set to in a logical shift right

A

0

26
Q

what happens to the least significant byte in a logical shift right

A

gets discarded

27
Q

logical shift right is the same as

A

dividing by 2n

28
Q

general formula for logical shifts

A

MOV Rd, Rm, LSR/L #n

29
Q

how can we not discard the bit when performing logical shifts

A

by using the MOVS instruction to store the bit in the carry flag

30
Q

what does BCC instrutcion do

A

branch if carry clear (0)

31
Q

What does the BCS instruction do

A

branch if carry set (1)

32
Q

how to perform right and left shifts on signed values ie to keep the msb the same (as it represents the sign)

A

use the ASR instruction

33
Q

What instruction can be used to rotate to the right

A

ROR #n

34
Q

what instruction can be used to rotate to the left

A

ROR #32-n

35
Q

formula for rotating right

A

MOV Rd, Rm, ROR #n