Cortex-M0+ Instructions Flashcards

1
Q

What is the difference between ADD and ADDS?

A

ADDS will update the condition flags depending on the result of the ADD operation

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

R0: 4000
R1: 200

ADD R0, R0, R1
What values are in the registers?

A

R0: 4200
R1: 200

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

R0: 4000
R1: 200

SUB R0, R1, #100
What values are in the registers?

A

R0: 100
R1: 200

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

R0: 4
R1: 2

MULS R1, R0, R1
What values are in the registers?

A

R0: 4
R1: 8

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

R0: 4
R1: 2

CMP R0,R1
What are the condition flags?

A

N:0
Z:0
C:0
V:0
Note: R0-R1

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

R0: 4
R1: 2

CMP R1,R0
What are the condition flags?

A

N:1
Z:0
C:0
V:0
Note: R1-R0

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

When is the N condition flag set?

A

When the result of an operation is negative.

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

When is the Z condition flag set?

A

When the result of an operation is Zero.

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

When is the C condition flag set?

A

When an operation results in a carry.
1) When addition result is greater than 32 bits.
2) If subtraction result is zero or positive.
3) As a result of inline barrel shifter operation

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

When is the V condition flag set?

A

When an operation results in overflow. When the resulting sign is wrong.
1) If Neg+Neg=Pos
2) If Neg-Pos=Pos
3) If Pos+Pos=Neg
4) If Pos-Neg=Neg

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

When does the processor enter Handler mode?

A

When servicing an exception or interrupt.

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

Thumb Instructions
How long are Full ARM Instruction?
How long are Thumb Insruction?

A

Full ARM: 32 Bits
Thumb: 16 Bits

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

What is the difference between Machine Language and Assembly Language?
How do you convert between them?

A

In Machine Language instructions are represented by numerical values ready to be processed directly by the CPU.
Assembly language is a human readable representation of machine language where instructions have mnemonic names.
Usually we generate Machine language with the help of an Assembler (software tool)

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

True or False?
Only Load, Store, Pop and Push instructions can access memory.

A

True.
Other instructions must use operands in registers or using immediate values

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

True or False?
Immediate values can be any length?

A

False.
Only between 0 and 255.

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

After a single register PUSH instruction how much will the value of the SP change?

A

It will decrease by 4.
As memory is byte addressable and 4 bytes have been added. The stack pointer decreases as the stack grows.

17
Q

The following code resultsin the number -14 in R0.

MOV R0,#0xd
MVNS R0,R0

How do these instructions work to generate -14?
Why not generate -14 using the MOV instruction and -14 as an immediate value?
Why not retrieve -14 from memory with a load instruction?

A

The value 13 is generate and placed in R0 then the MVNS performs and EOR operation with 0xFFFFFFFF and 0xd. The result is the signed representation of -14.

Immediate values can only be between 0 and 255.

Valid but retrieval from memory is slow.

18
Q

Branch instructions can have a conditional suffix attached. What is the condition of the suffix EQ?

A

Equal.
After a compare if the Zero flag is set the operands where equal.

19
Q

Branch instructions can have a conditional suffix attached. What is the condition of the suffix NE?

A

Not Equal.
After a compare if the Zero flag is not set the operands where not equal.

20
Q

Branch instructions can have a conditional suffix attached. What is the condition of the suffix CS or HS?

A

Carry Set / (unsigned) Higher or Same.
Greater than or equal.

21
Q

Branch instructions can have a conditional suffix attached. What is the condition of the suffix CC or LO?

A

Carry Clear/(Unsigned) Lower.
Less than.

22
Q

Branch instructions can have a conditional suffix attached. What is the condition of the suffix MI?

A

Negative.

23
Q

Branch instructions can have a conditional suffix attached. What is the condition of the suffix PL?

A

Positive.