0% found this document useful (0 votes)
40 views10 pages

Elec2630 Embedded Systems Theory

This document discusses pipelining in embedded systems and instructions that change program flow. It covers: 1) Pipelining allows fetching the next instruction while executing the current one to speed up processing, but problems can occur with instructions that alter flow like branches. 2) Instructions like branches, calls, and gotos change the program counter and can break the pipeline, requiring additional processing to fix. 3) Calls use a stack to save the return address and allow nested subroutine calls up to stack depth. Interrupts also use the stack to save the interrupted address before jumping to the interrupt routine.

Uploaded by

openid_ZufDFRTu
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views10 pages

Elec2630 Embedded Systems Theory

This document discusses pipelining in embedded systems and instructions that change program flow. It covers: 1) Pipelining allows fetching the next instruction while executing the current one to speed up processing, but problems can occur with instructions that alter flow like branches. 2) Instructions like branches, calls, and gotos change the program counter and can break the pipeline, requiring additional processing to fix. 3) Calls use a stack to save the return address and allow nested subroutine calls up to stack depth. Interrupts also use the stack to save the interrupted address before jumping to the interrupt routine.

Uploaded by

openid_ZufDFRTu
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 10

ELEC2630 EMBEDDED

SYSTEMS THEORY
Lecture 6: Pipelining and
instructions that change the flow
of a program
PIPELINING
• The idea of PIPELINING is to speed up the
operation of the Microcontroller

• The next instruction in sequence is fetched


whilst the current instruction is being
executed

• Problems arise when the instruction being


executed changes the flow of the program
INSTRUCTIONS THAT CHANGE
PROGRAM FLOW
• Test and branch instructions. These instuctions
test a bit in a register and if the result of true then
the progam counter is incremented again to skip
the next instruction in memory
• Call subroutine which saves the current program
counter and then load the program counter with
the address in the instruction
• A Goto which replaces the current program
counter value with the address in the instruction
Example Instruction
PIPELINE PROBLEM
• When a test is true, the next instruction in
sequence that has been fetched during the
current instruction is the wrong one

• Another fetch is required to bring the program


counter + 1 contents and “nops” are executed
whilst this happens making the instruction last
twice as long

• A similar process occurs for CALL and GOTO


PROCESSES THAT RETURN
• The CALL instruction changes the flow of
the program by changing the program
counter to the start address of the
subroutine contained in the CALL
instruction.
• But the CALL instruction returns to where it
was called from in the program by saving
the return address in a special area of
memory called a STACK
• A STACK is LIFO buffer, i.e. a Last In First
Out buffer
Why a LIFO buffer

• A LIFO buffer allows a subroutine to call


another subroutine if required

• The limit to this process is the number of


locations in the STACK area of memory
often called the Depth of the STACK

• This process of a call within a call is known


as nested calls
Nested CALL Example
INTERRUPTS
• INTERRUPTS also change the flow of the program but
normally in response to a hardware event
• This could be a signal received from outside the
microcontroller or from one of the peripherals inside the
device itself
• The microcontroller saves the address of the next
instruction on the stack before changing the program
counter to the address of the interrupt routine in memory
• This can be fixed or partly supplied by the interrupting
device
• A special type of return is used to go back to the address
saved on the stack
TYPES OF INTERRUPTS
• Different microcontrollers have different interrupt
structures but most have a means of enabling
individual interrupts and can prevent any interrupt
being acted upon
• Some processors had what was called a non
maskable interrupt which could not be “turned off”
in the software
• All have flags or bits in a register to say what
caused the interrupts (or interrupts)
• Some have a means of setting a priority of
operation if more than one interrupt occurs at
once

You might also like