Sunteți pe pagina 1din 6

ICT1003 Computer Organisation & Architecture

Lab 2 Manual

1. Equipment

 MSP-EXP430F5529LP Launchpad Board


 USB Cable (A-Male plug to Micro-B-Male plug)
 Computer/Notebook with Windows 7 or better
 Code Composer Studio (CCS) Version 6 or above (Free – Code Size Limited)

2. Learning Objective

This lab provides exercises that would allow the student to be familiar with the Instruction Set
Architecture of the MSP430. Exercises will cover topics in number representation, memory
storage organisation, machine code and the status flags of the MSP430 CPU.

After this lab session, the student should be able to:


 Understand how various data types are organised and stored in the memory
 Perform translation between Machine Codes and Mnemonic Assembly Instructions
 Understand how data movement and arithmetic operations affects the status flags (N,
Z, V, C)
 Write simple assembly instructions to validate a subset of questions from the ICT1003
tutorials

IMPORTANT
This lab has been intentionally designed to increase the amount of independent
actions/thought required as the tasks progresses. Thus, step-by-step instructions will become
less detailed as the tasks progresses.

3. References

For this lab, you will require the following documents that can be downloaded from the
ICT1003 LMS website under the Content Browser  Resources/Reference Manuals tab:
i) MSP430 Quick Reference Guide
ii) MSP430 Instruction Set Summary

The above documents will provide a good overview on the various assembly instructions
supported by the MSP430 and their machine code representation. You will also require the
question sheet from Tutorial 2 and your solutions to these questions as reference.

4. Overview of lab session

This lab session will be conducted over 2 hours. It assumes that you have already
successfully completed Lab 1.

For this lab, students should ideally explore independently but may also interact with their
fellow classmates to explore and have fun together.

Page 1 of 6
ICT1003 (Lab2) V1.1, Steven Wong, 2016
THERE IS A QUIZ for this lab. This 10-min lab quiz that will be
conducted 15-mins before the lab session ends.
The exercises in this lab session can be divided into the following parts:
(a) Number representation in the MSP430
(b) Data storage and memory organisation
(c) Machine code translation
(d) CPU status flags

5. The Exercises

5.1. Number Representation

5.1.1. Create a blank assembly project


 You would have learnt how to do all the items stated in this section during Lab 1.
 Create a new project and name it “Lab2_1”. Remember that you are working on a
MSP430F5529 CPU.
 Fix the memory issue in the file “lnk_msp430f5529”. (Refer to Lab 1)
 Resolve the entry point issues if any. (Refer to Lab 1)
 Make sure that you MSP-EXP430F5529 Launchpad is connected to the computer

5.1.2. Pre-exercise task


TASK 1
Without using code composer, manually determine the values of the various registers after
the execution of the respective instructions.
a) mov.b # -1, R5 R5 = ___________

b) mov.w # -1, R6 R6 = ___________

c) mov.w # -1234, R7 R7 = ___________

d) mov.w # -1234h, R8 R8 = ___________

e) mov.w # 'ABC', R9 R9 = ___________

5.1.3. Using code composer to validate your answers


 You can now write the above instructions into main.asm as shown in Figure 5.1.3a.
 Build your codes and resolve any errors.
 Make the “Register” window visible by selecting View  Registers
 You should be able to see the “Registers” window as seen in Figure 5.1.3b

Page 2 of 6
ICT1003 (Lab2) V1.1, Steven Wong, 2016
 Click on “Core Registers” to view the contents of R0 – R15 (remember that R0 =PC,
etc)

TASK 2
Single step through the programme and validate your answers
obtained in Section 5.1.2.
If you got some answers wrong, figure out why.

Figure 5.1.3a

Figure 5.1.3b

Page 3 of 6
ICT1003 (Lab2) V1.1, Steven Wong, 2016
5.2. Data Storage and memory organisation

5.2.1. Create a blank assembly project


Create a new project and name it “Lab2_2”. By now, you should be able to do this with ease.
5.2.2. Pre-exercise task
TASK 3
Without using code composer, complete the byte-sized memory map after the execution of
the following instructions:

Address Contents
mov.b #01h, &2400h H’002405
mov.b #0Ah, &2401h H’002404
mov.w #1234h, &2402h H’002403
H’002402
mov.w #5678h, &2403h
H’002401
mov.w #9ABCh, &2404h
H’002400

5.2.3. Using code composer to validate your answers


 Enter the above instructions into the main.asm of your project. Build and execute it.
 Make the “Memory Browser” window is visible by selecting View  Memory Browser
 You should be able to see the “Memory Browser” window as seen in Figure 5.2.3a

TASK 4
Validate your memory-map in Section 5.2.2 using code composer!!!

Search for
address 0x2400

Select this style

You can see the memory


contents here. For example,
in this case, the byte at
location 0x2450 is 0xFD.

Figure 5.2.3a

Page 4 of 6
ICT1003 (Lab2) V1.1, Steven Wong, 2016
5.3. Machine Code Translation

5.3.1. Pre-exercise task


TASK 5
Without using code composer, translate the following assembly instructions into their
machine code equivalent (in hexadecimal). You may need to refer to the lecture notes and
the reference materials.
i) add.w R1, R2

Machine Code:__________________________ Number of bytes:_______

ii) mov.w #1234h, R1

Machine Code:__________________________ Number of bytes:_______

iii) sub.b #5566h, &3000h

Machine Code:__________________________ Number of bytes:_______

5.3.2. Using code composer to validate your answers


 Create a suitable assembly language project and insert the above instructions into
main.asm. Build and load the program to the debugger
 Make the “Disassembly” window visible by selecting View  Disassembly
 You should be able to see the “Memory Browser” window as seen in Figure 5.3.2a

Addr Machine Assembly


Code Instruction

Figure 5.3.2a

TASK 6
Validate your answers obtained in Section 5.3.1.

Page 5 of 6
ICT1003 (Lab2) V1.1, Steven Wong, 2016
5.4. CPU status flags

5.4.1. Viewing the CPU status flags in CCS


 You can view the status of the various status flags (N, Z, V, C) by using the “Register”
window.
 Select “SR” for the Status Register and details of the individual flags will be shown as
seen in Figure 5.4.1.

Figure 5.4.1

5.4.2. Validating your Tutorial 2 solutions using CCS


Using the MSP-EXP430F5529 Launchpad and CCS, you should be able to validate the
solutions for questions Q1a to Q1h from the ICT1003 Tutorial 2.

For example, to validate Q1a,


100110012 + 110000002

we execute the following instructions:

mov.b #10011001b, R5 ; Move value of 10011001b into R5


add.b #11000000b, R5 ; perform R5 = R5 + 11000000b (Q1a)

TASK 7
Validate your answers for Tutorial 2 Question Q1a – Q1h

5.5. Challenge – Machine Code to Assembly using CCS

TASK 8

Given a machine code of H’507500C0, use CCS to determine the mnemonic


assembly instruction.

-------------------End of Lab 2-------------------

Page 6 of 6
ICT1003 (Lab2) V1.1, Steven Wong, 2016

S-ar putea să vă placă și