DOC PREVIEW
NMT EE 308 - EE 308 – LAB 1

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

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 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 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

EE 308 Lab 1 Spring 2003EE 308 – LAB 1ASSEMBLER, SIMULATOR, AND MONITORIntroduction and ObjectivesThis laboratory introduces you to the following 68HC12 assembly language programming tools:• The 68HC12 assembler CA6812. This runs on the PC.• The 68HC12 simulator ZAP. This also runs on the PC.• The D-Bug 12 monitor that runs on the 68HC12.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 storesthem in a .s19 file which the 68HC12 m onitor program can understand. In this lab we will usethe Cosmic Software CA6812 assembler, which is on the PCs in the Digital/Microcontrollers lab.This is copyrighted software which is licensed for use on our lab computers only. There is a demoversion of this assembler (as well as the Cosmic C compiler and the ZAP simulator) are availablefrom Cosmic at http://www.cosmic-us.com/hc12_des.html. It should be adequate for most ofthe labs in this course.The Cosmic CA6812 assembler produces an output file with a .h12 extension which the ZAPsimulator uses. It also produces an output file with a .s19 extension which can be loaded into andrun on the 68HC12. The D-Bug 12 monitor, running from HC12 EPROM, loads S19 records intothe HC12 and provides some tools for debugging loaded programs.The ZAP simulator simulates the operation of the 68HC12 on a computer. This has twoadvantages: you can try a program without having a 68HC12, and you can easily see information(such as register contents, number of cycles to com plete, etc.) which are difficult or impossible toobserve on an actual microcontroller. Again, the full ZAP simulator is a licensed program whichcannot be distributed, but the demo version will be adequate for most of the labs in this course.The relationship between these various programs is illustrated in Figure 1.CA6812D−Bug 12ZAPlab01.slab01.h12lab01.s19Figure 1: The relationship between CA6812, ZAP, and D-Bug 12.1EE 308 Lab 1 Spring 2003Pre-LabYou should read this entire lab before coming to lab, and answer all of the questions in thepre-lab se ction before coming to lab.The D-Bug 12 monitor allows you to interact with the HC12 microcontroller. You can use itto load programs, to find out what is in the HC12’s registers and memory, to change the contentsthe registers and memory, and many other things. The D-Bug 12 commands of interest for thislab are: ASM, BF, BR, NOBR, G, HELP, LOAD, MD, MDW, MM, MMW, RM, RD, and T. Read the descriptions ofthese commands in Chapter 5 of the D-Bug 12 Reference Gui de.Questions to answer before lab:• What is the difference between the MM and MMW commands?• How would you change the value of the B accumulator to 0x55? (There are several ways todo this; you only need to find one way.)Assembly language is used to write programs for the HC12. An assembly language instructionwill be converted by the assembler into a single machine instruction for the HC12. The assemblylanguage commands of interest to us for this lab are: LDAA, STAA, TAB, ABA, and ASRA. Read thedescriptions of these commands in the 68HC12 CPU12 Core Users Guide. At this point youwill not understand everything the guide says about these instructions, but you should understandenough to get you through this lab.Figure 2 is a simple program for the HC12. We will use it to illustrate how to use the assembler,the simulator and D-Bug 12. Note: We will always use the SWI instruction to end a program. Thisinstruction will transfer control the the HC12 from the program to the D-Bug 12 monitor.2EE 308 Lab 1 Spring 2003; 68HC12 demo program; Bill Rison; 1/15/03; This is a program to divide and multiply a number by two,; and store the results in memorytitle "LAB 1 Demo Program"evbram: equ $1000 ;0x1000 is start of user ram on 68HC12prog: equ evbram ;Start program at beginning of RAMdata: equ evbram+$1000 ;Memory area for dataCODE: section .text ;The stuff which follows is program codeorg prog ;set program counter to 0x1000ldaa input ;Get input data into ACC Aasra ;Divide by 2staa result ;Save the resultldaa input ;Get input data into ACCAtab ;Put the same number into ACCBaba ;Add the number to itself (multiply by two)staa result+1 ;Save the resultswi ;End program (return to D-Bug 12 monitor)DATA: section .data ;The stuff which follows is dataorg datainput: dc.b $07 ;first input dataresult: ds.b 2 ;reserve two bytes for resultsFigure 2: An assembly language program used to get started with the CA6812, ZAP, and D-Bug 12.Question to answer before lab: What are the contents of the A register after each instruc-tion of the program shown in Figure 2 executes?We will use D-Bug 12 to explore the memory of the HC12 on your evaluation board. Thememory map for your 68HC12 is shown on page 24 of the MC9S12DP256B Devi ce UsersGuide. (Look the the figure labeled “Normal Single Chip”.) Much of the memory is used by theD-Bug 12 monitor. For this class you can use RAM from 0x1000 to 0x2FFF, and EEPROM from0x0400 to 0x0FFF.Use a text editor to enter the program shown in Figure 2 before coming to lab and save itunder the name lab01.s. (You can also use a web browswer to download the program.)Also create the file lab01.lkf which contains the following lines:3EE 308 Lab 1 Spring 2003# Link file for program lab01.s+seg .text -b 0x1000 -n .text # program start address+seg .data -b 0x2000 -n .data # data start addresslab01.o # application programTo ass emble the program open a COMMAND window. (One way to do this is to go to START, theRUN, and e nter the program name CMD.) You can assemble the program using the ca6812 assemblerwith the commands:> c:\cx32\ca6812 -a -l -xx -pl lab01.s> c:\cx32\clnk -o lab01.h12 -m lab01.map lab01.lkf> c:\cx32\chex -o lab01.s19 lab01.h12(Note: If you use the demo version of the compiler, you will need to use a different path tothe assembler: instead of using c:\cx32\, you will need to use c:\cosmic\eval12\. Also, you cansave typing by using a batch file to exe cute these commands. To do this, follow the instructions atthe e nd of the lab.)The ca6812 command will create a file called lab01.o which contains the machine codes in aspecial form which other programs can read. It also creates the file lab01.ls which shows what opcodes were generated by the assembler. The clnk command will translate the lab01.o file into aform which the ZAP simulator can understand. It also creates a file lab01.map which shows wherein memory


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?