Lab 1

Introduction to Micro-computing

 

Before the Lab

These laboratories will introduce you to the basic concepts of microcomputing. Microcomputing systems span a vast range, from simple single-chip processors used to control appliances to 32-bit processors capable of outperforming a workstation PC.  It is however, somewhat reassuring that the fundamental ideas behind all of these units are about the same. Thus, by learning one microprocessor, you will be able to move to other units with relative ease. The tool that you will be using in these labs is the Axiom CMD-711EX (Axiom) single-board computer. It is a self-contained unit needing only a terminal for normal operation, although a host processor system--for editing, assembling and downloading your programs--will come in very handy, as you shall see later.  The Axiom boards use the MC68HC11, an 8-bit microcontroller, as their main processor unit.

You should read thoroughly the section on the HC11-VDK and the Axiom boards that describe their capabilities. Be sure to familiarize yourself with the commands that the BUFFALO monitor supports; you will use them for the remainder of the term.  Here are some useful facts before you start to write your programs:

·      Although the 68HC11 provides RAM at locations $0000-$FFFF, the monitor program uses most of this area for stacks and holding certain pointers. You probably should not plan on using this area unless you know exactly what is going on down there.

·        For the Axiom board there is a 52Kbyte usable user SRAM, which is split into different blocks in its memory space. See the documentation for further details.

·        Programs may be terminated by SWI($3F), which imitates a breakpoint; this prints the register contents and returns to the monitor. For the Axiom board, the END assembler directive may be used to terminate a program.

For your first microcomputer lab, you must write and encode (generate machine language) the programs yourselves. This will familiarize you thoroughly with the instruction set and addressing modes. The first programs are reasonably simple, for your convenience.  Later, the programs will get more challenging, but you will have a host system on which to do editing and downloading (Lab #2).

You should first review the simple addition program offered in the “In the Lab” section.  Note the format of how it is written: successive columns for address, code, label field, instruction, arguments, and comments.  This is fairly standard form for assembler programs you will be using later, so use this form for all programs to get accustomed to it.

Now write the following programs:

  1. Fill the second page of user memory ($C100-$C1FF) with values indicating the extended address of the even locations of the third page (i.e., $C100-$C101 contains $C2 00, $C102-$C103 contains $C2 02, etc.).  Some useful instructions include STX and ABX.  Note that this and subsequent programs must reside outside the second and third pages of user RAM.

  2. Move the page you have filled from $C100-C1FF to $C200-C2FF.  Other useful instructions might include LDD and STD or PSHX and PULX (If you are using the stack, don’t forget to initialize the stack pointer).

  3. Study the section titled “Utility Subroutines” to get the address of the subroutine to be used to output a string to the terminal screen. Write a program, called PDATA that prints your name to the screen.  In order to do this you must use an ASCII table to encode the letters of your name.  A conversion chart is available in the HC11 Programming Guide. Index register X should point to the ASCII string and the string should be terminated with $04.

In the Lab

We will begin with a simple exercise to familiarize you with the features of the Axiom CMD-711EX board and its BUFFALO (Bit User Fast Friendly Aid to Logical Operations) debugging monitor.  Connect your terminal to the HC11 board and turn on the power to the terminal. Make sure the terminal is set to 9600 baud.  (Ask your T.A. if you don't know how). Now power up the Axiom board. A sign-on message will appear, followed by a prompt (">"). The prompt means that the system is awaiting commands. Now, let’s see what kind of commands are available in the BUFFALO monitor. Refer to Table 1 at the end of this lab for a detail list of the available monitor commands.

1. Examine/modify memory

This mode is opened with an “MM” (modify memory) and closed with a carriage return.  The first location to be examined or modified must be entered (in hex) as an argument of “mm”. Try “m C000”; this will display the contents of the first address of user RAM.  The initial contents (after powering up) will be something apparently random. Once the current contents have been printed, type "00" and a carriage return.  Now examine the location again.  Is it 00?  Try “$ff”.

You can examine and modify successive locations simply by typing a space instead of a carriage return between locations.  Try loading the first ten locations ($C000-C009) with the values $00-09.  Now try examining location $E000; this is the first location in the BUFFALO monitor ROM. Can you modify it? Try. What happens?

2. Dump memory

It is often convenient to view memory in a tabular form, so that you can get the “big picture”.  Enter the following command: “MD C000 C0FF”.  What do you see? Note the structure of this readout.  Note also the contents of the first ten locations beginning at $C000. Are they what you expected?  The right-hand column contains the ASCII value of the contents of each location, printed as characters.  Those contents that do not correspond to printing characters are simply represented with a dot.  This feature will be useful to check a program that you will enter later on.  Try entering simply “MD C000”.  This prints the three lines (16 locations) flanking the location specified as your argument.

3. Running a Program

The remaining features of the BUFFALO monitor require a program to work on. So, let's write a simple program.  This routine adds five numbers stored in memory at locations $C100-C104.

Address  Code  Label    Mnem.  Argument  Comment

$C000     4F            CLR A             ; clear accumulator

 C001     C6            LDA B   #$04      ; SET LOOP COUNTER

 C002     04

 C003     CE            LDX    #$C100     ; SET INDEX POINTER

 C004     C1

 C005     00

 C006     AB   LOOP     ADD A   $0,X      ; ADD [A] TO [WHERE X POINTS]

 C007     00

 C008     08            INX               ; BUMP X

 C009     5A            DEC B             ; DROP LOOP COUNTER

 C00A     26            BNE    LOOP       ; LOOP BACK IF NOT DONE

 C00B     FA

 C00C     3F            SWI

Enter this program using the "MM" command to alter memory. When you are done, use the "MD" command to insure that the code has been entered properly --almost correct doesn't count a bit here!! Close only counts with hand grenades and horseshoes!! Now enter five numbers --try 01, 02, 03, 04 and 05 in locations $Cl00-$C104.

Run the program by entering "g C000<cr>" (where <cr> means carriage return). This tells the monitor program to execute whatever code is found at location $C000. When the program is done, it will stop and print the contents of the registers (this function is enabled by the "SWI" at the end of your program) . Check the contents of accumulator a. Is it the sum of your five numbers? NO? Congratulations! You have inherited your first bug, courtesy of the management.

4. Debugging programs (breakpoints)

We are not purposefully being mean; this is an exercise to demonstrate one of the most powerful tools used in debugging programs, the breakpoint.  A breakpoint is a means of inserting a special code in your program to stop execution and print out the machine state when executing a given location.  By observing the known machine state and comparing it with what you think it ought to be, you can usually find the answer to your problems.  In programs involving loops, it is most important to know what is going on just before entering the loop, at the critical state inside the loop, and just after exiting the loop.

Breakpoints are entered by typing “BR xxxx<cr>” where xxxx is the location you wish for the breakpoint.  Insert breakpoints at $C003 (just before entering the loop; NOTE that breakpoints must ALWAYS be specified at locations where instructions begin!!) and $C00A (after the loop business has been done).  You are allowed at most four breakpoints.  While the loop exit (SWI) is already a form of breakpoint, it is not counted in your allowable total.  By typing “BR <cr>” you get a list of the locations of all of your breakpoints.  List your program using “MD”; what do you see in the modified locations?

Now run your program using “g C000<cr>”.  It will stop at the first breakpoint and tell you all about the machine state.  Note that the instruction AT THE BREAKPOINT has not yet been executed.  Note the machine state before you enter the loop.  Is everything OK?  To continue execution after encounter of a breakpoint, simply type “g<cr>”, which means "go at the place pointed to by the program counter".  Observe the execution of your program through the loop.  Watch each variable as the loop iterates.  How many times did you go through the loop before falling out of it?  By now you should have picked up the error in your program.  Fix the program using the “MM” command.  You may delete the breakpoints by entering “b - <cr>” before running your program the last time to check it.  Note the values in your list and the corrected sum.

5. Other BUFFALO commands

Now you are better prepared to enter your program to fill memory.  As you do so, familiarize yourself with the other BUFFALO commands (See Table 1), such as RM. Verify the flow of your program's execution by using the T (trace) command.

Enter and run the program to move the first page of user memory.  Use the “MD” command to verify its correct operation.

Enter and run the program that writes your name to the screen.  Show the result to your lab TA.  Aren't you proud of yourself?

After the Lab

  1. Produce neat, written and annotated listings of your code.

  2. Describe IN YOUR OWN WORDS the function of the following monitor commands: md, mm, rm, rd and t.

  3. How can you simulate a breakpoint without "br"? Is it possible? If you were to write a BUFFALO monitor, how would you implement breakpoints?

  4. The Axiom board has a clock rate of 2.4576 MHz. Use your instruction card to look up how many clock cycles each instruction in each program uses. Total the time of execution for the first three programs (can't do this for the program to write your name, since it uses a subroutine of unknown length). At $10.00/hour of processor time, calculate how much it costs to run each of the first three programs once.

          TABLE 1.  BUFFALO Monitor Program Commands

COMMAND DESCRIPTION
ASM[<address>] Assembler/disassembler
BF <addr1> <addr2> <data> Block fill memory with data
BR [-] [<address>]... Breakpoint set
BULK Bulk erase EEPROM
BULKALL Bulk erase EEPROM & CONFIG register
CALL [<address>] Execute subroutine
G [<address>] Execute program
HELP Display monitor commands
LOAD <host download command> Download (S-records) via host port
LOAD <T> Download (S-records) via terminal port
MD [<addr1> [<addr2>]] Dump memory to terminal
MM [<address>] Memory modify
MOVE <addr1> <addr2> [,dest>] Move memory to new location
P Proceed from breakpoint
RM[p,y,x,a,b,c,s,] Register modify
T [<n>] Trace $1-$FF instructions
TM Enter transparent mode
VERIFY <host download cmd> Compare memory to download data via host port
VERIFY <T> Compare memory to download data via terminal port

BUFFALO UTILITY SUBROUTINES

Several subroutines exist that are available for performing I/O tasks. A jump table has been set up in ROM directly beneath the interrupt vectors. To use these subroutines, execute a jump to subroutine (JSR) command to the appropriate entry in the jump table. By default, all I/O performed with these routines are sent to the terminal port. Redirection of the I/O port is achieved by placing the specified value (O=SCI, 1=ACIA) into RAM location IODEV.

Utility subroutines available to the user are as follows:

UPCASE  If character in accumulator A is lower case alpha, convert to upper case.
WCHEK  Test character in accumulator A and return with Z bit set if character is white space (space, comma, tab).
DCHEK  Test character in accumulator A and return with Z bit set if character is delimiter (carriage return or white space).
INIT  Initialize I/O device.
INPUT  Read I/O device.
OUTPUT  Write I/O device.
OUTLHLF  Convert left nibble of accumulator A contents to ASCII and output to terminal port.
OUTRHLF  Convert right nibble of accumulator A contents to ASCII and output to terminal port.
OUTA  Output accumulator A ASCII character.
OUTlBYT  Convert binary byte at address in index register X to two ASCII characters and output. Returns address in index register X pointing to next byte.
OUTlBSP  Convert binary byte at address in index register X to two ASCII characters and output followed by a space. Returns address in index register
OUT2BSP  Convert two consecutive binary bytes starting at address in index register X to four ASCII characters and output followed by a space. Returns address in index register X pointing to next byte.
OUTCCRLF  Output ASCII carriage return followed by a line feed.
OUTSTRG  Output string of ASCII bytes pointed to by address in index register X until character is an end of transmission ($04).
OUTSTRGO  Same as OUTSTRG except leading carriage return and line feed is skipped.
INCHAR  Input ASCII character to accumulator A and echo back. This routine loops until character is actually received.

Utility jump subroutines for performing I/O tasks are shown below. These subroutines are in ROM and are programmed as jumps. To use the jump subroutine, execute a JSR to the applicable address shown below.

$FFAO JMP UPCASE Convert character to uppercase
$FFA3 JMP WCHEK Test character for white space
$FFA6 JMP DCHEK Check character for delimiter
$FFA9 JMP INIT Initialize I/O device
$FFAC JMP INPUT Read I/O device
$FFAF JMP OUTPUT Write I/O device
$FFB2 JMP OUTLHLF Convert left nibble to ASCII and output
$FFB5 JMP OUTRHLF Convert right nibble to ASCII and output
$FFB8 JMP OUTA Output ASCII character
$FFBB JMP OUTlBYT Convert binary byte to 2 ASCII characters and output
$FFBE JMP OUT1BSP Convert binary byte to 2 ASCII characters and output followed by space
$FFCl JMP OUT2BSP Convert 2 consecutive binary bytes to 4 ASCII characters and output followed by space.
$FFC4 JMP OUTCRLF Output ASCII carriage return followed by line feed
$FFC7 JMP OUTSTRG Output ASCII string until end of transmission ($04)
$FFCA JMP OUTSTRGO Same as OUTSTRG except leading carriage return and line fees is skipped
$FFCD JMP INCHAR Input ASCII character and echo back

 


| EE-218  Homepage | Syllabus | Schedule | Lab News | Faculty | Contact Information | Lab Info | Project |


Department of Electrical Engineering and Computer Science
Box 1824 Station B
Nashville, TN 37235
Phone: 322-2771
Fax: 343-6702


 | Search | Site Index | People Finder | Phone Directory | VUnet | VUmail | VU Library | Help |


Last Updated: Wednesday, January 11, 2006

Juan J. Rodriguez-Moscoso

Copyright © 2003 Vanderbilt University