Vous êtes sur la page 1sur 15

EXPERIMENT 17

In and Out Instructions (Unit 6)


Purpose 1. To demonstrate the input and output instructions Materials Required 1 EWS-8085 1 Program Cartidge (EB 8085 30) 8 10 pieces of no. 22 insulated wires, stripped at each end.

Note: All values entered from the EWS-8085 keyboard are hexadecimal.

Introduction
In addition to the 65, 53610 memory addresses, the 8085 can talk to 25610 input ports and 256 output ports. The procedure for talking to each of these ports is different, depending on the hardware at that port. However, the only 8085 instructions available are the IN (DB) and OUT instructions (D3). To output data, you put the data into the accumulator and identify the port address as part of the OUT instruction. For example MVI A, 61H and OUT 30H will send 61H to port 30H. After the out instructions, the accumulator will still contain the data that was sent. To input data, you just specify the port as part of the IN instruction, for example, IN90H will transfer the data from port 90H to the accumulator. If there was anything in the accumulator before, it will be lost. In this experiment, you will work with the IN and OUT instructions and see how they work. The I/O addresses in the EWS- 8085 are not completely decoded. This means that several addresses will access the same port. You should make it your practice to always use the lowest address. In addition, at some addresses, the different bits control different functions. The following is a list of the EWS- 8085 I/O ports and their uses.

Port Addresses OOH-03H 10H-13H 20H-23H 30H-33H 30H-33H 30H-33H 40H, 44H, 48H, 4CH 41,H 45H, 49H, 4DH 42H, 46H, 4AH, 4EH three 43H, 47H, 4BH, 4FH 50H-5FH (Breadboard) 60H-6FH (Breadboard) 70H-7FH (Breadboard) 80H-83H 80H-83H 90H-93H A0H-A3H B0H,B2H B1H,B3H register

I/O I I I O O O O O O O I/O I/O I/O I O I O I/O I/O

Bits 1,2,3,4,5,6 1,2,3,4,5,6 1,2,3,4,5,6,7 0,1,2 3 4,5,6,7 All D all D all D all All All All All All All All All All

Function Keyboard Column 1 Keyboard Column 2 Keyboard Column 3 A/D input select A/D input Range select A/D input select Timer register one Timer register two Timer register Timer register four General I/O zero General I/O one General I/O two A / D input D / A output input port (IPO IP7) output (OP0-OP7) LCD data register LCD command/status

Procedure
1. Use the eight wires to connect OP0 through OP7( Right side lower block) to the eight LEDs (Upper left Corner). Make sure only one wire is connected to ech OP point and each LED connection. Keep the wires in order so that OP7 is connected to the left LED and OP0 is connected to the right LED. 2. You are already aware of the GETC routine that inputs a value from the keyboard, but yuou are not aware of the difficulties involved in getting that value. From the list above, you see that the heaxdeciaml keys are in three columns read at addresses 00 through 2F16. Write a program that inputs column 1 and sends the vlue to the LED port (A0). Although we have provided many lines, you can do this in 3 instructions. Address Code __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ Label Mnemonic Comment

__ __ __ __ __ __ Try your routine to see that it works 3. Modify the program so that it will input keyboard column 1 twice and display the second value if the two are different. You can call PUTBYTE (CNZ 0055H) to diplay the accumulator when the values are different. Although w have provided many lines, you can write this program in 5 instructions. Address Code __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ Label Mnemonic Comment

Again, try your routine to see that it works.

Discussion
During Steps 2 and 3, you should have noticed two things. First, in Step 2 the display held the value as long s the key was depresses. Second, in Step 3 you got one value when the key is pressed, and another when the key is released. What you may not have seen is that occasionally when you pressed a key you can get more than one pair of changes. This is called key bounce. An effective keyboard routine should get each keyboard entry, but never give more than two entries for a single key stroke. In other words, you must debounce that keyboard. Because the EWS-8085 keyboard is generally bounced free, you can get good results if you cause the routine to wait until the key is released. For the next step, we have helped by giving you a table of ASCII values and a routine to select the right one. To use this routine, the key board value must be in the accumulator will contain the appropriate ASCII value. The H-L register pair is also changed by the routine.

Procedure (continued)
4. Write a program that checks column for a key value (other than FF), converts the values to the ASCII for that key and send the value to the display (Use the PUTC system call) only once for each key press. Address Code __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ Label Mnemonic Comment

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ Try this routine to see that it works.

FINDIT LOOP

FOUND

LXI H, TABLE ANA A RLC PUSH PSW JNC FOUND INX H POP PSW JMP LOOP POP PSW MOV A, M CALL 0046H RET DB 00H DB 33H DB 36H DB 39H DB 43H DB 46H DB 3FH

; Point to the table ; Clear the Carry ; Rotate into the carry ; Save the value ; Jump if found ; Point to the next item ; Restore the value ; Try again ; Clean up the stack ; Read the table ; Display the Character ; Return ; High bit Co1 is clear ; 3 key ; 6 key ; 9 key ; C key ; F key ; ? key

TABLE

5. Write a program that checks for a key value (other than FF) IN ALL THREE COLUMNS, converts the value to the ASCII for that key and sends the value to the display. Again, the display should continue to display that value until the next time a key is pressed. You can use the same FINDIT routine, except you should set H-L to the beginning of the section of the table that belongs to the column in which the key was pressed.

Address

Code __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Label

Mnemonic

Comment

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ Run your program to see that it works

FINDIT LOOP

FOUND

ANA A RLC PUSH PSW JNC FOUND INX H POP PSW JMP LOOP POP PSW MOV A, M CALL 0046H RET DB 00H DB 33H DB 36H DB 39H DB 43H DB 46H DB 3FH DB 00H

; Clear the Carry ; Rotate into the carry ; Save the value ; Jump if found ; Point to the next item ; Restore the value ; Try again ; Clean up the stack ; Read the table ; Display the character ; Return ; High bit Col 1 is clear ; 3 key ; 6 key ; 9 key ; C key ; F key ; ? key ; High bit Col 2 is clear ; 2 key ; 5 key ; 8 key ; B key ; E key ; + key ; 0 key ; 1 key ; 4 key ; 7 key ; A key ; D key ; - key

TABLE

TABLE2

TABLE3

Discussion
This completes Experiment 17.

EXPERIMENT 18
Interrupt Experiment (Unit 6)
Purpose 1. To demonstrate the use of the INTR interrupt. 2. To demonstrate a technique for storing an interrupt vector.

Material Required
1 EWS-8085 1 PROGRAM CARTRIDGE (EB-8085-30) 18 10 pisces or no. 22 insulated wire, stripped at each end.

Note: All values entered from the EWS-8085 keyboard are hexadecimal.

Introduction
INTR is usual interrupt, because It pulls an instruction from the data bus an immediately execute it . This is normally one of the RST instruction. T he only way this can be done, is to have hardware connected to data bus that provides the correct instruction when the hold acknowledge signal is generated. Therefore, if you are a programmer you will seldom have to worry about the INTR signal. Every time you reset your trainer, the interrupt vectors are restored to their `default values. If you want to use an interrupt vectors are restored to their default values. If you want to use an interrupt, you must be sure the correct vector is in memory. Fortunately , you are aided by the fact that the interrupt vectors already contains jumps. Therefore, the easiest way to change a vector is to replace the default jump destination. To do that, put a value into H-L (LXI H, vector) and store the value into existing jump location (SHLD ADDRESS). For example, if youre new interrupt routine for RST 5.5 is at address 70B016 you could use the following instructions to make that change.

Address
xxxx xxxx

Code
21 B0 70 22 13 68

Label

Mnemonics
LXI H, 70b0H SHLD 6813H

Comment
;Point to the new routine ;Replace the old vector

We will use this technique both here and in Experiment 19. Although most of the connector block signals are labeled the same on the connector blocks and overlays some are different. You should have the connector block overlays in place before doing this experiment. If not, refer to this list for different labels when you make your connections: Overlay READ HDA INR Connector block IRQ 1HZ PAI

In this experiment you will observe the operation of an INTR service routine.

Procedure
1. As you did in experiment 17, use eight wires to connect OP0 through OP7 (Right side lower block) to the eight LEDs (Upper left corner). Make sure only one wire is connected to each OP point and each LED connection. Keep the wires in order so that OP7is connected to the left LED and OP0 is connected to the right LED. 2. Use another eight wires to connect Data Lines D0 through D7 (Left side Upper block) to the eight data switches (Upper left corner). Make sure only one wire is connected to each Data Line and each data switch connection. Keep the wires in order so that D7 is connected to the left data switch and D0 is connected to the right data switch. 3. Use another wire to connect READ to HDA (Hold acknowledge). 4. Insert one end of the remaining wires into the INR connector. You will use the free end as a switch to activate the INTR interrupt. 5. Set all the data switches to the up (high) position except the one connected to D3. What RST instruction does this represent?

6. load file digit B from the cartridge, or key in the following program. ADDRESS CODE LABEL PUTC INTR BEGIN MNEMONICS EQU 0046 EQU 6816H LXI SP, 6FFFH MVIA, CFFH OUT OACH LXI H, MSGI SHLD INTR LXI H,MSGI MOV A, M ANA A JZ AGAIN INX H CALL PUTC CALL PAUSE JMP LOOP OUT OACH CALL PAUSE EI RET COMMENT

7000 7003 7005 7007 700A 700D 701C 7011 7012 7015 7016 7019 701C 701F 7021 7024 7025 7026 7029 702A 702B 702E 7031 7032 7035 7036 7037 7038 703B 7041 7044 7047

31 FF 6F 3E FF d3 AC 21 IF 70 22 26 68 21 38 70 7E A7 CA 0D 70 23 CD 46 CC CD 29 70 C3 10 70 D3 AC CD 29 70 FB C9 E5 D5 11 01 00 21 00 00 19 D2 31 70 D1 E1 C9 53 61 6D 65 20 6F 6D 65 73 73 61 67 65 0D 00

AGAIN LOOP

INTRUPT

PAUSE

DLY

MSG1

; Routine to display character ; vector address for RST ; Establish a stack ; Set all bits high ; Turn on the LEDs ;Point to interrupt the routine ; Change the vector ;Point to message ; Get the character ;I s it zero? ; If so, start over ; Point to next character ; Display it ; Wait a while ; Go back for the next character ; Display ASCII on LEDs ;Wait a while ;Reenable the interrupts ;Return for service routine ;For step 9 PUSH H ;Save H PUSH D ;Save D LXI D, 1 ;Set up increment LXI H, C ;Clear counter DAD D ;Increment H UNC DLAY ;If carry, were done POP D ;Restore ? POP H ;Restore H RET ;Pause routine done DB Same old message, 0DH,0 ;This is the message

7. Execute the program and observe that the message is displayed one character at a time. 8. While the program is running, briefly touch the free end of the INR lead to ground point (GND). The program will stop as long as the connection is held. You should observe the ASCII code for the current character on the LEDs. Disconnect the INR wire and the program will resume. Touch ground briefly again and the LEDs should change to show the ASCII code for the letter just displayed. 9. Modify the program so that the interrupt causes the program to restart in addition to displaying the character. Be sure the stack is cleared before jumping to AGAIN. Replace the RET at address 702516 with an instruction to fix the stack. The three addresses after that should allow you to restart the message. Write your corrections into the listing.

EXPERIMENT 19 Control and mask instruction (unit 6)


Purpose 1. To demonstrate the use of vectored interrupts. 2. To demonstrate the use of the interrupt mask.

Material required
1 EWS-8085 1 Program Cartridge (EB-8085-30) 1 10piece of no. 22 insulated wire, stripped at each end. Note:all values entered from the ews-8085 keyboard are hexadecimal.

Introduction

In addition to intr, the 8085 allows four hardware interrupt:TRAP, RST 7.5, RST 6.5, and RST 5.5. Three of those are controlled with the mask associated ,with the RIM and SIM instructions. The TRAP interrupt is wired to the NMI key and is used by the trainer to break a program. Here are the default vectors associated with these four interrupts. Interrupt TRAP RST 5.5 RST 6.5 RST 7.5 Address 0024 002C 0034 003C ROM Instruction JMP 680C JMP 6812 JMP 6818 JMP 681E RAM Instruction JMP 0156 * JMP 0156 * JMP 0156 * JMP 03FF *

Notice that the default RAM jumps for RST 5.5 and RST 6.5 are the same as for TRAP. Under default conditions, if generate an RST 5.5 or RST 6.5. the result will be the same as if you had pressed the NMI key. RST 7.5 is used for RS-232C communication timing control. One of the trainers built in timers (TIMER2) is connected to interrupt 7.5. This can be reprogrammed at the expense of RS232C communications *These values may be different depending on the ROM version.

Only RST 6.5 and 5.5 are available on the connector blocks. If you do not have the overlay, use this table to identify the locations. Overlay R5.5 R6.5 connector block IC2 IC1

In this experiment you will observe the operation of an RST 5.5 service routine.

Procedure
1. Load the program from file digit c in the program cartridge. It is listed here.

Address

code

label PUTC RST55 COUNT

mnemonic EQU 0046H EQU6813H EQU 10000

comment ; display character routine ; RST 5.5 vector ; count

7000 7003 7004 7006 7008 7009 700C 700F 7012 7013 7014 7017 701A 701B 701E 7021 7022 7024 7026 7027 7028

31 FF 6F 20 E6 06 f6 06 30 21 21 70 22 13 68 21 56 70 7E A7 CA OF 70 CD 46 00 23 CD 40 70 C3 12 70 20 E6 06 F6 09 30 E5 21 68 70

BEGIN

AGAIN LOOP

LXI SP,6FFFH RIM ANI 06H ORI 08H SIM LXI H,INTRUPT SHLD RST55 LXT H, MSG1 MOV A, M ANA A JZ AGAIN CALL PUTS INX H CALL DLAY JMP LOOP RIM ANI O6H ORI 09H SIM PUSH H LXI h, MSG

;establish stack ; read the interrupt mask ; add RST 5.5 to mask ; add mask set enable (mse) ; establish new mask ; Point to new routine ; Replace old verctor ; Point to message ; Get the character ; Set the flags ; If message is done repeat ; display character ; Point to next character ; Pause a while ; Go back for next\ character ; Get the mask ; Save RST 7.6 and RST 5.5 ; And mse & mask for RST 5.5 ; Mask RST 5.5 ; Save H-L ; Point to RST 5.5 message

INTRUPT

702B 702C 702D 7030 7033 7034 703A 703C 703D 703E 703F 7049 7041 7042 7043 7045 7048 7049

7E A7 CA 3A 70 CD 46 00 23 CD 40 70 3E 08 30 E1 FB C9 D5 F5 C5 06 01 11 1027 1B 7A

LP

DONE

MOV A,M ANA A JZ DONE CALL PUTC INX H CALL DELAY MVI A, 08H SIM POP H EI RET PUSH D PUSH PSW PUSH B MVI B,1 LXI D, COUNT DCX D MOV A, D

; Get the character ; Set the flags ; Jump if message is done ; Display it ; Point to next character ; Pause a while ; Repeat for next character ; Well reenable interrupt ; Restore H-L ; Reenable interrupts ; Interrupt routine complete ; Save D ; Save PSW ; Save B ; Load count multiplier ; Set counter ; Decrement count ; Load high byte to A

DELAY

TIMER LP3

704A 704B 704E 704F 7052 7053 7054 7055 7056

B3 C2 48 70 05 C2 45 70 C1 F1 D1 C9 53 61 6D 65 MSG1 20 6F 6C 64 20 6D 65 73 73 61 67 65 0D 00 7B 69 6E 74 MSG 20 35 2E 35 7D 00

ORA E JNZ LP3 DCR B JNZ TIMER POP B POP PSW POP D RET

; Are both zero? ; If so, timer is done ; Decrement multiplier ; Repeat till Multiplier=0 ;Restore B ; Restore PSW ; Restore D ; Delay done

DB Same old message, 0DH, 0

7068

DB {int 5.5}, 00

2. Execute the program and notice that the Same old message is displayed repeatedly. Insert one end of the wire into the R5.5 connector o the lower block. While the program is running, touch the other end of the wire to the ground (GND) and then disconnect it. Write down the way your work display appeared. 3. Touch the wire to ground again. Try it several times. Do you get the interrupt message each time? 4. Stop the program and examine memory address 703E16 which is currently FB16, and change it to 00. 5. Execute the program, and again, touch the RST 5.5 wire to ground. Did the interrupt work the first time? Try it again. Does it continue to work? If not, why not? . 6. Examine address 703E16 and change it back to FB16. Then examine address 700716 and change it from 0816 to 0916. Look at the program listing and explain what you think this will do? . 7. Execute the program and try the RST 5.5 interrupt by touching the lead to ground. Does the interrupt work?

Discussion
The interrupt massage will appear within the Same old Message. The exact location will depend on when the lead is touched to ground. If the connection is held (int 5.5) message may repeat.

Vous aimerez peut-être aussi