Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 151Data values in 68HC11 registers.Recall that registers A and B are 8-bit registers and that registers D, X, and Y are16-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 2’s complement form 7 A 0 7 B 015 PC 015 SP 015 Y 015 X 015 D 08-Bit accumulators A and B16-Bit double accumulator DIndex register XIndex register YStack pointerProgram CounterS X H I N Z V C Condition Code RegisterLecture #17 EGR 270 – Fundamentals of Computer Engineering2Example: Determine the value stored in each register below in decimal form:0 0 0 1 1 0 0 1Register A(decimal value)1 1 0 1 1 1 0 0Register B(decimal value)(decimal value)0 0 0 1 0 0 0 0Register X0 0 0 0 0 1 1 0(decimal value)1 1 1 1 1 1 1 0Register X1 1 1 1 0 0 1 1Example: Determine the largest and smallest (most negative) values that can be stored in registers A and X.Register Largest Value Smallest valueAXLecture #17 EGR 270 – Fundamentals of Computer Engineering3Memory 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: __________Lecture #17 EGR 270 – Fundamentals of Computer Engineering468HC11 Assembly Language Programming ExamplesWrite a program to:A) Find the sum of the values in memory locations M[$00], M[$01], M[$02], and M[$03] and store the result in M[$04]Lecture #17 EGR 270 – Fundamentals of Computer Engineering568HC11 Assembly Language Programming ExamplesWrite a program to:B) Determine the smallest value in memory locations M[$00], M[$01], M[$02], and M[$03] and store it in M[$04]Lecture #17 EGR 270 – Fundamentals of Computer Engineering668HC11 Assembly Language Programming ExamplesWrite a program to:C) Write a program similar to the C++ program below:Sum = 0;for (i = 1; i >=20; i+=2) Sum = Sum + i;Lecture #17 EGR 270 – Fundamentals of Computer Engineering7MemoryWhen working with microcontrollers and their limited memory, it is important to be aware what memory addresses are available for:• 68HC11 registers• Storing data• Storing programsA 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 MicroStamp11’s 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 MicroStamp11’s to be used in lab have 32kB of EEPROM.Lecture #17 EGR 270 – Fundamentals of Computer Engineering8Memory Map for the MicroStamp11 (32k Turbo)32kB EEPROM($8000 to $FFFF)32kB External RAM($0100 to $7FFF)(64k MAX version only)(unused in other versions)192 bytes Internal RAM($0040 to $00FF)64 bytes Internal Register Block ($0000 to $003F)$FFFF$8000$7FFF$0100$00FF$0040$003F$0000Used to store programs (S19 files)(Ex: Begin a program with ORG $8000)Extra RAM for data storage(Not available with our MicroStamp11)Used to store data(Ex: STAA $0040 ;Save countUsed for register contents(Ex: LDAA #$04 STAA $09 ; Set PD2 as an output)Lecture #17 EGR 270 – Fundamentals of Computer Engineering968HC11 Assembler DirectivesSo 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 memoryAssembler Directives:•EQU•ORG•FCB•FCC•FDB•BSZ•RMB•ENDLecture #17 EGR 270 – Fundamentals of Computer Engineering10ORG <expression>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 ROMLDAA #$FF ;First line of program <label> EQU <expression>Directs the assembler to substitute the expression value where ever the label appearsExample:Amount EQU $10 ;Equate the label Amount to memory address M[$10]…STAA Amount ;Store value in memory location labeled Amount(<label>) FCB <expr> (,<expr>,…,<expr>)Form Constant Byte - 8 bit constantsDirects the assembler to store each value listed as an 8-bit constant in successive memory locationsExample:ORG $8000Fibonacci FCB 0, 1, 1, 2, 3, 5, 8, 13; ;Store constants beginning at M[$8000]Lecture #17 EGR 270 – Fundamentals of Computer Engineering11(<label>) FDB <expr>(,<expr>,…,<expr>)Form Double Byte - 16 bit constantsDirects the assembler to store each value listed as an 16-bit constant in successive memory locationsExample:ORG $8000Mask FDB %1000100110101011 ;Store binary value at M[$8000]Data FDB 4000, 6000, 8000 ;Store 16-bit constants beginning at M[$8002](<label>) FCC 'String'Form Character Constant - Character StringDirects the assembler to store the ASCII values in successive memory locations.Example:ORG $8000Message FCC 'Hello World!‘ ;Store ASCII Code for H at M[$8000] and;remaining ASCII codes in successive bytesLecture #17 EGR 270 – Fundamentals of Computer


View Full Document
Download EGR 270 LECTURE NOTES
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view EGR 270 LECTURE NOTES and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view EGR 270 LECTURE NOTES 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?