68000 Assembly Language Programming Lab: Solving Specific Problems, Lab Reports of Computer Science

A lab guide for students to learn 68000 assembly language programming. It includes an introduction to the lab, materials required, a sample problem solution, and procedures for debugging and programming. Students will write, assemble, execute, and debug assembly language programs to solve defined problems.

Typology: Lab Reports

Pre 2010

Uploaded on 10/01/2009

koofers-user-x3o
koofers-user-x3o 🇺🇸

5

(1)

10 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
39
Lab #5
Programming Problems
PURPOSE
This lab is an introduction to 68000 assembly language programming. Students will write,
assemble, download, execute, debug, and demonstrate assembly language problems that
solve specific yet simple programming problems. Concepts from the previous labs are
used extensively.
Upon completing this lab, students will be able to do the following:
Write, test, and debug 68000 assembly language programs to solve defined problems
in data computation, manipulation, or conversion.
PREPARATION
Prior to the scheduled lab session, read the following chapter from your textbook:
Chapter 5 (Programming Examples)
MATERIALS
Hardware:
68KMB 68000-based computer
PC host computer
RS232C serial interface cable
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download 68000 Assembly Language Programming Lab: Solving Specific Problems and more Lab Reports Computer Science in PDF only on Docsity!

Lab

Programming Problems

PURPOSE

This lab is an introduction to 68000 assembly language programming. Students will write, assemble, download, execute, debug, and demonstrate assembly language problems that solve specific yet simple programming problems. Concepts from the previous labs are used extensively.

Upon completing this lab, students will be able to do the following:

  • Write, test, and debug 68000 assembly language programs to solve defined problems in data computation, manipulation, or conversion.

PREPARATION

Prior to the scheduled lab session, read the following chapter from your textbook:

  • Chapter 5 (Programming Examples)

MATERIALS

Hardware:

  • 68KMB 68000-based computer
  • PC host computer
  • RS232C serial interface cable

MS-DOS Software:

  • A68K 68000 cross assembler
  • XLINK 68000 linker, locator, conversion utility
  • PC-VT VT100 terminal emulator
  • EDIT MS-DOS text editor (or equivalent)

68000 Programs:

  • EXAMPLE provided (to be entered)
  • SHIFT32 to be written
  • LENSTR to be written
  • SAME to be written
  • HEXCHAR to be written
  • LOOKUP to be written

INTRODUCTION

The following programming example demonstrates how problems are stated in this lab.

Problem: Write a 68000 program called EXAMPLE to compute the sum of three 16- bit words of data. The data are stored in memory starting at address $9000, identified by the label NUMBERS. Store the result immediately after the data, in SUM at memory location $9006.

Sample Conditions:

Before:

Address Contents 009000 1234 009002 5678 009004 0ABC 009006 0000

After:

Address Contents 009000 1234 009002 5678 009004 0ABC 009006 7368 Note: $1234 + $5678 + $0ABC = $

PROCEDURE

Part I: Debugging

  1. Work through the solution to the example problem by hand and complete the table below. If you are not sure of the precise operation of any instruction, consult Appendix B of your textbook. (As consistent with MON68K's trace facility, the first column shows the PC value after each instruction executes.)

Instruction CCR PC Just Finished X N Z V C A0 D0 D

8006

MOVEA.L #NUMBERS,A

  1. Enter the example problem in a file called EXAMPLE.SRC. Assemble the program and convert the object output file to S-records. Begin execution of PC-VT and transfer the program to the 68KMB.

Use MON68K's single-step facility (described in lab #3) to verify your work above. If you completed the table without any errors, congratulations: You are ready to undertake problems in assembly language programming. Ask your lab instructor for assistance if you have trouble determining the correct conditions after any instruction.

Problem 2: Write a program called LENSTR to determine the length of a string of characters. The starting address of the string is contained in the 32-bit variable START at location $9000. The end of the string is marked by an ASCII null character. Place the length of the string (excluding the null character) in the variable LENGTH at location $9004.

Sample Conditions:

Before:

Address Contents 009000 0000 009002 9040 009004 5555 009040 4142 009042 4344 009044 4546 009046 4748 009048 00FF

After:

Address Contents 009004 0008

Note: Place the ASCII string in your program by enclosing the characters within single quotes after a DC.B directive.

Problem 3: Write a program called SAME to compare two strings of ASCII characters to see if they are the same. The starting addresses are contained in the longword variables START1 at location $9000 and START2 at location $9004. The first byte of each string contains the string length (in bytes) and is followed by the string. If the two strings match, clear the variable MATCH at location $9008; otherwise set its value to -1.

Sample Conditions:

Before:

Address Contents 009000 0000 009002 9040 009004 0000 009006 9050 009008 5555 009040 0441 009042 4243 009044 44FF 009050 0441 009052 4244 009054 5FDD

After:

009008 FFFF = -1 (Strings are different!)

Note: Test your program with several different string conditions. Place strings in your program in the appropriate way.

Problem 5: Write a program called LOOKUP to convert the contents of the BCD variable DIGIT at location $9000 to a seven-segment code and store it in the variable CODE at location $9001. If DIGIT does not contain a single BCD digit, clear CODE. Assume a standard segment arrangement (e.g., 74LS47) with segment a as bit 0 and segment g as bit 6 (bit 7 = 0, always). This is shown below. Assume a segment is ON for a 1 and OFF for a 0. Hint: begin by constructing a table of BCD-to-CODE mappings.

a

g

b

c d

e

f

Sample Conditions:

Before:

Address Contents 009000 0400

After:

009000 0466

Note: Verify that your program works for any value from 0 to F.

CONCLUSION

Having completed this lab, students are capable of writing small 68000 programs in assembly language.