Docsity

Assembly Programming with Mini IDE – Assemble and Trace – Lab 1 | ECE 3120, Lab Reports of Microcomputers

Toggle sidebar
bg1
ECE 3120 - Spring 2008
Lab 1 – Assemble and Trace
ASSEMBLY PROGRAMMING WITH MINIIDE
The purpose of this lab is to introduce you to the layout and structure of assembly
language programs and their format, as well as to the use of the MiniIDE development
tool. You will write your own programs later on in the semester with similar structure.
In the following example source code, from left to right, you will notice four
columns. The first column contains label names. The second column contains
instruction/assembler keywords. The third column contains data or operands. The fourth
column is used for comments. Your programs should always be in this format.
INTRODUCTION TO MiniIDE
MiniIDE (a free program available on the Internet) is a windows based program,
which allows assembly programmer to assemble, debug, and download a program onto
the Dragon12 68HCS12 board. This lab familiarizes the student with all the steps
involved in loading, running, and debugging assembly language programs using
MiniIDE. The student will be required to understand and remember all the steps to
download and debug programs in future labs.
PROCEDURE:
I. USING MINIIDE
After logon in the CadLab, click on the start menu as follows:
Start Æ AllPrograms Æ Engineering Æ ECE CadLab Æ MGTEK MiniIDE
1. Click on the File Æ New. This opens a blank window where you will write your
program.
2. Type the following program into the edit window:
1/31/08 Page 1 of 6
pf3
pf4
pf5

Partial preview of the text

Download Assembly Programming with Mini IDE – Assemble and Trace – Lab 1 | ECE 3120 and more Lab Reports Microcomputers in PDF only on Docsity!

Lab 1 – Assemble and Trace

A S S E M B L Y P R O G R A M M I N G W I T H M I N I I D E

The purpose of this lab is to introduce you to the layout and structure of assembly language programs and their format, as well as to the use of the MiniIDE development tool. You will write your own programs later on in the semester with similar structure.

In the following example source code, from left to right, you will notice four columns. The first column contains label names. The second column contains instruction/assembler keywords. The third column contains data or operands. The fourth column is used for comments. Your programs should always be in this format.

I N T R O D U C T I O N T O MiniIDE

MiniIDE (a free program available on the Internet) is a windows based program, which allows assembly programmer to assemble, debug, and download a program onto the Dragon12 68HCS12 board. This lab familiarizes the student with all the steps involved in loading, running, and debugging assembly language programs using MiniIDE. The student will be required to understand and remember all the steps to download and debug programs in future labs.

P R O C E D U R E :

I. U S I N G M IN I IDE

After logon in the CadLab, click on the start menu as follows: Start Æ AllPrograms Æ Engineering Æ ECE CadLab Æ MGTEK MiniIDE

  1. Click on the File Æ New. This opens a blank window where you will write your program.
  2. Type the following program into the edit window:

Lab 1 – Assemble and Trace

;--------------------------------------- ;Lab# ;Assemble and Trace ;(Put your name and date here) ;--------------------------------------- org $1000 ;Memory data starts at address hex 1000 num_1 dc.b $6C ;Define Constant Byte with value hex 6C stored ; in memory at label num_ num_2 ds.b 1 ;Define Storage Byte to reserve ONE Memory Byte ; at label num_

data1 equ num_1 ;Symbol data1 equals num_1 (hex 6C) num equ $72 ;Symbol num equals value hex 72

org $1100 ;Start program at memory location hex 1100 LDAA #num ;Load the value of symbol NUM into Accumulator A LDX #data1 ;Load register X with the value of symbol data LDAB $0,X ;Load Accumulator B with content of memory ; location pointed to by register X plus 0 STAB num_2 ;Store the content of Accumulator B into mem ; location num_ STAA num_1 ;Store the content of Accumulator A into mem ; location num_ ABA ;Add the content of A & B and store result in A LDX #255 ;Load reg X with decimal value 255 EXG D,X ;Exchange registers D and X SWI ;Software Interrupt Command. Makes the ; microcontroller Stop executing this program

  1. Save the program as Lab1.asm in your network directory.
  2. Make sure the options in MiniIDE are set properly. In the menu, select Build – Options and make sure only the following items are selected: Generate listing file, Used only, and Warning level 4.
  3. Click on the Build Current button on the task bar (or menu: Build – Build Current ). This will assemble your source code and allow you to check whether or not your program has any syntax errors.
  4. In the Output window at the bottom of the screen, you should get the assembler’s message. If it says 0 errors detected, your program has been assembled successfully. If not, go back and check where the problem is and fix it.

Now you have assembled the program and created a lab1.s19 file (machine or object code) and a lab1.lst file (source/object listing). These files are located in the same directory as your Lab1.asm file. The object code is what you will download onto the Dragon12 board’s memory next. The listing file is a text file that is helpful in debugging the program.

_Approved: Lab TA _____________________ Date _____________

Lab 1 – Assemble and Trace

A B X N Z V C

Table 1

_Approved: Lab TA _____________________ Date _____________

III. U S I N G T H E D-B UG 12 M O N IT O R C O MM A N D S

This section will provide a walk-through of important and useful D-BUG commands. When finished executing this section, copy the terminal window output and paste it into a Word document as shown by the TA for inclusion in the report.

  1. Hit the RESET button on the 68HCS12 board. Make sure the terminal window is still activated. If not, follow the instructions in part II, step 1.
  2. In the Terminal Window type bf 2000 2200 0 and press Enter. This has block filled all memory locations from $2000 to $2200 with zeroes. To view this change, type md 2000 2200 followed by Enter. The memory contents from $2000 to $2200 are displayed on screen, and all should be filled with zeroes. md stands for “memory display”.

Note: Everything entered and displayed in D-Bug12 Monitor is in HEX, whether or not you enter the $. Each memory display line holds the 16 byte block associated with the beginning address. For example the $2200 block displays locations $2200 - $220F on one line. Using the command md $220A will display the entire 16 byte block associated with it; therefore it will display $2200 - $220F.

  1. Now let’s look at modifying memory contents from the terminal window.

Type mm 2110 then press Enter.

Make the following addresses hold these values by typing in the value corresponding to the memory location and pressing Enter at the end of each line (note that the 21xx will be displayed as a prompt):

Lab 1 – Assemble and Trace

2111 9A

Then press Enter. You will see the results of changing $2113 to $12.

Press Enter, type 55 ^ Press Enter, type 44. Press Enter Finally, display the memory contents of $2110 using md 2110 and press Enter. Record the final values below (assume these are hex values):

2110 _____________ 2111 _____________ 2112 _____________ 2113 _____________

  1. To modify the registers, type the register name, space, the value, and then press Enter. Type these examples:

A 99 B EB X 569A

_Approved: Lab TA _____________________ Date _____________