0% found this document useful (0 votes)
38 views

Experiments in Microprocessor Interface & Programming by Douglas V. Hall

This book is intended to provide a broad-spectrum of 8086/8088 Microprocessor and Microcomputer laboratory exercises.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
38 views

Experiments in Microprocessor Interface & Programming by Douglas V. Hall

This book is intended to provide a broad-spectrum of 8086/8088 Microprocessor and Microcomputer laboratory exercises.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 133
EXPERIMENTS IN MICROPROCESSORS AND INTERFACING PROGRAMMING AND HARDWARE SECOND EDITION DOUGLAS ¥. HALL Maen {ake Forest, ins Columbus, Chio Mission ils, California Peoria, Minos BMC, 18M PCAC. eM POVAT, 18M P8:2, ae MiroChannel Architecture are registered "admarks ol 1M Corprein. Te alwng are regen racersrks oft Corporation: 480, e801, RMI. Borand, Stdekeck,Turoo Assembler, TASM, Turbo Debugger, and Tuba Gr= re ‘aglteredademarks of Boland Iicmatond ine. Maeosot, MS, MS OOS, Windows 3.0, ode. and MASM sre registered rademares of Me-ceah Corpeaton. Other product names are fogatted trademarks of tho companies assorted wits ts product name flere nth tox or Agu. Copyright © 1902 by the Glanece Ohison of MacmitanMeGrau- Hil Shoe! Punishing Company. Copyiget 2 1886 ay McGraw, a. All rights reserves. Except as permed Lncer the Unites States Copyright Act, no part ofthe pubieaion may be reproduced or Se appear in the rightmost digit of the address field eorex 60 | Go lad ast press oe hey and then ne a Brat Manet nex mse dceee | TS] LS | frmbol for ass ha vt segnend nee aes | [pa the syaibol for a BG) dake man ee at cre eet es Proms end dm Sho | TL oe Nawesm | ax [omar note that the symbols for the last four keys — Se ee 2. To prepare the SDK to receive its next command, oner fae Seles -) —— prem they anes sist Rese SSCs. Whenever n dash i dplayed on the tetas cchoearueesr rm ocmmracmmat | TET oy loom | |p With one of the keys on the keypad. Figure 1-1 eld — inex Shows the fnetons of eats af ans PES LD Pale | ow eerntien pes ow | urout 2S | Osta Segment poe Ei ana ‘SDK-36 ww an a a ack SF BJ fmm |e fo fa we] | RIMES a twee a nom | wa s [om ren | | oi eae eee roitarnac eg teres ezem ole pe pee eee uae i — ie ope ciel Seon = Trousers, Lr SES A ee [Tf me fae | aoe foe =] Sasssaretae ti 2 Ay mp wae Loam Stel omen ce . Zien tay seo gr eg Poa recent das, Nox tween rgb Sonar {cis ors arecsn tae 2 epeRweNT (@) Hexadecimal keypad interpretation. Intel Conporation) that many of the kes have several functions, depending upon whether yout are entering a com. mand, entering addresses and data, or examining 8086 registers. The 0 key. for example, is used te enter the EB command ifs dash is showing. It is Used to enter the number 0 if an address or data Word ts being entered. Tt is used to represent the AX register if registers are heing examined, “The SDK-86 keypad monitor program allows you to execute 10 baste commands. Figure 1-2 summarizes the format for these commands. Worle your way through the following sections. which show you how to use some of these commands. The sections are ented by the command name 50 thet you ean find them easily if you need to relresh your memory at some future tie, EXAMINE BYTE (EB! ‘The examine byte command Is used to inspect and, if desired, change the byte stored in a memory location. ‘This command allows you to easily enter program code bytes or data bytes in successive memory Jocatlons. As shown in Figure 1-2, the format for the command is EB addr {data .1*. ‘The letters “EB” tell you to press the Key labeled EB. The “addr” tells you to enler the address of the byte that you want io look at. Pressing the comma after entering the address causes the address and the contents of that address to be displayed. The square ‘brackets and the * shown in the command format are not entered. Command parts contained tn square brackets are optional. The inner square brackets in ‘his command indicate that the data at that address can be changed by simply typing in the desired hex value, The“ indicates that the part of the command contained in the outer square brackets can be repeated. In other words, by pressing the <> key, you can step to the next address, see lls contents, and change them if you want ‘To see the byte in a memory location, press the key labeled EB, enter the address of the desired byte, and onmane Funcinlsyoe xarioe | Dielownodtis memory bse eaters Be | EBcoaie> a teu Blo Examine | Diplayeeditar emery word eens ors jeoear> fear 21a Examine | Ospaye-notes 8085 asi contets ager | ER T] 1°10) trout | Digaye cea aetna part Sym | gl ala Wed | Bicootser>orai to urpur | outputs aye out pot bye porte cea ) A foupar | Duessedaen wont cup ore Word | Gicoertacdr> Sdn a eds>1 902 60 | Tater conta fom monitor ow rosary Boia (a cend ed Ol | Bl crane seer) Q)*D FIGURE 1-2 SDK-86 boare! moniter command summaty. {Intel Cosporaion) then press the <> key. Addresses are entered in the segmentioffset form, and so in order to see the contents of the memory location 000100H (0000:0100), you enter 0:160 as the address. Note that the SDK does not require you to enter leading zeros and does net display them, 4. To see the byte in memory at 0000:01008, enter the following series of Keys: BBO:100, ‘Afier you press the <> key, the contents of add- ress 0000:0100 should appear on the rightmost ‘ovo digits of the data field LEDs, 2, To insert some new byte value at that address, center the hex digits of the new value with the keypad, To enter the value C4H, press the keys ca As you press the Keys, you should see the ew vahie appear on the data field LEDS. If you make a mistake while entering a value. Just {ype in the two correct digits; they will replace the previously entered value 8. To examine the next memory location, press <>. You should now see the address 101 displayed on the address fefd digits, and the byte stored at that location displayed on the right two data field LEDs. To change the contents of this new address, enter another value with the keypad. Press the <> key fagain if you want to examine and/or change the next sequential memory address. '5, To terminate the command alter you have looked fat all the memory locations you Want, prese the <> Key, When the dash prompt ) appears, you can enter your next command, 4. EXAMINE WORD (EW) ‘The examine word command is used to mspect and, sf desired, change a word stored In (we memory loca- Uons. AS shown in Figure 1-2. the format for the ‘command is EW addr. {[datal.1* ‘The operation of BW is identical to that of the EB command deseribed in the preceding paragraphs, except that a data word (16 bits) will be displayed on the four data field LEDs. The right two digits of the displayed word represent the byte contained in memory at the address specified in the command, The high byte of the word, displayed on the upper two data fleld LEDs. represents the byte contained in the memory location after the address specified im the ‘command, 1. Examine the word contained in addresses (0000-0100 and 0000:0101 by pressing the keys EW0:100, You should see the byte from 0000:0100% displayed on the right evo data field LEDs and the INTRODUCTION TO THE SOK-85 MICROPROCESSOR DEVELOPMENT BOARD 3 byte from address 0000:0201 displayed on the left ‘vo LEDs, 2, Change the displayed word by entering the desired ord. Press the <> key to step to the next word in memory. 3. Write down the value you see for this word, Then press the <> Key to get the dash prompt back, so that you can enter another command. 4. Use the EB command to verify that the low byte of the displayed word came from the low address (0000:0100) and the high byte of the word came from the higher address (0000-0101). This relax ‘Gonship is very important to remetber, EXAMINE REGISTER (ER) To display the contents of an 8086 register, press the key and then the key that contains the letter Initials for that register. 1, Examine the contents of the AX register by pressing the keys BRAK Notice that the key is also the key. The address field of the display will show the letter A ‘to maleate the register that is being displayed, and ‘the data fled will show the word contained i the AX register, 2, Examine the contents of the next 8086 register by pressing the <> key. Each tlme you press the <.> ‘key, the SDK will display the next register in the sequence AX, BX, CX, DX, SP, BP, Sh. DI, OS, DS. $8, BS. IP, FL. FL ts the flag register. In each case the address field will show one or two mnemonie letters to indicate which register Is being displayed. 3, To change the word in any register, enter the four hex digits for the word you want in the register. ‘Then press the <> key to step to the next register. or press the <> key to get the dash prompt back ‘0 that you can enter your next command, NOTE: ‘The ER command operation is not circular, so if you want to loole at a register earlier In the sequence, press the <> key to terminate the command, Then press the key to start the command again and then press. the key that has the name of the register you ‘want 10 see. co ‘The SDK-86 GO command allows you to run programs which you have previously loaded into RAM. Remember, you can load programs, into RAM starting at address 0000:0100H. The format for the ‘command 1s| GO [addr } |, breakpoint addr! ‘The first address spectiied in the command is the Program address at which you want execution to 4. expentwenT a start. The breakpoint address specified in the command is the program address at which you want execution to stop. Whenever you run a program on a microcomputer, you must I some way prevent the processor from fetching and attempting to execute random bytes stored tn memory after your program. One way to solve this problem is te put a jump instruction as the last instruction in the program to make the program execute over and over again in an ‘endless loop, For programs that you don’t want to execute over land over, you can put & breakpoint after the last program instruction. When the 8086 reaches the breakpoint, tt will save the values that were in the £8086 registers afer the last program instrietion was executed and retum control to the SDK-86 monitor program. You can then use the EB or EW command to look at any program results in memory. You can use the ER command to look at any program results sn registers. Using the SDK-86 Commands io Load and Exectite a Program igure 1-8 shows a simple program that you can enter into the RAM on your SDK and run for practice. When run, this prograin causes the SDK to display ‘4-digit hexadecimal count sequence en the data fleld LEDs. The program keeps counting from QO00H to EFFFH, Don't worry tf you haven't the foggiest nation hhow the program works at this point. You can learn to drive a car without knowing how the camshaft opens the valves, To load and run the program in Figure 1-3, follow these instructions. 12. Look at the first coluran from the left in Figure 1- 3 to find the addresses for the code you will be loading into RAM. The addresses shown in the program listing are relative. This means that they show where the bytes for each instruction are relative to the starting address at which you load the program into RAM. You want to load the program starting at address 0000:0100H, and $0 you add 10014 to each of the addresses in Figure 1-3 to find the actual address of each byte. ‘The E command, deseribed previously, 1s used to enter the sequence of data and instruction bytes shown in Figure 1-2 tnta the SDK-86 RAM start- sng at address 0000:0100H. To see the current contents of address 0000:0100 on the data fleld LEDs. press the keys EBO:100, ‘You want to enter the frst instruction code byte of the program into this location 2, The second column to the left in the program listing contains the codes that you wall be loading into RAM, The reason there are different numbers of code bytes on different lines 1s that the code byte(s) required for an instruction are put on the line with the Instruction, Laole at the 184 Personal Coaputer MACRO Asseabler Version 2,00 Page f+! ages 132 9086 Count Progren 5 5 This progran dinpiays an tnsrononting hanadesiaal count on 5 the data Tielé diaplay of the $0686 board. i 000 COE HERE SeaHEMT PUBLIC S1AE C9:C0BE WERE DECORA, MERE Sanitialize data sepeent 0000 98 1300 OV A, DATA PERE 00039 88 HOW D8, ak 0005. 9F coo HOV Dt, 060 4 zero counter 008 8B 000 OV BK, OFFSET SEVEH SEO 5 pointer to seven-seguent codes 0008 ah RFE DISPLAYENOY DY, OFFER {point at 8279 control address 008 E090 HO AL, 38 5 Yoad control werd for data field 0010 OT BY, aL 4 send control werd $0 279 cout BA SOFF av Dx, OFFEBK 5 point at 4279 display mam 0018 6B OF Mov C1, BT ote a4 cL HOV Aly cl 1 get tow byke to be displayed ons a6 OF AND AL, FH 4 mask upper nibble 00a a7 nate 5 translate Lower nibble'to 7-s09 cade 001g FE OUT Diy a F send to 279 display RAN O0ie a6 cs tov AL, 4 get low byte again OO1E BL OF Ov Ck, 04 4 Toad rotate count 0020 m2 00 fou aL, OL 4 Move apper nibble into Iow position 002224 OF BD AL, FH 5 Mask upper nitble ones 7 tan § translate 2nd nitble to 7-s99 code oes gE WT Day a 5 send to O277 display RAK 08S 8A CS HOY Aly | Set high byte to translate 0088 24 OF a AL oF 4 Mask upper nibble 0024 07 su 5 Translate to Tosey code 002) EE Or Di a send $0 8279 display Rh ooec aa os HOV aly 4 get high byte to fix upper nibble coat 2 C9 ROL Aly cL ‘ove upper nibble into low position cog 24 oF PAD AL, FH 4 sash upper nitble ooge 07 ate 4 translate to T-seg code 0039 SE OWT Dky AL 5 Tosog code to S279 display Aa 0094 3 FFFF NY ST, OFFFFH 4 Jond counter to pause 0087 4 Pause: DEC St 9038-75 FD BAZ. PAUSE 0038 47 INCL 5 incrawent counter nga 6B ce AP oIeLay 0030 (CODE HERE BS 000 DATA HERE SESRENT WORD PUBLIC 9000 3F 06 8 4F 66 6D 79 07 SEVER_SEB DB FH) OOH, Sy OFM, 68H, AIH, 7M, OTH Ve ete sare be 0009. TF AF 77-90-39 SE 79 71 Diy Fy 77My POH, Hy SERS PAM 1 a on DATA, HERE EMIS Ey FIGURET-3 8086 counting program, INTRODUCTION TO THE S088 MICROPROCESSOR DEVELOPMENT BOARD. 5 6 2. {op of that column to find the BEM code byte and. fhe other cades that will be put aller {To put the BS code byte into RAM and ta sce address. G1OT on the address Neld and the contents of ‘that address on the data fel, press the keys Bs. ‘The next code byte (to the right of BBR) is 19H, ‘To enter this with the keypad, press the keys 13, ‘The <> Key steps to the next RAM address ‘The next code byte for the program is OOH, so enter this value and press the <> key to step to the next address, ‘The next code byte, found on the next linen the Program printout, is 8EH, Enter this value and Press the <,> key to step to the next RAM. auldress, - Enter each code byte in column 2, followed ty a When you reach the end of the code bytes in column 2, insert the data bytes, starting with SPH in the series of addresses starting with 0000:013E. Note that address 0000:013D is ‘slapped. - Aer you have entered all the program bytes, ress the <> key to return control to the monitor Program. EXPERIMENT 1 9 The next step 1s to check f the program was entered correctly. Press the keys EB 0:10, to see the byte in the first address, If this byte is ot correct, enter the correct value and prese the <> key to get to the next address. if the byte is correct. just press the <,> key to step to the next address. A common error Is to miss a byte: consequently, the bytes after the missed byte eid LP at wrong addresses. If you find an ervor, you can just insert the correct value(s), and proceed, When the program seems correct in RAM, run the ‘program from the starting address (0000:0106H. Press the keys G00:100, + If the program does not operate correctly, press the RESET key and check the codes in RAM again. If the program stil does not work core reetly. get help, If ie permits we suggest that you now go on and do Experiment 2, which shows you how to luse breslspoinis to debug a program that docs? Work and how to modify the operation of the pro- gram, Experiment 2 uses the same program 16 {his experiment, so ifyou leave the power on and do Experiment 2 now, you won't have to Key the Program in again 10. 4,

You might also like