EER-018
INTRODUCTION to DIGITAL COMPUTERS
LABORATORY NO. 7
INTRODUCTION to the ICS05J1A SIMULATOR

OBJECTIVES:

EQUIPMENT :

Gateway2000, RAPID Microcontroller Development System.

REFERENCES:

SIMPLE M68HC05 PROGRAM EXAMPLES:

Example 1.
       org rom    ;sets the starting address $0300 for the code that follows
start: lda #$10   ;loads the hex number 10 (decimal 16) into ACCA
       ldx #$11   ;loads the hex number 11 (decimal 17) into the index register X
       mul        ;multiplies the contents of ACCA by the contents of X.
                  ;After the operation,X contains the upper 8 bits of the
                  ;16-bit result and ACCA contains the lower 8 bits
       stop
       org $7FE   ;sets the address $07FE for the object code that follows
back1: fdb start  ;forms double byte address constant start that defines
                  ;where the program counter begins on reset

After this program executes,  X and ACCA together contain the hexadecimal number 110 (decimal 272).

Example 2.
temp1  equ $C0    ;one byte temp storage location
       org rom    ;program will start at $0300
start: lda #$D    ;loads the hexadecimal number D (decimal 13) into
                  ;the accumulator ACCA
       sta temp1  ;stores the contents of ACCA (hex D (decimal 13)) in
                  ;temp1 (the address  )
       lda #$20   ;loads the hexadecimal number 20 (decimal 32) into ACCA
       sub temp1  ;subtracts the contents of temp1 from ACCA and places
                  ;the result in ACCA
       stop
            org $7FE   ;sets the address $07FE for the object code that follows
back1: fdb start  ;forms double byte address constant start that defines
                  ;where the program counter begins on reset

After executing this program,  ACCA contains the hexadecimal number 13 (decimal 19).

Example 3.
temp1  equ $C0    ;one byte temp storage location
temp2  equ $C1    ;one byte temp storage location
       org rom    ;program will start at $0300
start: lda #$5    ;loads the hexadecimal number 5 (decimal 5) into ACCA
       sta temp1  ;stores the contents of ACCA (the hexadecimal number 5
                  ;(decimal 5)) in temp1 (the address $C0)
       lda #$2    ;loads the hexadecimal number 2 (decimal 2) into ACCA
       sta temp2  ;stores the contents of ACCA (the hexadecimal number 2
                  ;(decimal 2)) in temp2 (the address $C1 )
       lda #$1    ;loads the hex number 1 (decimal 1) into ACCA
loop1: ldx temp2  ;loads the hex number 2 (decimal 2) into index register X
       mul        ;multiplies the contents of ACCA by the contents of X.
                  ;After the operation, X contains the upper 8 bits of the
                  ;16-bit result and ACCA contains the lower 8 bits 
       dec temp1  ;subtracts one from the contents of temp1
       bne loop1  ;the branch (jump to the label loop1) will occur if the
                  ;contents of temp1 is not equal to 0
       stop       ;stop oscillator of the microcontroller
       org $7FE   ;sets the address $07FE for the object code that follows
back1: fdb start  ;forms double byte address constant start

After executing this example ACCA and X contain the hexadecimal number 80 (decimal 128).

PRELAB:

Using the above examples as a guide, develop the following programs:

Program 1.
Multiply $4 by $5 and put the result at address  (see Example 1 and Example 2).
Program 2.
Calculate the following value: 26 + 3 using a loop (see Example 3).

Be sure to add comments to your programs.
PROCEDURE:
A.
How to prepare and run a program.

Use the program given in Example 2.
B.
How to set break points.

Setting break points forces the execution of the program to stop and control to return to the monitor program. You can check the intermediate results of an operation.
Example 4.
Suppose that after you run the program of Example 2 you would like to check the result of the program after the instruction lda #$20 is executed. You can do it using the following steps:
C.
How to trace through a program.

Instead of using break points, you can trace a program, executing one instruction at a time, using the command t. Type t after prompt > in Debug Window (Debug F10, Fig. 1) and press Enter. The command  means ``execute n assembly instructions'''.
 
D.
Run the program from Example 3.

Enter and run the program from Example 3, using the command g and check the final result. Trace this program and record the intermediate results after the instruction mul. Repeat these results using the command  (n=1,2,...,7).
 
E.
Run your prelab programs.

Enter and run your prelab programs, using the command g and check the final result. For program 3, use Trace these programs and record the intermediate results. Repeat these tests using the command br with corresponding address and the value of n
 
F.
Program 3. Write a program to calculate the equation F = X*$5 + Y*$9, where X and Y are stored in locations $C0 and $C1 and F is stored in location $C2. Test this program for the following values of X and Y.
X Y F
0 $0F            
$0C $00     
$12 $02
$05 $0A
 

G.    Print your programs.

Open the ``notepad'' application and open the .asm file that you created in
C:\ICS05J1A\
Use the print command in the notepad application to print the file.
 
H.
Save your programs.

Save your programs on your disk or email or ftp them to your idol account (ASCII mode).
THE REPORT SHOULD INCLUDE:


Cherrice Traver

Fall 2004