UEE072HM - PowerPoint PPT Presentation

About This Presentation
Title:

UEE072HM

Description:

UEE072HM – PowerPoint PPT presentation

Number of Views:14
Avg rating:3.0/5.0
Slides: 21
Provided by: craig60
Category:

less

Transcript and Presenter's Notes

Title: UEE072HM


1
UEE072HM
  • Linking HLL and ALP
  • An example on ARM

2
Embedded and Real-Time Systems
  • We will mainly look at embedded systems
  • Systems which have the computer system embedded
    within their application area, normally using a
    specialised single board computer (SBC)
  • There is a difference between embedded and
    real-time one does not imply the other
  • Hard real-time vs soft real-time

3
Embedded Systems Development
  • Embedded systems require host-target development
    this means
  • The development is done on a different machine
    than the target
  • The code must be downloaded to run
  • Can be running on different CPU and architecture

4
Host Target Development
Target boards
Development Host (Linux?)
5
Embedded Systems Development
  • Embedded systems development requires
  • Mixed language programming HLL plus assembler
  • Increased knowledge of tools compiler, linker
    and librarians
  • Use of specialised tools i.e. down loaders
  • Special skills to debug code

6
Using C for Embedded Systems
define ADDRESS 0xFFFF41 main() char
mem_p mem_p(char)ADDRESS while !(mem_p
) // do nothing
  • A major requirement is for direct memory access,
    this is achieved using pointers.
  • This style of code is quite common

7
Using C for Embedded Systems
  • Note
  • Use of define
  • Use of char
  • Use of volatile
  • Casting of return value
  • Use of binary op

define ADDRESS 0xFFFF41 define MASK
0x3 main() volatile char mem_p mem_p(char
)ADDRESS while !(mem_p MASK ) // do
nothing
8
Using C for Embedded Systems
  • Using C in Embedded Systems you will need to know
    more about
  • Compilation process
  • Linking
  • Storage issues

9
Using C for Embedded Systems
  • Compilation issues
  • Passing parameters
  • Naming conventions
  • Symbol table and map generation
  • Assembler output

10
Why use HLL?
  • Why do high level language programmers need to
    know the low level details of storage and
    function calls?
  • To write more efficient code
  • To write assembler routines that are called from
    a HLL
  • To call assembler routine from a HLL
  • Improves knowledge of both tools and CPU

11
Why use ALP?
  • Why use assembler in place of HLL?
  • Speed up code
  • Smaller code
  • Special instructions
  • Boot strap routines
  • Optimise HLL code

12
Using C for Embedded Systems
  • Ways to link HLL ALP - passing parameters
  • Parameter blocks
  • No recursion
  • Using registers
  • Limited numbers of registers
  • Using the stack
  • Most favoured method
  • Many use a combination of the above

13
The run-time stack
  • In order to see how HLLs are implemented we need
    to know about the run-time stack and the
    registers that control it.
  • The stack is used for
  • Storing important values that may get changed
    during execution
  • Local variables
  • Passing some function parameters

14
Function set-up
  • In C function set up consists of
  • Creating an executable label
  • Saving the stack pointer into ip
  • Storing registers used onto the stack
  • Using stmfd store multiple registers instructions
  • Putting the frame pointer at the stack base

gcc2_compiled..text .align 2 .global main .ty
pe main,functionmain _at_ args 0, pretend 0,
frame 8 _at_ frame_needed 1 mov ip,
sp stmfd sp!, fp, ip, lr, pc sub fp, ip, 4
15
Function set-up
Stack
16
Local variables
  • The stack is used for local variable storage
  • The compiler creates a stack frame to store the
    variables
  • The variables are accessed by an offset from the
    frame pointer fp
  • This means
  • variable names can be repeated
  • functions can be recursively called

17
Creating a stack frame
Create the Stack frame
18
A stack frame
Registers
Low memory
SP Stack Pointer
j
20
FP - 20
i
10
FP - 16
PC
LR
IP
FP Frame Pointer
FP
High memory
IP Intra-Procedure
19
Leaving a function call
  • The code to leave a function call is simple
  • ldmea
  • Load multiple registers command is used from the
    stack
  • The old
  • frame stack pointers program counter
  • are restored
  • This does a return with a cleaned stack

.L2 ldmea fp, fp, sp, pc.Lfe1 .size
main,.Lfe1-main
20
_at_ Generated by gcc 2.95.3 20010315 (release) for
ARM/elf .file "ex1.c"_at_ GNU C version 2.95.3
20010315 (release) (arm-linux) compiled by GNU C
version 2.95.2 20000220 (Debian GNU/Linux)._at_
options passed -fverbose-asm_at_ options enabled
-fpeephole -ffunction-cse -fkeep-static-consts_at_
-freg-struct-return -fsjlj-exceptions -fcommon
-fverbose-asm -fgnu-linker_at_ -fargument-alias
-fident -mapcs-32 -mshort-load-bytes
-mno-short-load-wordsgcc2_compiled..text .alig
n 2 .global main .type main,functionmain _at_
args 0, pretend 0, frame 8 _at_ frame_needed
1, current_function_anonymous_args 0 mov ip,
sp stmfd sp!, fp, ip, lr, pc sub fp, ip,
4 sub sp, sp, 8 mov r3, 10 str r3, fp,
-16 mov r3, 20 str r3, fp, -20 mov r0,
1 mov r1, 2 mov r2, 3 mov r3,
4 bl do_it.L2 ldmea fp, fp, sp,
pc.Lfe1 .size main,.Lfe1-main
Write a Comment
User Comments (0)
About PowerShow.com