0% found this document useful (0 votes)
49 views

Experiment #3: Thrsim11 Simulator

The document provides instructions for several experiments using the THRSim11 simulator and EVBplus2 board. It includes programs to multiply numbers, compute squares, display digits on a 7-segment display, blink LEDs, sort numbers, and compute square roots of values in memory.

Uploaded by

ventsym
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Experiment #3: Thrsim11 Simulator

The document provides instructions for several experiments using the THRSim11 simulator and EVBplus2 board. It includes programs to multiply numbers, compute squares, display digits on a 7-segment display, blink LEDs, sort numbers, and compute square roots of values in memory.

Uploaded by

ventsym
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Experiment #3

THRSim11 Simulator

1. Enter the following program into the THRSim11 Simulator.


Save the file containing the program in a file named
exp3_p1.asm. Make sure that the label “Loop” starts in the first
column of the file containing your assembly code. This program
is supposed to multiply the contents of accumulators A and B
and save the result in memory at location $0010.

ORG $C000
LDAA #12
LDB #08
MUL
STD #$10
Loop BRA lo0p

a. Assemble the program and note the errors. Correct your


program and save it. Assemble it again to make sure
there are no errors.
b. Now, employ the instruction set table for the 68HC11
and generate the machine code for the program.
c. Next, open a window showing the memory locations
starting at $C000 (open View>Memory>Memory List
and type $C000). Copy the machine code and compare
it to the machine code generated manually in Part (b).
d. Execute the program by stepping through the

instructions. Record the values of


the following registers after executing each instruction:
A, B, D, PC, CC. Before you proceed, make sure to
manually change the contents of these registers as
shown below:
e. Verify the result of the multiplication operation.

2. Verify the look-up table of squares program (listed below) using


the THRSim11 Simulator. Note that the simulator allows the
user to change the content of registers and memory while a
program is running on the simulator.

* Program to compute the square of a number 0-15


* Input is assumed to be placed at $0001
* Output goes to ACCA
ORG $C000
LDAB #$00
STAB $0000
loop LDX $0000
LDAA $96,X
BRA loop

ORG $96
FCB $00,$01,$04,$09,$10,$19,$24,$31,$40
FCB $51,$64,$79,$90,$A9,$C4,$E1
END

3. Verify the following program using THRSim11. This program


requires that you connect the virtual 7-segment display to
PORTB. This is automatically done by selecting “7-segment
display” from the menu Connect>7-Segment Displays.

* Programming Example 4 (Unit 2) Revisited


* Program intended to run on THRSim11
* It displays hex digits on a 7-segment display
* Display driven by PORTB ($1004)
pointer EQU $0000 initialization for X register
portb EQU $1004
finish EQU $0010
ORG $C000 starting address of program
restart LDX #pointer
loop LDAA $00,X
STAA portb
INX
CPX #finish
BEQ restart
JMP loop
ORG $0000
FCB $3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F
FCB $6F,$77,$7C,$39,$5E,$79,$71
END

When you run this program, you will notice that the 7-
segment display will flash too fast for the eye to see the
various digits. We can pause the execution by running the

simulator in the “Run Until” mode: . For this to


work, you must first choose the instruction you want to stop
at. You can do that by left clicking the mouse at the
instruction of interest inside the LIST window, as shown in
the screenshot below (INX is highlighted).
EVBplus2

1. The following program delays for 10 seconds (Refer to


Programming Example 4):

LDAA #60
loop1 LDX #55554
loop2 DEX
BNE loop2
DECA
BNE loop1

The following is a modified program that utilizes the MSB


LED of output PORTB to turn on for 10 seconds. Download
this program onto the EVBplus2 and run it. Time the LED
and verify that it is turned on for precisely 10 seconds.

portb EQU $1004


ORG $C000
LDAB #$80
STAB portb
LDAA #60
loop1 LDX #55554
loop2 DEX
BNE loop2
DECA
BNE loop1
CLR portb
BRA *
END

Modify the above program so it continuously blinks all


PORTB LED’s every 2 second (i.e., LED’s are ON for 1
second and then OFF for one second).

2. Modify the squares program in Problem 2 above (AND


SAVE IT IN A FILE WITH A NEW NAME) assuming that
the list of squares has already been saved in the on-chip
EEPROM at locations $B600-B60F. Verify your program on
the EVBplus2. Note: EEPROM content can be modified by
using the THRSim11 to manually edit the target’s memory
window locations $B600-B60F (the ORG $B600 followed by
FCB $00,$01,$04 … in the assembly program would not work
in this case.) Make sure that you view the Target register and
memory windows (with the blue background, not white) as
you verify your program. Also, terminate your program with
a SWI instruction (as opposed to BRA loop); this will allow
the simulator to display all EVBplus2 memory and register
content changes.

After verifying your program, disconnect power from the


EVBplus2. Now, power up the EVBplus2 and use the
simulator to confirm that the list is retained in the EEPROM,
as expected. Note: you need to reconnect to the EVBplus2
using the “Target Connect” option under the “Target” menu
before downloading the program to the board.

3. Modify Programming Example 3 (UNIT 3) so that it sorts


signed numbers. Run the program on the THRSim11
Simulator and on the EVBplus2. Convert the sorted (signed)
bytes to decimal and verify the consistency of the sorted list.

4. Write a program that overwrites the contents of memory


locations $0000 - $000A with their square roots. Download
your program to the EVBplus2 (starting at address $C000)
and verify its operation.

You might also like