EE 308 - LAB 1

Final version for 2001


ASSEMBLER, SIMULATOR, AND MONITOR

Introduction and Objectives

This laboratory introduces you to the following 68HC12 assembly language programming tools:

An assembler takes assembly language code in a form that a human can reasonably read with a little practice, translates it to machine codes which a microprocessor can understand. and stores them in a .s19 file which the 68HC12 microcontroller can understand. In this lab we will use the 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 demo version of this assembler (as well as the Cosmic C compiler) available. It should be adequate for most of the labs in this course. Information about how to obtain this demo assembler and compiler will be posted on the EE 308 web page. In your HC12 kit you received a copy of the P&E Microsystems IASM12 assembler. You may put this assembler on your own PC, and may put it in your directory on the EE computer system. Using this assembler you can do much of the assembly language programming at home. IASM12 is similar to the Cosmic assembler we will use in lab.

The Cosmic CA6812 assembler produces an output file with a .h12 extension which the ZAP simulator uses. It also produces an output file with a .s19 extension which can be loaded into and run on the 68HC12. The D-Bug 12 monitor, running from HC12 EPROM, loads S19 records into the HC12 and provides some tools for debugging loaded programs.

The ZAP simulator simulates the operation of the 68HC12 on a computer. This has two advantages: you can try a program without having a 68HC12, and you can easily see information (such as register contents, number of cycles to complete, etc.) which are difficult or impossible to observe on an actual microcontroller. Again, the full ZAP simulator is a licensed program which cannot be distributed, but we have a demo version of the simulator which will be adequate for most of the labs in this course.

The relationship between these various programs is illustrated in Figure 1.


  
\begin{figure}
\epsfig{file=lab01_fig1.eps,width=5in}\end{figure}
Figure 1: The relationship between CA6812, ZAP, and D-Bug 12.

Pre-Lab

You should read this entire lab before coming to lab, and answer all of the questions in the pre-lab section before coming to lab.

The D-Bug 12 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 3 of the M68EVB912B32 Evaluation Board User's Manual.

Questions to answer before lab:

The assembly language commands of interest are: LDAA, STAA, TAB, ABA, and ASRA. Read the descriptions of these commands in the 68HC12 CPU12 Reference Manual. At this point you will not understand everything the reference manual says about these instructions, but you should understand enough 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.

; 68HC12 demo program
; Bill Rison
; 1/22/99

; This is a program to divide and multiply a number by two, 
; and store the results in memory

         title   "LAB 1 Demo Program"

evbram:  equ     $0800        ;0x0800 is start of user ram on 68HC12
prog:    equ     evbram       ;start program at beginning of RAM
data:    equ     evbram+$0100 ;

CODE:    section .text    ;The stuff which follows is program code
         org     prog     ;set program counter to 0x0800
         ldaa    input    ;Get input data into ACC A
         asra             ;Divide by 2
         staa    result   ;Save the result
         ldaa    input    ;Get input data into ACCA
         tab              ;Put the same number into ACCB
         aba              ;Add the number to itself (multiply by two)
         staa    result+1 ;Save the result
         swi              ;End program (return to monitor in HC12)



DATA:    section .data    ;The stuff which follows is data
         org     data
input:   dc.b    $19      ;first input data
result:  ds.b    2        ;reserve two bytes for results


  
Figure 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 instruction of the program shown in Figure 2 executes?

We will use D-Bug 12 to explore the memory of the HC12 on your EVBU. The memory map for your 68HC12 is shown on page 31 of the MC68HC912B32 Technical Summary. Most of this memory is used by the D-Bug 12 monitor. Page 3-55 of the M68EVB912B32 Evaluation Board User's Manual shows the memory available for your use.

Questions to answer before lab: