EE 308 -- LAB 2
Further Use of SIM11 and the EVBU

This laboratory will give you more experience with the tools we will use in this lab.

  1. Consider the following program for the 68HC11:
            .area CODE (ABS)
            .org    0x0100
            ldaa    #12
            ldab    #195
            std     *0x10

    Do (a), (b) and (c) before coming to lab.

    1. Hand-assemble this program. I.e., determine the op-codes the HC11 will use to execute this program.
    2. How many instruction cycles will it take the HC11 to execute this program? How long will this take on the HC11? (Do not consider the swi instruction.)
    3. What will be in address 0x0010 after the program executes?
    4. Assemble the program using as6811 and aslink. Look at the S19 file. You should be able to relate the op-codes from part (a) to the data in the S19 file. Appendix A of the M68HC11EVBU User's Manual describes the format of the S19 file.
    5. Trace through the program using SIM11. The RUN window in SIM11 shows how many cycles it takes to execute the instructions. Compare this to the answer of part (b).
    6. Look at the contents of address 0x0010. Does the value agree with your answer of part (c)?
    7. You could change this program to subtract rather than add by changing the aba instruction to a sba instruction. Rather than going back to the text editor, modifying the program, assembling it and loading the new program into the simulator, you can easily change the one instruction of the simulator.
      1. Find the address of the aba instruction. Do this by looking at the program code in the ASSEMBLE window of the simulator.
      2. Change the instruction by first typing ASM addr where addr is the address of the aba instruction. Then enter the new instruction (sba). Do this in the DEBUG window.
      3. Run the program again, and verify that the program now subtracts rather than adds.
    8. Repeat (e) through (g) on your EVBU. For part (g), use the ASM command of BUFFALO to look at and change the program code on the EVBU.

  2. Consider the program in Figure 1, which is just the program from Lab 1, modified to divide a table of ten values.


    ; 68HC11 demo program
    ; Bill Rison
    ; 1/2/96
    ; This is a program to take a table of data, and create a new table
    ; which is the original table divided by 2
             .title  LAB 1 Demo Program
    EVBRAM   =  0x0000        ;0x0000 is start of user ram on 68HC11EVBU
    PROG     =  EVBRAM+0x100  ;start program above BUFFALO
    COUNT    =  10            ;number of entries in table
             .area   CODE  (ABS)
             .org    PROG     ;set program counter to 0x0100
             ldab    #COUNT   ;ACC B holds number of entries left to process
             ldx     #table1  ;Reg X points to entry to process 
    repeat:  ldaa    0,x      ;Get table1 entry into ACC A
             asra             ;Divide by 2
             staa    COUNT,x  ;Save in table2
             inx              ;REG X points to next entry in table1
             decb             ;Decrement number left to process
             bne     repeat   ;If not done, process next table1 entry
             swi              ;Done -- Exit
             .area   DATA  (ABS)
             .org    DATARAM
    ;initialize table1 (COUNT bytes long)
    table1:  .db     0x07,0xae,0x4a,0xf3,0x6c,0x30,0x7f,0x12,0x67,0xcf
    table2:  .ds     COUNT    ;reserve COUNT bytes for table2.

    Figure 1: Demo program for Part 2 of Lab 2

    1. Use a text editor to enter this program, or download it from here . Assemble the program into an S19 file.
    2. Load the program into the simulator. Run the program. How many cycles does it take to execute the entire program? How long would this take on the EVBU?
    3. Use the BF instruction of the simulator to change the values in addresses 0x0000 through 0x0020 to 0xFF. Reload the S19 file.
    4. Set a break point at repeat.
    5. Execute the program again. The program should stop the first time it reaches the repeat label, with 0x0A in ACC B, and 0x0000 in X.
    6. Continue running the program. It should stop each time it gets to the repeat label -- B should be decremented by one, X should be incremented by one, and there should be a new entry in table2.
    7. Repeat the above using the EVBU.

  3. Consider the code of Figure 2. Do parts (a) and (b) below before coming to lab.


                            ldab    #100
                  loop1:    ldx     #33333
                  loop2:    dex
                            bne     loop2
                            bne     loop1

    Figure 2: Demo program for Part 3 of Lab 2

    1. How many cycles will it take to execute this program? How long will this take on the EVBU?
    2. Use a text editor to enter the code into a program -- you will have to add .org statements and other assembler directives to make the program work.
    3. Assemble the program and run it on the simulator. Determine the number of cycles it takes. This should match your answer to part (a).
    4. Run the program on the EVBU. How long does it take to run? This time should match your answer to part (a).

Bill Rison, < >
Fri Jan 24 1997

© 1997, New Mexico Tech