Cortex-M0+ Instructions Flashcards
What is the difference between ADD and ADDS?
ADDS will update the condition flags depending on the result of the ADD operation
R0: 4000
R1: 200
ADD R0, R0, R1
What values are in the registers?
R0: 4200
R1: 200
R0: 4000
R1: 200
SUB R0, R1, #100
What values are in the registers?
R0: 100
R1: 200
R0: 4
R1: 2
MULS R1, R0, R1
What values are in the registers?
R0: 4
R1: 8
R0: 4
R1: 2
CMP R0,R1
What are the condition flags?
N:0
Z:0
C:0
V:0
Note: R0-R1
R0: 4
R1: 2
CMP R1,R0
What are the condition flags?
N:1
Z:0
C:0
V:0
Note: R1-R0
When is the N condition flag set?
When the result of an operation is negative.
When is the Z condition flag set?
When the result of an operation is Zero.
When is the C condition flag set?
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
When is the V condition flag set?
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
When does the processor enter Handler mode?
When servicing an exception or interrupt.
Thumb Instructions
How long are Full ARM Instruction?
How long are Thumb Insruction?
Full ARM: 32 Bits
Thumb: 16 Bits
What is the difference between Machine Language and Assembly Language?
How do you convert between them?
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)
True or False?
Only Load, Store, Pop and Push instructions can access memory.
True.
Other instructions must use operands in registers or using immediate values
True or False?
Immediate values can be any length?
False.
Only between 0 and 255.
After a single register PUSH instruction how much will the value of the SP change?
It will decrease by 4.
As memory is byte addressable and 4 bytes have been added. The stack pointer decreases as the stack grows.
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?
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.
Branch instructions can have a conditional suffix attached. What is the condition of the suffix EQ?
Equal.
After a compare if the Zero flag is set the operands where equal.
Branch instructions can have a conditional suffix attached. What is the condition of the suffix NE?
Not Equal.
After a compare if the Zero flag is not set the operands where not equal.
Branch instructions can have a conditional suffix attached. What is the condition of the suffix CS or HS?
Carry Set / (unsigned) Higher or Same.
Greater than or equal.
Branch instructions can have a conditional suffix attached. What is the condition of the suffix CC or LO?
Carry Clear/(Unsigned) Lower.
Less than.
Branch instructions can have a conditional suffix attached. What is the condition of the suffix MI?
Negative.
Branch instructions can have a conditional suffix attached. What is the condition of the suffix PL?
Positive.