Title: EGR 277
1Lecture 17 EGR 270 Fundamentals of
Computer Engineering
- Data values in 68HC11 registers.
- Recall that registers A and B are 8-bit registers
and that registers D, X, and Y are - 16-bit registers. Since the registers contain
signed binary numbers note that - If the MSB 0, the value is positive
- If the MSB 1, the value is negative and in 2s
complement form
2Lecture 17 EGR 270 Fundamentals of
Computer Engineering
Example Determine the value stored in each
register below in decimal form
Example Determine the largest and smallest
(most negative) values that can be stored in
registers A and X.
Register Largest Value Smallest value
A
X
3Lecture 17 EGR 270 Fundamentals of
Computer Engineering
Memory Addresses in 68HC11 registers. Note that
memory addresses are NOT signed binary numbers so
no sign bit is used. Example So if an 8-bit
memory address is specified (2 hexadecimal
digits) as in the examples below, what is the
largest and smallest memory address? STAA 00
? memory address ___________ (decimal
form) STAA FF ? memory address
___________ (decimal form)
total amount of memory addresses with
8 bits __________ Example So if an 16-bit
memory address is specified (4 hexadecimal
digits) as in the examples below, what is the
largest and smallest memory address? STAA 0000
? memory address ___________
(decimal form) STAA FFFF ? memory
address ___________ (decimal form)
total amount of memory
addresses with 16 bits __________
4Lecture 17 EGR 270 Fundamentals of
Computer Engineering
68HC11 Assembly Language Programming
Examples Write a program to A) Find the sum of
the values in memory locations M00, M01,
M02, and M03 and store the result in M04
5Lecture 17 EGR 270 Fundamentals of
Computer Engineering
68HC11 Assembly Language Programming
Examples Write a program to B) Determine the
smallest value in memory locations M00,
M01, M02, and M03 and store it in
M04
6Lecture 17 EGR 270 Fundamentals of
Computer Engineering
68HC11 Assembly Language Programming
Examples Write a program to C) Write a program
similar to the C program below Sum
0 for (i 1 i gt20 i2) Sum Sum
i
7Lecture 17 EGR 270 Fundamentals of
Computer Engineering
- Memory
- When working with microcontrollers and their
limited memory, it is important to be aware what
memory addresses are available for - 68HC11 registers
- Storing data
- Storing programs
- A memory map is often used to illustrate
different sections of memory. Different
microcontrollers have different amounts of
memory. Note that some memory addresses are used
to access RAM and others are used to access ROM. - RAM (Random Access Memory)
- Used for temporary storage of program data and
register contents - This information is lost when power is turned
off to the MicroStamp11 - Most MicroStamp11s have only 256 bytes of ROM,
although the 64K Max - MicroStamp11 is available with an additional
32kB of external RAM. - ROM (Read-Only Memory) or EEPROM (Electrically
Erasable Programmable ROM) - Used to store programs (i.e., S19 files that
are downloaded). - This information is NOT lost when power is
turned off to the MicroStamp11 - The MicroStamp11 is available with 8kB, 32kB,
or 64kB of EEPROM. - The MicroStamp11s to be used in lab have 32kB
of EEPROM.
8Lecture 17 EGR 270 Fundamentals of
Computer Engineering
Memory Map for the MicroStamp11 (32k Turbo)
9Lecture 17 EGR 270 Fundamentals of
Computer Engineering
68HC11 Assembler Directives So far we have
concentrated on writing assembly language using
commands in the 68HC11 instruction set.
Additional commands, called assembler directives
(or pseudo-ops), are available for
- Specifying the memory location for the program
- Reserving memory for variables and assigning
labels to the memory locations - Specifying constants directly into memory
- Assembler Directives
10Lecture 17 EGR 270 Fundamentals of
Computer Engineering
ORG ltexpressiongt Directs the assembler to set an
address. Any code or data following an ORG will
begin at the specified address. Example ORG
0100 Store the following program at this
location in ROM LDAA FF First line of program
ltlabelgt EQU ltexpressiongt Directs the assembler
to substitute the expression value where ever the
label appears Example Amount EQU 10 Equate the
label Amount to memory address M10 STAA
Amount Store value in memory location labeled
Amount (ltlabelgt) FCB ltexprgt (,ltexprgt,,ltexprgt) Fo
rm Constant Byte - 8 bit constants Directs the
assembler to store each value listed as an 8-bit
constant in successive memory locations Example O
RG 8000 Fibonacci FCB 0, 1, 1, 2, 3, 5, 8,
13 Store constants beginning at M8000
11Lecture 17 EGR 270 Fundamentals of
Computer Engineering
(ltlabelgt) FDB ltexprgt(,ltexprgt,,ltexprgt) Form
Double Byte - 16 bit constants Directs the
assembler to store each value listed as an 16-bit
constant in successive memory locations Example O
RG 8000 Mask FDB 1000100110101011 Store
binary value at M8000 Data FDB 4000, 6000,
8000 Store 16-bit constants beginning at
M8002 (ltlabelgt) FCC 'String' Form Character
Constant - Character String Directs the assembler
to store the ASCII values in successive memory
locations. Example ORG 8000 Message FCC 'Hello
World! Store ASCII Code for H at M8000
and remaining ASCII codes in successive bytes
12Lecture 17 EGR 270 Fundamentals of
Computer Engineering
- Example
- Write assembler directives to
- Store the program at memory location M9000
- Label and store two numbers (NUM1 30, NUM2
50) in memory beginning at location M8000 - Label memory locations M80028003 as Sum and
Diff - Write assembly language instructions to
- calculate the sum and the difference of Num1 and
Num2. - Draw a memory map
13Lecture 17 EGR 270 Fundamentals of
Computer Engineering
(ltlabelgt) RMB ltexpressiongt Reserve Memory Bytes -
number of bytes in expression. Directs the
assembler to reserve the specified number of
bytes and associate them with the label. Nothing
is stored there yet. Example ORG 8000 Buffer
RMB 16 Reserve 16 bytes beginning at
M8000 (ltlabelgt) BSZ ltexpressiongt Block
Storage of Zeros Directs the assembler to store
0s in the specified number of bytes and
associate them with the label. Example ORG
E000 Available BSZ 64 Store 0 in 64 bytes
beginning at ME000 Associate the label
Available with ME000 END End of assembler
input Directs the assembler to stop reading the
file. All lines following END are comments. If
END is omitted, the assembler reads until the end
of file.
14Lecture 17 EGR 270 Fundamentals of
Computer Engineering
- Assemblers
- An assembler converts assembly language
instructions into machine code. - Most assemblers are 2-pass assemblers, where
the assembler essentially the assembler converts
mnemonics into op codes on the first pass and
then determines offsets for branches, memory
locations, etc., on the second pass. - The assembler often produces two key files the
executable machine code (.S19 file) and a listing
file (.LST) which shows the program listing with
op codes and computed offsets.
15Lecture 17 EGR 270 Fundamentals of
Computer Engineering
Simulators Simulators are used to test assembly
language programs. Simulators can be used to
step through programs, check memory and register
contents, etc. It is always a good idea to
simulate a program if possible before downloading
it into a microcontroller.
- Assemblers and Simulators
- A number of assemblers and simulators are
available for the 68HC11. - ODU has recently used the following software
(freeware) for their equivalent course - As11 DOS Motorola 68HC11assembler
- Sim68 DOS 68HC11 assembler
- Wookie Windows 68HC11 simulator
- In this course we will use two freeware programs
to assemble and simulate programs - MGTEK MiniIDE Windows 68HC11 assembler
- Wookie Windows 68HC11 simulator
- Refer to the following handout available on the
instructors webpage - Example Mini IDE Assembler and Wookie
Simulator