EE 308 -- LAB 1
Introduction and Objectives

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

The AS6811 assembler takes assembly language code in a form that a human can reasonably read with a little practice, translates it to machine codes, and stores them in a .s19 file which the 68HC11 microcontroller can understand. We have three assemblers available, ASM6811, IASM11 and AS11. The assemblers take slightly different forms of assembly language files. We will use the AS6811 assembler in this course; we can give you a copy of this assembler and its documentation for your personal computer. You can get it over the Internet at

The op-codes contained in the S19 records can either be run on the SIM11 simulator, or loaded into and run on the 68HC11. The BUFFALO monitor, running from HC11 EPROM, loads S19 records into the HC11 and provides some tools for debugging loaded programs. PCBUG11 performs the same functions as BUFFALO, but it runs partly on the PC and partly from HC11 RAM. PCBUG11 can be used to program HC11 chips that do not have BUFFALO in EPROM. BUFFALO, SIM11, and PCBUG11 all have very similar commands. We will not study PCBUG11 in this lab. (Note: SIM11 is a commercial program which we cannot distribute.)

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

Figure 1: The relationship between AS6811, SIM11, BUFFALO, and PCBUG11.


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. Also read Section 2.11 of the text.

The BUFFALO commands of interest for this lab are: BF, BR, G, HELP, LOAD, MD, MM, P, RM, and T. Read the descriptions of these commands in Chapter 4 of the M68HC11EVBU Universal Evaluation Board User's Manual.

Question to answer before lab: Do you need the T option to the LOAD command when using the EVBU?

The assembly language commands of interest are: LDA, STA, and ASR. Read the descriptions of these commands in the M68HC11 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.

Question to answer before lab: What are the contents of the A register after each instruction of the program shown in Figure 2 executes?


; 68HC11 demo program
; Bill Rison
; 1/13/98

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

         .title  LAB 1 Demo Program

evbram   =  0x0000        ;0x0000 is start of user ram on 68HC11EVBU
data     =  evbram
prog     =  evbram+0x100  ;start program above BUFFALO

         .area   CODE  (ABS)

         .org    prog     ;set program counter to 0x0100
         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              ;Done -- Exit

         .area   DATA  (ABS)

         .org    data
input:   .db     0x07     ;first input data
result:  .ds     2        ;reserve two bytes for results

Figure 2: An assembly language program used to get started with the AS6811, SIM11, and BUFFALO.

We will use BUFFALO to explore the memory of the HC11 on your EVBU. Memory maps are shown on pages 4-4 and 4-5 of the M68HC11 E Series Technical Data Manual.

Question to answer before lab: Which of these maps applies to the HC11 on your EVBU?

If you have a PC at home, type the program shown in Figure 2 before coming to lab and save it under the name lab01.s.

You can assemble it at home, using the AS6811 assembler with the commands

> as6811 -l lab01.s
> aslink -o lab01.s19 lab01.o

The as6811 command will create a file called lab01.o which contains the machine codes in a special form which other programs can read. The -l option to the as6811 command tells the assembler to create a listing file lab01.lst which shows the machine codes in a form humans can read. The aslink command will translate the lab01.o file into a form which microcontrollers can understand. The -o lab01.s19 option to aslink tells the linker to create a .s19 file. (The linker can also generate a .ihx file, which is the form used by Intel microprocessors. We will not use the Intel file format in this course.)

Bring a disk with the program on it to the lab.

As you gain experience you will operate independently in the lab. However, for the first few labs you should be pestering the lab assistants to distraction to make sure you get everything that you can from the time in the lab. We are there to help. Your part is to take the pre-lab seriously and show up for the lab session prepared.

The Lab

Create a directory for this course (say, D:\EE308). Inside this directory create a subdirectory for this lab (say, D:\EE308\LAB01). Change to this subdirectory, type in the lab01.s program, and assemble it with the commands

> as6811 -l lab01.s
> aslink -o lab01.s19 lab01.o

Some questions on the output of the assembler:

  1. Look at the lab01.lst file. Where will the machine code for the instruction staa result be stored in the HC11?
  2. What machine code is generated for the staa result mnemonic? Is this what you expected? (Look up the STA instruction in your M68HC11 Reference Manual to determine what code this instruction should generate.)
  3. At what address will result be located in the HC11 memory?

Start the SIM11 simulator. Open a DOS window. Inside this window change to your LAB01 directory, and invoke the simulator by typing SIM11.

Once you are in the simulator, load the .s19 file using

> load lab01.s19

Note that the program counter is not initialized. Type

> PC=0100

to initialize it to 0x0100, the start of our sample program. We are concerned with the DEBUG, CPU, CODE, and MEMORY windows. Observe that your program has appeared in the CODE window, and that the registers are in the CPU window. Trace, or single step, through your program using the T command and observe what is going on in the CODE and CPU windows.

When you are done single stepping, reset the program counter to 0x0100 and execute the entire program using the G command. Check that you have the expected values in result and result + 1 after the program finishes..

Change the input data from 0x07 to 0xbd, and rerun the program. Check the results.

Some questions on the simulator:

  1. How do the contents of the A register compare to what you predicted in the Pre-Lab after the execution of each in instruction?
  2. What do the F1, F2, F3, and F10 commands do in the simulator?
  3. Change the contents of the B register to 0xAC. Change the contents of the A register to 0xDC. Set the stack pointer to 0x0047. Hint: How did you change the program counter?
  4. What is the relationship between the A, B and D registers? Set the D register to 0x0537 and observe what happens to A and B.
  5. How can you put 0x3421 in the X register? How can you verify the change took place? Do it to see if your ideas are correct.
  6. What do the three columns in the CODE window represent?
  7. Try out some BUFFALO style commands:
    1. Use MM to modify memory at location 0x0010 and location 0xD000. Set the contents of the memory in both locations to 0x37. Use QUIT to exit the MM sequence.
    2. Use MD to display memory and verify that your MM command worked.
  8. Reset the program counter to 0x0100 and rerun the program. Use the MD command to look at input and result. Is result equal to input/2? If not, why?

When you have finished exploring the simulator, type QUIT or EXIT.

To communicate with your HC11, first connect power and your PC's serial cable to your EVBU. (Ask one of your lab instructors for help the first time you do this.) Then double click on the HC11 Terminal icon (or the Terminal icon in the Accessories group if you are running Windows 3.1). Make sure the communications parameters are set to COM2, 9600 baud, 8 data bits, 1 stop bit, no parity and no flow control. Power up your EVBU and hit the reset button. You should see a line of text about BUFFALO, or you might see a help screen go by.

To download your program to your EVBU type LOAD T at the BUFFALO prompt. Then select the Transfers menu, Send Text File submenu, and select the file lab01.s19 to send. Wait for the HC11 to respond with done. You might have to push the Reset button to proceed.

Using your EVBU do the same things that you did on the simulator, and answer all of the questions from the simulator section that are applicable to the EVBU. In addition:

  1. Trying to do PC=0100 to reset the program counter did not work. What is the BUFFALO command that you need?
  2. Trying to modify the memory at 0xD000 did not work. Why not? Hint: This is a memory map question.
  3. Use the BF command to load zeros into memory locations 0x0100 to 0x0180. Use the MD command to verify that it worked.

Answer the following questions about the EVBU:

Bill Rison, < >
Tue Jan 13 1998

© 1998, New Mexico Tech