Fat MPMC
Fat MPMC
MICROCONTROLLERS
Dr. Sandeep Moparthi
Assistant Professor
School of Electronics Engineering
1
ARM - Advanced RISC Machines
RISC- Reduce Instruction Set Computers
Course Outcomes:
CO5: Infer the architecture of ARM Processor
CO6: Develop the simple application using ARM processor.
TIMELINE (1/3)
1985: Acorn Computer Group manufactures the first
commercial RISC microprocessor.
1990: Acorn and Apple participation leads to the founding of
Advanced RISC Machines (A.R.M.).
1991: ARM6, First embeddable RISC microprocessor.
1992 – 1994: Various companies use ARM (Sharp, Samsung),
while in 1993 ARM7, the first multimedia microprocessor is
introduced.
3
TIMELINE (2/3)
1995: Introduction of Thumb and ARM8.
1996 – 2000: Alcatel, Huindai, Philips, Sony, use ΑRM, while
in 1999 ARM cooperates with Erickson for the development of
Bluetooth.
2000 – 2002: ARM’s share of the 32 – bit embedded RISC
microprocessor market is 80%. ARM Developer Suite is
introduced.
4
TIMELINE (3/3)
Current low-end ARM core for applications like digital mobile
phones
TDMI
T: Thumb, 16-bit instruction set
D: on-chip Debug support, enabling the processor to halt in response to
a debug request
M: enhanced Multiplier, yield a full 64-bit result, high performance
I: Embedded ICE hardware
ICE – in circuit emulator for debugging
5
ARM Design Philosophy
1. Instructions
2. Pipelines
3. Registers
Q J
#10 #10
Note:
1
ARM - Advanced RISC Machines
RISC- Reduce Instruction Set Computers
Course Outcomes:
CO5: Infer the architecture of ARM Processor
CO6: Develop the simple application using ARM processor.
Instructions
Instructions process data held in registers and access memory
with load and store registers
Classes of instructions:
o Data processing
o Branch instructions
o Load-store instructions
o Software interrupt instructions
o Program status register instructions
ARM Data types
o MVN Rd, N
o Move into Rd not of the 32-bit value from source
(takes the value of Operand2 , performs a bitwise logical
NOT operation on the value, and places the result into Rd)
Data processing instructions
Using Barrel Shifter
Enables shifting 32 bit operand in one of the source registers left
or right by a specific no. of positions within the cycle time of
instructions
Basic barrel shifter operations
o Shift left, shift right, rotate right
Facilitates fast multiply, division and increases code density
Example : MOV r7, r5, LSL #2
Data processing instructions
Arithmetic instructions
Implements 32 bit addition and subtraction
3 operand form
Examples
ADD r0, r1, r2
SUB r0, r1, r2
Subtract value stored in r2 from that of r1 and store in r0
• No flag will be effected after arithmetic operation.
• Since there is no S appended at the end of arithmetic instruction,
this will not update/effect the status of corresponding flags after
the operation.
Data processing instructions
Arithmetic instructions
Implements 32 bit addition and subtraction
3 operand form
Examples
ADDS r0, r1, r2
SUBS r1, r1, #1
Subtract 1 from r1 and store result in r1 and update Z and C
flags
S is appended at the end of arithmetic instruction. This will
update/effect the status of corresponding flags after the
operation.
ADC : Present addition along with previous carry;
SBC : Subtract with previous carry/barrow.
Data processing instructions
Arithmetic instructions with barrel shifter
Use of barrel shifter with arithmetic and logical instructions
increases the set of possible available operations
Example
o ADD r0, r1, r1 LSL #1
Register r1 is shifted to the left by 1, then it is added with r1
and the result (3 times of r1) is stored in r0.
Data processing instructions
Multiply instructions
• Multiply contents of a pair of registers
Long multiply generates 64 bit result
Examples
MUL r0, r1, r2
Multiplying two 32-bit numbers together gives rise to a 64-bit
number. The MUL instruction only stores the lower 32 bits of
the product in the specified destination.
UMULL r0, r1, r2, r3 (r15 not allowed as operand.)
UMULL interprets the values from Rn and Rm as unsigned
integers. (r0 and r1 are the destinations of higher and lower 32-
bit of the 64-bit result, respectively.)
Number of cycles taken for execution of multiply instruction
depends upon processor implementation
Data processing instructions
Logical instructions
Bit wise logical operations on the two source registers
o AND, OR , Ex-OR, bit clear
o Example : BIC r0, r1, r2
o r2 contains a binary pattern where every binary 1 in
r2 clears a corresponding bit location in register r1.
R0 = R1 and (~R2)
o Useful in manipulating status flags and interrupt masks
Data processing instructions
Compare instructions
• Enables comparison of 32 bit values
– Updates CPSR flags but do not affect other registers
Examples
compare :
CMP R1, R2 Update CPSR on R1-R2
compare negated :
CMN R1, R2 Update CPSR on R1+R2
bit test :
TST R1, R2 Update CPSR on R1 and R2
test equal :
TEQ R1, R2 Update CPSR on R1 xor R2
Addressing modes
• Register addressing mode-
– All operands are registers which carries data
• Immediate addressing mode
- One of the operand is immediate data
• Direct addressing mode (Not allowed in ARM)
- One of the operand is memory address
Addressing modes (continued)
• Scaled Addressing modes
o Address is calculated using the base address register and a barrel
shift operation
There are different scaled addressing modes that can be used for load
and store operations.
o Register indirect addressing- the address is in a register.
LDR R0, [R1] @ address pointed to by R1
o Pre-indexed addressing - An offset address will be added to the
base address which is present in base register before the memory
access.
The form of this is LDR Rd, [Rn, Op2].
The offset can be positive or negative and can be an immediate
value or another register with an optional shift applied.
LDR R0, [R1, R2] @ address pointed to by R1 + R2
LDR R0, [R1, R2, LSL #2] @ address is R1 + (R2*4)
Addressing modes (continued)
• Scaled Addressing modes (continued)
o Pre-indexed with write-back : this is indicated with an
exclamation mark (!) appended after the instruction. After the
completion of memory access, the base register will be updated
by adding the offset value.
LDR R0, [R1, #32]! @ address pointed to by R1 + 32,
then R1=R1 + 32
• Branch instructions
• Conditional branches
• Conditional execution
• Branch and link instructions
• Subroutine (sub-program) return instructions
Software Interrupt Instruction (SWI)
Solution:
Instruction 1: No flag will be effected through data transfer. It is in
register indirect addressing mode.
Instruction 2: No flag will be effected through data transfer. It is in
immediate addressing mode.
Examples: Assembly language programs of ARM
Example 1: Show the flag bits of status register after the execution of
each instruction in the following code. Identify the addressing mode of
each instruction in the given program.
data R4 carries the address of memory location where data
LDR R2,[R4] ; R2 [R4] is stored.
MOV R3,#0x0FH ; R3 = 0x0FH 0x0FH is a 32-bit data.
ADDS R3,R3,R2 ; R3 = R3+R2
ADD R3,R3,#0x07H ; R3 = R3+0x07H 0x07H is a 32-bit data
MOV R1,R3 ; R1 = R3
Solution (continued):
Instruction 3: Carry flag will be effected after addition. It is in
Register addressing mode.
S is appended at the end of arithmetic instruction. This will
update/effect the status of corresponding flags after the operation.
Examples: Assembly language programs of ARM
Example 1: Show the flag bits of status register after the execution of
each instruction in the following code. Identify the addressing mode of
each instruction in the given program.
data R4 carries the address of memory location where data
LDR R2,[R4] ; R2 [R4] is stored.
MOV R3,#0x0FH ; R3 = 0x0FH 0x0FH is a 32-bit data.
ADDS R3,R3,R2 ; R3 = R3+R2
ADD R3,R3,#0x07H ; R3 = R3+0x07H 0x07H is a 32-bit data
MOV R1,R3 ; R1 = R3
Solution (continued):
Instruction 4: No flag will be effected after addition. It is in
immediate addressing mode.
Since there is no S appended at the end of arithmetic instruction, this
will not update/effect the status of corresponding flags after the
operation.
Examples: Assembly language programs of ARM
Example 1: Show the flag bits of status register after the execution of
each instruction in the following code. Identify the addressing mode of
each instruction in the given program.
data R4 carries the address of memory location where data
LDR R2,[R4] ; R2 [R4] is stored.
MOV R3,#0x0FH ; R3 = 0x0FH 0x0FH is a 32-bit data.
ADDS R3,R3,R2 ; R3 = R3+R2
ADD R3,R3,#0x07H ; R3 = R3+0x07H 0x07H is a 32-bit data
MOV R1,R3 ; R1 = R3
Solution (continued):
Instruction 5: No flag will be effected through data transfer. It is in
register addressing mode.
Solution:
Examples: Assembly language programs of ARM
Example 3: Optimize the following code which is written using
branching. Hint: Use conditional execution.
Solution:
CMP R0,#0x5H
ADDNE R1,R1,R0
SUBNE R1,R1,R2
------
------ Remaining
------ code continues
using branching
Note: In above example, conditional execution resulted in optimized code (higher code
density). However, code optimization is not guaranteed with conditional execution in all cases.
In some applications, both conditional execution and branching may give same code density.
Examples: Assembly language programs of ARM
Example 5: Write an ARM assembly language program (ALP) for the
following expression.
4H+5H-19H
Solution: