Vous êtes sur la page 1sur 13

ECE 2560

L7 – Assembler Directives

Department of Electrical and


Computer Engineering
The Ohio State University

ECE 3561 - Lecture 1 1


Lect 6 – Assembler Directives

 What are assembler directives?


 The MSP 430 directives to
 Specify where user code is
 Reserve space for variables
 Set the value for constants
 Other useful directives

 This assembler directives covered in this


class are only part of those available.
ECE 3561 - Lecture 1 2
Assembler Directives

 What are assembler directives?


 How do you set up an area of memory to be
data
 For temporary data of the program
 Set up constants for use in my program

 And other possible uses

 Assembler Directives are a means by which


you can ‘direct’ the assembler to take
specific actions.

ECE 3561 - Lecture 1 3


Where is information on them
 Information on the assembler directives can
be found in CCS help.
 Do a search for assembler directives and
the top item is ‘Chapter 5. Assembler
Directives.
 There are a lot of directives. In class only a
small number of them will be addressed.
 Section 5.1 is the Directives Summary
 Chapter 2 also has information on the
assembler directives.

ECE 3561 - Lecture 1 4


High level directives
 The code you develop is divided into
sections named
 .text – Used for program code (ROM)
 .data – Assembles the directives following into
the .data section and RAM memory area of the
selected MSP430xxxx version.

 .intvec – Creates an interrupt vector entry in a


named section that points to an interrupt
routine name. (located in ROM) More on this
later.

ECE 3561 - Lecture 1 5


When starting a new project
 The code
template
 Note .text
section
 Code goes here
 You need to
terminate
execution of
your code
 loop JMP loop

ECE 3561 - Lecture 1 6


Where to put data?
 Use: To reserve space for data variable used in
your program.
 The data registers are one place to use for the
data variables in a program.
 Limited to 12 specific locations R5-15.
 Program will often have need of more than 12
variables.
 The first program could have use mostly register
but used memory instead.
 Where to store them? IN MEMORY
 There needs to be a means to reference them,
i.e., they need to be named.

ECE 3561 - Lecture 1 7


Storing variables in memory
 First need a section for variables
 .data
 Examples of this were shown during the demo.
 For example
 .word reserves space and initializes the value
- use:
 label .word 0xFFFF
 label2 .word 0xAAAA,0x1111,0x2222
 .byte reserves space for byte values - use:
 label3 .byte 0x11
 label4 .byte 0x40

ECE 3561 - Lecture 1 8


Declare and initialize values

 .bits – initializes one or more successive


bits (use of one bit will use the entire byte)
 .char declares and initialized one or more
successive bytes to be the ASCII values of
the character.
 lbl .char 8, “def”
 Will place the values 8h in memory, then the ascii for
d (64), ascii for e (65), ascii for f (66)
 .string – initializes one of more text strings
 Mlbl .string “now is the time”

ECE 3561 - Lecture 1 9


More value types

 .int – initializes one or more 16-bit integers


 .long – initializes one or more 32-bit
integers
 .float – initializes one or more floating point
numbers – IEEE format – 32 bits
 .uint – initializes one or more unsigned
integers
 .long – initializes one or more 32-bit
integers

ECE 3561 - Lecture 1 10


Just want to reserve space

 To reserve space in RAM and attach a


label to it so it can be referenced
 .bes – Used for uninitialized objects
(global data – variables)
 label .bes size - label points to the
end of the reserved space
 .space – Used for uninitialized objects
 splbl .space size2 - splbl points to the
start of the reserved space

ECE 3561 - Lecture 1 11


For further reference

 For a further explanation of the


assembler directive you can look in
section 5.12, Directives Reference, in the
MSP430 Assembly Language Tool
User’s Guide (available in Code
Composer help).

ECE 3561 - Lecture 1 12


Summary - Assignment

 These are the most relevant directives


for this class.

 No new assignment.

ECE 3561 - Lecture 1 13

Vous aimerez peut-être aussi