


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
In this document, students are given instructions for completing a microprocessor lab, specifically adding ready signals to a keypad and wiring an input port. The document also includes notes on catching up if behind and working with instruction opcodes. The lab involves programming and assembling opcodes, as well as using an assembler.
Typology: Lab Reports
1 / 4
This page cannot be seen from the preview
Don't miss anything!



In this lab, you will finish wiring an input port to allow the CPU to read the keypad (defined as memory address $ 8000 by the HCT 138 you installed in the last lab). You will also wire in a READY SIGNAL (A one bit signal from memory location $ 8001 that tells the CPU when the keypad has new data. The wiring this week is relatively quick. The rest of the time will be programming to make use of some of the features we’ve included in the past weeks. NOTE: For the first time, you will have to work out some of the instruction opcodes for yourselves. Be sure to try to understand the programs as you use them. A note to those of you behind. You should try to catch up as soon as you can. Time is available on Monday and Friday mornings for you to work outside of class hours if you arrange it with your TA. If, at this point, your processor is not executing opcodes and loops, you are behind enough that you should consider taking advantage of this. Next week will be a miniproject, showing you know how to use the processor and opcodes. There may be some catch up time as well, but if you’re too far behind, it won’t be enough. Another note – Keep in mind that the example circuit is wired and working through the end of today’s lab – If you’re behind, or even working on an earlier section, you should wire as instructed in that section. DO NOT blindly copy off the front example board, especially if you are not as far along as that board is, as each step along the way has changes, and sometimes previous wirings needed for an earlier section are removed as we get successive “small pieces” working. Mixing and matching parts from earlier and later sections may lead to intersting results. While it may seem obvious to most of you, it should be noted that your microprocessor board is a SYSTEM and all the parts must work together correctly. The lab writeups will walk you through that process if you follow each and every step in the order it appears, testing the new parts along the way. Not doing so, however, or inventing your own procedures may lead to some remarkable confusions. Do so at your own peril. And randomly changing wiring is not likely to lead to a productive conclusion – You must trace an input from what you know is good through the circuit until something doesn’t make sense... And there will very likely lie your error. You should follow the steps outlined in the order outlined until you have a good understanding how the parts fit together, then you can make your own changes intelligently when it comes to project time.
Section 20-1 - p. 489 Do this section as described in the manual. Be sure the first 8 memory locations contain in order 00 00 20 00 00 00 01 00 to specify the address of the stack to be $ 00002000 and the address of your main program to be $ 00000100. You need to fill in the op codes for the branch instructions where you see the “xx”. We’ll do them for you here but not for the later sections. At memory location $010E you need a BSR ’Delay’ instruction to $0166, the address of the delay subroutine. The offset is then the hex difference $
word opcode as given in the manual (p.490) where the high byte is 61 for the BSR opcode and the low byte is the byte offset, 56 in this case. The opcode is then $ 6156 (For offsets that require 2 bytes, you need a two word instruction where the second word is the 16 bit offset and the low byte of the first word is 00) At memory location $ 0110, you need a BRA ’Show’ instruction. Again, since the offset is small we can use a byte offset and the instruction requires only 2 bytes. The program counter will then contain $ 0112 when BRA is executed and you want to branch to $ 0106 (the address of ’Show’). The offset is then $112 - $106 = $0C steps backwards. (NOTE $ 12 - $6 is not $6 because when you borrow (or carry) in hex you borrow 16 decimal). Since the branch is backwards, we need the two’s completment of $0C which is $ F4. The opcode is then $60F4. You could also get F4 by counting backwards from $112 to $106, i.e. back one memory location is FF, back two is FE, etc. Alternatively, you can use the assembler to figure out the opcodes for you. In order to figure them out and have the addresses where you expect them to be and matching those in the book, you will have to use the ORG directive for the assembler. You should really be able to use both the assembler and also be able assemble the opcodes by hand. The assembler is handy when you need to do a big pile of coding, but if I have working code that I just want to tweak, I will sometimes just hand assemble an instruction or two... It’s quicker than modifying, saving, recompiling, etc. To make it less painful to watch if you simulate, you may wish to change the number of time delay loops. Here’s what the assembler came up with for this section:
00000000 2 * Program : Section 20_ 00000000 3 * Written by : Phys 00000000 4 * Date : 00000000 5 * Description: 00000000 6 *-------------------------------- 00000000 7 00000000 8 OPT MEX 00000000 9 OPT SEX 00000000 10 00000000 =00000000 11 CODE EQU 0 00000000 =00000001 12 TEXT EQU 1 00000000 =00000003 13 QTRSECONDLOOPS EQU $ 00000000 14 00000000 15 * I/O ADDRESSES 00000000 =00008000 16 DISP_KEYPAD EQU $ 00000000 =00008001 17 READYPORT EQU $ 00000000 =00008002 18 CONVERTERDATAPORT EQU $ 00000000 =00008003 19 STARTCONVERT EQU $ 00000000 20 00000000 21 00000000 22 SECTION CODE 00000100 23 ORG $ 00000100 24 00000100 25 START 00000100 26
20-6 – Do as instructed. We’ll discuss this program in class.
20-7 Optional
Appendix If you have time, play with these programs. Delay, Version2 might be useful for your homework mini-project.