DOC PREVIEW
NMT EE 308 - EE 308 – LAB 1

This preview shows page 1-2 out of 5 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

EE 308 Lab 1 Spring 2006EE 308 – LAB 1MC9S12 ASSEMBLER AND MONITORIntroduction and ObjectivesThis laboratory introduces you to the following MC9S12 assembly language programming tools:• The Freescale MC9S12 assembler as12. This runs on the PC.• The D-Bug12 monitor that runs on the MC9S12.An assembler takes assembly language code in a form that a human can reasonably read (witha little practice), translates it to machine code which a microprocessor can understand, and storesthe machine code in a .s19 file which the MC9S12 monitor program can understand. In this lab wewill use the Freescale as12 assembler, which is on the PCs in the Digital/Microc ontrollers lab. Theas12 assembler is also included on the CD-ROM which comes with your MiniDRAGON+ board.The as12 assembler produces an output file with an .s19 extension which c an be loaded intoand run on the MC9S12. The D-Bug12 monitor, running from 9S12 EPROM, loads S19 recordsinto the 9S12 and provides some tools for debugging loaded programs.Pre-LabYou should read this entire lab and answer all of the questions in the pre-lab section beforecoming to lab. The pre-lab questions are repeate d on a separte page to help you prepare for lab.The D-Bug12 monitor allows you to interact with the 9S12 microcontroller. You can use it toload programs, to find out what is in the 9S12’s registers and memory, to change the contents theregisters and memory, and many other things. The D-Bug12 commands of interest for this lab are:ASM, BF, BR, NOBR, G, HELP, LOAD, MD, MDW, MM, MMW, RM, RD, and T.Read the descriptions of these commands in Chapter 5 of the D-Bug12 Reference Guide.Questions to answer before lab:• What is the difference between the MM and MMW commands?• How would you change the value of the X accumulator to 0x55AA? (There are several ways todo this; you only need to find one way.)Assembly language is used to write programs for the 9S12. An assembly language instructionwill be converted by the assembler into a single machine instruction for the 9S12. The assemblylanguage commands of interest to us for this lab are:LDAA, STAA, TAB, ABA, and ASRA.1EE 308 Lab 1 Spring 2006Read the descriptions of these commands in the MC9S12 CPU12 Core Users Guide. At thispoint you will not understand everything the guide says about these instructions, but you shouldunderstand enough to get you through this lab.Figure 1 is a simple program for the 9S12. We will use it to illustrate how to use the assembler,the simulator and D-Bug12. Note: We will always use the SWI instruction to end a program. Thisinstruction will transfer control the the 9S12 from the program to the D-Bug12 monitor.2EE 308 Lab 1 Spring 2006; MC9S12 demo program; Bill Rison; 1/18/06; This is a program to add the numbers in memory locations $2000 through $2003,; divide the sum by four, and store the result in memory location $2004prog: equ $1000 ; Start program at beginning of RAMdata: equ $2000 ; Memory area for dataorg prog ; set program counter to 0x1000ldaa input ; Get first input value into ACC Aadda input+1 ; add next valueadda input+2 ; add next valueadda input+3 ; add next valuelsra ; divide by 2lsra ; divide by 2 againstaa average ; Save the averageswi ; End program (return to D-Bug 12 monitor)org datainput: dc.b $15,$63,$24,$3F ; Input valuesaverage: ds.b 1 ; reserve one byte for averageFigure 1: An assembly language program used to get started with as12 and D-Bug12.Question to answer before lab: What are the contents of the A register after each instruc-tion of the program shown in Figure 1 executes?We will use D-Bug12 to explore the memory of the 9S12 on your evaluation board. The memorymap for your MC9S12 is shown on page 24 of the MC9S12DP256B Device Users Guide. (Lookthe the figure labele d “Normal Single Chip”.) Much of the memory is used by the D-Bug12 monitor.For this class you can use RAM from 0x1000 to 0x2FFF, and EEPROM from 0x0400 to 0x0FFF.Thegetting started.pdf file which comes on the CD with your MiniDRAGON+ boardshows how to install and use the As mIDE software on you personal computer. Use of AsmIDEis also discussed in Section 3.6 of Huang. Use the AsmIDE or a te xt editor to enter the programshown in Figure 1 before coming to lab and save it under the name lab01.asm. (You can also usea web browswer to download the program.)To assemble the program double-click on the AsmIDE icon on your desktop. Open you filewith the File:Open menu option. Assembe with the Build:Assemble menu option.The as12 assembler will create a file called lab01.lst which shows what op codes weregenerated by the assembler, and a file called lab01.s19, which is the file you will use with the9S12 evaluation board.3EE 308 Lab 1 Spring 2006The LabCreate a directory for this course (say, U:\EE308). Inside this directory create a subdirectoryfor this lab (say, D:\EE308\LAB01). Change to this subdirectory, type in the lab01.s program,and assemble it with the commands shown above.Some questions on the output of the assembler:• Look at the lab01.lst file. Where in memory will the machine code for the instruction staaaverage be stored?• What machine code is generated for the staa average mnemonic? Is this what you expected?(Look up the STAA instruction in your MC9S12 CPU12 Core Users Guide to determinewhat code this instruction should generate.)• At what address will average be lo cated in the 9S12 memory?Connect your MiniDRAGON+ board to your computer using the included se rial cable. Makesure AsmIDE is running, and the that Terminal window is active. Power up the MiniDRAGON+board. You should see the following in the Terminal window:D-Bug12 4.0.0b29Copyright 1996-2005 Freescale SemiconductorFor Commands type "Help"• Use the MM com mand to put 0x55 into memory location 0x2000 and 0xAA into memorylocation 0x2001. Use the MD command to verify that this was done.• Use the MMW command to put 0x55 into memory location 0x2100 and 0xAA into memorylocation 0x2101. Use the MD command to verify that this was done.• Use the BF command to load 0x55 into memory locations 0x2800 to 0x2FFF. Use the MDcommand to verify that it worked.• Use the ASM 1000 command to enter the following simple program at address 0x1000. (Whatdoes this program do?)clraclrbincaincbabaswi• Use the RM command to change the value of the Program Counter to 0x1000, the address ofthe first instruction of the simple program.4EE 308 Lab 1 Spring 2006• Use the Trace T to trace (single step through) the first four


View Full Document

NMT EE 308 - EE 308 – LAB 1

Documents in this Course
Load more
Download EE 308 – LAB 1
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 EE 308 – LAB 1 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 EE 308 – LAB 1 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?