intel's mcs-51 family of microcontrollers and its ... viz 8085, z-80, 6502, 8031, 8086/8088,...

30
ELEVATOR INTERFACE 1 CONTENTS PAGE NO 1.0 Introduction 2 2.0 Description of the Circuit 2 3.0 Installation 2 4.0 Demonstration Examples 3 4.1 Demonstration Program for MPS 85-3 Trainer 4 4.2 Demonstration Program for ESA 85-2 Trainer 5 4.3 Demonstration Program for ESA-80 Trainer 7 4.4 Demonstration Program for ESA-65 Trainer 9 4.5 Demonstration Program for ESA-31 Trainer 11 4.6 Demonstration Program for ESA-68K Trainer 13 4.7 Demonstration Program for ESA-196 Trainer 15 4.8 Demonstration Program for ESA 86/88-2 17 4.9 Demonstration Program for ESA 68-2 Trainer 19 4.10 Demonstration Program for ESA 68K-2 Trainer 21 4.11 Demonstration Program for ESA-51 Trainer 22 4.12 Demonstration Program for ESA 86/88-3 Trainer 24 4.13 Demonstration Program for ESA 51E Trainer 26 4.14 Demonstration Program for ESA 86/88E Trainer 28 Appendix A : Component Layout Diagram Appendix B : Schematic Diagram

Upload: hathuy

Post on 19-Mar-2018

224 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

1

CONTENTS

PAGE NO

1.0 Introduction 2

2.0 Description of the Circuit 2

3.0 Installation 2

4.0 Demonstration Examples 3

4.1 Demonstration Program for MPS 85-3 Trainer 4

4.2 Demonstration Program for ESA 85-2 Trainer 5

4.3 Demonstration Program for ESA-80 Trainer 7

4.4 Demonstration Program for ESA-65 Trainer 9

4.5 Demonstration Program for ESA-31 Trainer 11

4.6 Demonstration Program for ESA-68K Trainer 13

4.7 Demonstration Program for ESA-196 Trainer 15

4.8 Demonstration Program for ESA 86/88-2 17

4.9 Demonstration Program for ESA 68-2 Trainer 19

4.10 Demonstration Program for ESA 68K-2 Trainer 21

4.11 Demonstration Program for ESA-51 Trainer 22

4.12 Demonstration Program for ESA 86/88-3 Trainer 24

4.13 Demonstration Program for ESA 51E Trainer 26

4.14 Demonstration Program for ESA 86/88E Trainer 28

Appendix A : Component Layout Diagram

Appendix B : Schematic Diagram

Page 2: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

2

ELEVATOR INTERFACE

1.0 INTRODUCTION

Electro Systems Associates Private Limited (ESA) manufactures trainers for most of the popular

microprocessors viz 8085, Z-80, 6502, 8031, 8086/8088, 68000 and 6809. ESA offers a variety of

modules which can be interfaced to these trainers. These modules can be effectively used for

teaching/training in the laboratories.

This interface simulates the control and operation of an elevator. Four floors are assumed and for

each floor a key and corresponding LED indicator are provided to serve as request buttons and

request status indicators. The elevator itself is represented by a column of ten LEDs. The motion of

the elevator can be simulated by turning on successive LEDs, one at a time. The delay between

turning off one LED and turning on the next LED (this delay is programmed in software by the

user) can simulate the "speed" of the elevator. User can read the request status information through

one port, reset the request indicators through another port and control the elevator (LED column)

through another port.

This interface allows the user to write software for simulating the operation of elevator. The software

exercises could include priority schemes, different service schemes etc.

2.0 DESCRIPTION OF THE CIRCUIT

Please refer to the schematics of this interface presented in Appendix B.

This interface has four keys, marked 0, 1, 2 and 3 representing the request buttons at the four floors.

Pressing of a key causes a corresponding Flip-Flop to be set. The outputs of the four Flip-Flops can

be read through Port B (PB0, PB1, PB2 and PB3). Also, the status of these signals is reflected by a

set of 4 LEDs. The Flip-Flop can be reset (LEDs are cleared) through Port A (PA4, PA5, PA6 and

PA7). A column of 10 LEDs, representing the elevator can be controlled through Port A

(PA0,PA1,PA2 and PA3).

These port lines are fed to the inputs of the decoder 7442 whose outputs are used to control the on/off

states of the LEDs which simulate the motion of the elevator.

3.0 INSTALLATION

The interface is housed in a plastic enclosure which has a locking mechanism. To open the cover,

push in the locking mechanism with a finger and lift the cover to open.

Page 3: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

3

The interface module has a 26-pin connector at one edge of the card. This is used for connecting the

interface to the trainer with a flat cable connector set. The +5V DC power required by this

interface is drawn from the trainer via the flat cable connector set.

Table 3-1 shows the connector on various trainers to which this interface can be connected. Some

trainers have two connectors and either may be used for connecting this interface. The

demonstration programs presented in this manual assumes that the interface is connected to

connectors shown in column A. If the connector shown in column B is used, then user has to

change the port addresses appropriately. User may refer to the component layout diagrams of

respective ESA trainers to locate the connectors mentioned here.

TABLE-3.1

MICROPROCESSOR

TRAINER

A B

MPS 85-3 J2 J1

ESA 85-2 J2 J1

ESA-80 J2 J1

ESA-65 P4

ESA-68K P3 P4

ESA 68K-2 J2 J1

ESA 68-2 J1 J6

ESA 196 J1 J2

ESA-31 J2 J1

ESA-51 J10 J7

ESA-51E J5 J3

ESA-86/88-2 J4 J5

ESA-86/88-3 J8 J9

ESA-86/88E J4 J6

4.0 DEMONSTRATION EXAMPLES

DESCRIPTION OF DEMO PROGRAMS

A sample program to illustrate the operation of this interface is listed below. This program can be

entered and executed either from KEYBOARD MODE or from SERIAL MODE of any of ESA

trainers.

The elevator is operated as follows:

Page 4: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

4

Initially, the elevator is at ground floor

When the elevator reaches any floor, it stays at that floor until a request from another floor is

made. When such a request is detected, it moves to that floor.

The floor requests are scanned in fixed order ie floors 0, 1, 2, and 3.

The program will be in the loop and to come out, press RESET key on the trainer

4.1 DEMONSTRATION PROGRAM FOR MPS 85-3 TRAINER

; Assume the interface is connected over J2 of the trainer.

; The trainer can be in KEYBOARD MODE or SERIAL MODE.

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

8C00 3E 82 MVI A,82H ;Initialise 8255

;to mode 0

8C02 D3 43 OUT 43H ;Port A as O/P

;Port B as I/P

8C04 06 00 MVI B,00H ;Elevator at the

;Ground floor.

8C06 78 LOOP1: MOV A,B

8C07 F6 F0 ORI 0F0H ;Clear request

;(Only upper

;4 bits are used)

8C09 D3 40 OUT 40H

8C0B 21 53 8C LXI H,FLOOR

8C0E DB 41 LOOP2: IN 41H ;Get the status of

;request keys

8C10 F6 F0 ORI 0F0H ;Ensure a known

;value for the

;unconnected bits

8C12 4F MOV C,A

8C13 D6 FF SUI 0FFH ;Any request ?

8C15 CA 0E 8C JZ LOOP2 ;No loop back

8C18 79 LOOP3: MOV A,C

8C19 1F RAR ;Determine the floor

;where service is

;required

8C1A 4F MOV C,A

8C1B D2 22 8C JNC DECIDE

8C1E 23 INX H

Page 5: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

5

8C1F C3 18 8C JMP LOOP3

8C22 CD 49 8C DECIDE: CALL DELAY

8C25 7E MOV A,M ;Get the floor

;number

8C26 90 SUB B ;Subtract current

;floor number

8C27 FA 36 8C JM DOWN ;Elevator goes down

8C2A CA 3F 8C JZ RESET ;No movement for

;the elevator

8C2D 04 UP: INR B ;Elevator goes up

8C2E 78 MOV A,B

8C2F F6 F0 ORI 0F0H

8C31 D3 40 OUT 40H ;direction indicator

;LEDs turned on

8C33 C3 22 8C JMP DECIDE

8C36 05 DOWN: DCR B ;Elevator goes down

8C37 78 MOV A,B

8C38 F6 F0 ORI 0F0H

8C3A D3 40 OUT 40H ;direction indicator

;LEDs turned ON

8C3C C3 22 8C JMP DECIDE

8C3F 3E 05 RESET: MVI A,05H

8C41 85 ADD L

8C42 6F MOV L,A

8C43 7E MOV A,M

8C44 D3 40 OUT 40H ;Corresponding

;request indicator

8C46 C3 06 8C JMP LOOP1 ;LED turned off

8C49 11 00 40 DELAY: LXI D,4000H ;Time interval

8C4C 1B DCX D ;between glow of

;successive LEDs

8C4D 7A MOV A,D

8C4E B3 ORA E

8C4F C2 4C 8C JNZ DELAY+3

8C52 C9 RET

8C53 00 03 06 FLOOR: DB 00H, 03H, 06H

09 00 E0 DB 09H, 00H, 0E0H

D3 B6 79 DB 0D3H, 0B6H, 79H

4.2 DEMONSTRATION PROGRAM FOR ESA 85-2 TRAINER

; Assume the interface is connected over J2 of the trainer.

; The trainer can be in KEYBOARD MODE or SERIAL MODE.

Page 6: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

6

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

8000 3E 82 MVI A,82H ;Initialise 8255

;to mode 0

8002 D3 43 OUT 43H ;Port A as O/P

;Port B as I/P

8004 06 00 MVI B,00H ;Elevator at the

;Ground floor.

8006 78 LOOP1: MOV A,B

8007 F6 F0 ORI 0F0H ;Clear request

;(Only upper 4 bits

; are used)

8009 D3 40 OUT 40H

800B 21 53 80 LXI H,FLOOR

800E DB 41 LOOP2: IN 41H ;Get the status

;of request keys

8010 F6 F0 ORI 0F0H ;Ensure a known

;value for the

;unconnected bits

8012 4F MOV C,A

8013 D6 FF SUI 0FFH ;Any request ?

8015 CA 0E 80 JZ LOOP2 ;No loop back

8018 79 LOOP3: MOV A,C

8019 1F RAR ;Determine the

;floor where

;service is

801A 4F MOV C,A ;required

801B D2 22 80 JNC DECIDE

801E 23 INX H

801F C3 18 80 JMP LOOP3

8022 CD 49 80 DECIDE: CALL DELAY

8025 7E MOV A,M ;Get the floor

;number

8026 90 SUB B ;Subtract current

;floor number

8027 FA 36 80 JM DOWN ;Elevator goes down

802A CA 3F 80 JZ RESET ;No movement for

;the elevator

802D 04 UP: INR B ;Elevator goes up

802E 78 MOV A,B

802F F6 F0 ORI 0F0H

8031 D3 40 OUT 40H ;direction indicator

;LEDs turned ON

8033 C3 22 80 JMP DECIDE

Page 7: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

7

8036 05 DOWN: DCR B ;Elevator goes down

8037 78 MOV A,B

8038 F6 F0 ORI 0F0H

803A D3 40 OUT 40H ;direction indicator

;LEDs turned ON

803C C3 22 80 JMP DECIDE

803F 3E 05 RESET: MVI A,05H

8041 85 ADD L

8042 6F MOV L,A

8043 7E MOV A,M

8044 D3 40 OUT 40H ;Corresponding

;request indicator

;LED turned OFF

8046 C3 06 80 JMP LOOP1

8049 11 00 40 DELAY: LXI D,4000H ;Time interval

;between glow of

804C 1B DCX D ;successive LEDs

804D 7A MOV A,D

804E B3 ORA E

804F C2 4C 80 JNZ DELAY+3

8052 C9 RET

8053 00 03 06 FLOOR: DB 00H, 03H, 06H

09 00 E0 DB 09H, 00H, 0E0H

D3 B6 79 DB 0D3H, 0B6H, 79H

4.3 DEMONSTRATION PROGRAM FOR ESA-80 TRAINER

; Assume the interface is connected over J2 of the trainer.

; The trainer can be in KEYBOARD MODE or SERIAL MODE.

CMDPRT EQU 43H

PORT A EQU 40H

PORT B EQU 41H

PORT C EQU 42H

CMDWRD EQU 82H

COUNT EQU 3000H

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

8000 3E 82 LD A,CMDWRD ;Configure 8255

;for mode 0

8002 D3 43 OUT (CMDPRT),A ;Port A O/P

;& Port B I/P

8004 06 00 LD B,00H ;Elevator at

Page 8: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

8

;ground floor

8006 78 LOOP1: LD A,B

8007 F6 F0 OR 0F0H

8009 D3 40 OUT (PORTA),A ;Clear request

;(only upper 4

;bits are used)

800B 21 50 80 LD HL,FLOOR

800E DB 41 LOOP2: IN A,(PORTB) ;Get the status

;of request

;keys Ensure a

8010 F6 F0 OR 0F0H ;known value

8012 4F LD C,A ;for unconnected

;bits

8013 D6 FF SUB 0FFH ;Any request ?

8015 28 F7 JR Z,LOOP2 ;No, loop back

8017 79 LOOP3: LD A,C

8018 1F RRA ;Determine the

;floor where

;service is

8019 4F LD C,A ;required

801A 30 03 JR NC,DECIDE

801C 23 INC HL

801D 18 F8 JR LOOP3

801F CD 42 80 DECIDE: CALL DELAY

8022 7E LD A,(HL) ;Get the floor

;number

8023 90 SUB B ;Subtract current

;floor number.

8024 FA 31 80 JP M,DOWN ;Elevator goes down

8027 28 10 JR Z,RESET ;No movement for

;the elevator.

8029 04 INC B

802A 78 LD A,B ;Elevator goes up

802B F6 F0 OR 0F0H

802D D3 40 OUT (PORTA),A ;Direction

;indicator LEDs

;turned ON.

802F 18 EE JR DECIDE

8031 05 DOWN: DEC B

8032 78 LD A,B ;Elevator goes down

8033 F6 F0 OR 0F0H

8035 D3 40 OUT (PORTA),A ;Direction

;indicator LEDs

;turned ON.

8037 18 E6 JR DECIDE

Page 9: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

9

8039 3E 05 RESET: LD A,05H

803B 85 ADD A,L

803C 6F LD L,A

803D 7E LD A,(HL)

803E D3 40 OUT (PORTA),A ;Corresponding

;request indicator

8040 18 C4 JR LOOP1 ;LED OFF

8042 11 00 30 DELAY: LD DE,COUNT

8045 1B DEC DE

8046 7A LD A,D

8047 B3 OR E

8048 20 FB JR NZ,DELAY+3

804A C9 RET

8050 00 03 06 FLOOR: DEFB 00H, 03H, 06H

8053 09 00 E0 DEFB 09H, 00H, 0E0H

8056 D3 B6 79 DEFB 0D3H, 0B6H, 79H

4.4 DEMONSTRATION PROGRAM FOR ESA-65 TRAINER

; Assume the interface is connected over P4 of the trainer.

; The trainer can be in KEYBOARD MODE or SERIAL MODE.

CMDPRT EQU A043H

PORT A EQU A040H

PORT B EQU A041H

CURFLR EQU 1090H

COUNT1 EQU 20H

COUNT2 EQU 00H

COUNTER1 EQU 1091H

COUNTER2 EQU 1092H

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

1000 A9 82 LDA #82H ;Initialize 8255

;Port A O/P

1002 8D 43 A0 STA CMDPRT ;and Port B I/P

1005 A9 00 LDA #00H ;Elevator at the

1007 8D 90 10 STA CURFLR ;ground floor

;at the beginning

100A AD 90 10 LOOP1: LDA CURFLR

100D 09 F0 ORA #0F0H ;Clear request

;(Only upper 4

100F 8D 40 A0 STA PORT A ;bits are used)

Page 10: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

10

1012 A0 00 LDY #00H ;Get the status of

1014 AD 41 A0 LOOP2: LDA PORT B ;request keys

1017 09 F0 ORA #0F0H ;Ensure a known

1019 AA TAX ;value for the un-

101A 38 SEC ;connected bits

101B E9 FF SBC #0FFH ;Any request?

101D F0 F5 BEQ LOOP2 ;No loop back

101F 8A LOOP3: TXA

1020 4A LSR A ;Determine the

;floor where

;service is

1021 AA TAX ;required

1022 90 04 BCC DECIDE

1024 C8 INY

1025 4C 1F 10 JMP LOOP3

1028 20 60 10 DECIDE: JSR DELAY

102B B9 80 10 LDA FLOOR,Y ;Get the

;floor number

102E 38 SEC

102F ED 90 10 SBC CURFLR ;Subtract current

;floor number.

1032 30 10 BMI DOWN ;Elevator

;goes down

1034 F0 1C BEQ RESET ;No movement for

;the elevator.

1036 EE 90 10 INC CURFLR ;Elevator goes up

1039 AD 90 10 LDA CURFLR

103C 09 F0 ORA #0F0H

103E 8D 40 A0 STA PORT A ;Direction indicator

;LEDs turned ON.

1041 4C 28 10 JMP DECIDE

1044 CE 90 10 DOWN: DEC CURFLR ;Elevator down.

1047 AD 90 10 LDA CURFLR

104A 09 F0 ORA #0F0H

104C 8D 40 A0 STA PORT A ;Direction indicator

;LEDs turned on.

104F 4C 28 10 JMP DECIDE

1052 98 RESET: TYA

1053 18 CLC

1054 69 05 ADC #05H

1056 A8 TAY

1057 B9 80 10 LDA FLOOR,Y

105A 8D 40 A0 STA PORTA ;Corresponding

;request indicator

;LEDs turned OFF.

Page 11: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

11

105D 4C 0A 10 JMP LOOP1

1060 A9 20 DELAY: LDA #COUNT1 ;Time interval

;between glow of

1062 8D 91 10 STA COUNTER1 ;successive LEDs

1065 A9 00 DELAY10: LDA #COUNT2

1067 8D 92 10 STA COUNTER2

106A CE 92 10 DELAY20: DEC COUNTER2

106D D0 FB BNE DELAY20

106F CE 91 10 DEC COUNTER1

1072 D0 F1 BNE DELAY10

1074 60 RTS

ORG 1080H

1080 00 03 06 FLOOR: DB 00H, 03H, 06H

1083 09 00 E0 DB 09H, 00H, E0H

1086 D3 B6 79 DB D3H, B6H, 79H

4.5 DEMONSTRATION PROGRAM FOR ESA-31 TRAINER

; Assume the interface is connected to J2 of the trainer

; The trainer can be in KEYBOARD MODE or SERIAL MODE

SEG EQU 0E8H

P2 EQU 0A0H

DPL EQU 82H

DPH EQU 83H

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

8000 75 A0 E8 START: MOV P2,#SEG ;Initialize 8255

;to mode 0.

8003 78 03 MOV R0,#03H ;PORT A as O/P

8005 74 82 MOV A,#82H ;PORT B as I/P

8007 F2 MOVX @R0,A

8008 E4 CLR A

8009 F8 MOV R0,A ;Elevator at the

800A F9 MOV R1,A ;Ground floor

800B E9 LOOP1: MOV A,R1

800C 44 F0 ORL A,#0F0H ;Clear request

800E 78 00 MOV R0,#00H ;(only upper 4

8010 F2 MOVX @R0,A ;bits are used)

8011 90 80 61 MOV DPTR,#FLOOR

8014 08 INC R0

8015 E2 LOOP2: MOVX A,@R0 ;Get the status

8016 44 F0 ORL A,#0F0H ;of request keys

Page 12: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

12

8018 FA MOV R2,A ;Ensure a known

;value for the

8019 04 INC A ;unconnected

;bits Any

801A 60 F9 JZ LOOP2 ;request?

801C EA LOOP3: MOV A,R2 ;No, loop back

801D 13 RRC A ;Determine the

801E FA MOV R2,A ;floor where

801F 50 03 JNC DECIDE ;service is

8021 A3 INC DPTR ;required

8022 80 F8 SJMP LOOP3

8024 12 80 4E DECIDE: LCALL DELAY

8027 E4 CLR A ;Get the floor

8028 93 MOVC A,@A+DPTR ;number

8029 B5 01 02 CJNE A,1,L1 ;Subtract current

;floor number

802C 80 14 SJMP RESET ;No movement for

;the elevator

802E 40 09 L1: JC DOWN ;Elevator goes

;down

8030 09 UP: INC R1 ;Elevator

;goes up

8031 E9 MOV A,R1

8032 44 F0 ORL A,#0F0 ;Direction indicator

8034 78 00 MOV R0,#00H ;LEDs turned on

8036 F2 MOVX @R0,A

8037 80 EB SJMP DECIDE

8039 19 DOWN: DEC R1 ;Elevator down

803A E9 MOV A,R1

803B 44 F0 ORL A,#0F0H ;Direction indicator

803D 78 00 MOV R0,#00H ;LEDs turned ON

803F F2 MOVX @R0,A

8040 80 E2 SJMP DECIDE

8042 74 05 RESET: MOV A,#05H ;Corresponding

8044 25 82 ADD A,DPL ;request indicator

8046 F5 82 MOV DPL,A ;LED turned OFF

8048 E4 CLR A

8049 F8 MOV R0,A

804A 93 MOVC A,@A+DPTR

804B F2 MOVX @R0,A

804C 80 BD SJMP LOOP1

804E C0 83 DELAY: PUSH DPH

8050 C0 82 PUSH DPL

8052 90 00 00 MOV DPTR,#00H

8055 A3 DELAY1: INC DPTR

Page 13: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

13

8056 E5 83 MOV A,DPH

8058 45 82 ORL A,DPL

805A 70 F9 JNZ DELAY1

805C D0 82 POP DPL

805E D0 83 POP DPH

8060 22 RET

8061 00 03 06 FLOOR: DB 00H,03H,06H

8064 09 00 E0 DB 09H,00H,0E0H

8067 D3 B6 79 DB 0D3H,0B6H,79H

4.6 DEMONSTRATION PROGRAM FOR ESA-68K TRAINER

; Assume the interface is connected over P3 of the trainer.

ORG $40600

PORT A EQU $80300

PORT B EQU $80302

PORT C EQU $80304

CNTPRT EQU $80306

DECIDE EQU $40638

DOWN EQU $40652

CLEAR EQU $40664

DELAY EQU $4066E

DELAY5 EQU $40675

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

040600 13 FC 00 MOVE.B #$82,CNTPRT ;Configure8255

82 00 08 ;in mode 0

03 06 ;PortA as O/P

;portB as I/P

040608 42 00 CLR.B D0 ;Elevator at

04060A 12 00 REPEAT: MOVE.B D0,D1 ;ground floor

04060C 00 01 00 ORI.B #$0F0,D1

F0

040610 13 C1 00 MOVE.B D1,PORTA

08 03 00

040616 20 7C 00 MOVEA.L #$FLOOR,A0

04 06 7D

04061C 14 39 00 CHKRQT: MOVE.B PORTB,D2 ;Get status

08 03 02 ;of request

;keys

040622 00 02 00 ORI.B #$0F0,D2 ;Mask off

Page 14: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

14

F0 ;unused bits in

;the sampled

;data

040626 0C 02 00 CMPI.B #$0FF,D2 ;Any request?

FF

04062A 67 F0 BEQ $CHKRQT ;No, loop back

04062C 42 83 CLR.L D3 ;Yes,

;determine the

04062E 07 02 CHKNXT: BTST D3,D2 ;requesting

040630 67 06 BEQ.S DECIDE ;floor

040632 52 03 ADDQ.B #01,D3

040634 52 88 ADDQ.L #01,A0

040636 60 F6 BRA.S CHKNXT

040638 61 34 DECIDE: BSR.S DELAY ;Duration of

;glow of each

;LED.

04063A 18 10 MOVE.B (A0),D4 ;Determine

;the direction

04063C 98 00 SUB.B D0,D4 ;of movement

;for elevator

04063E 6D 12 BLT.S DOWN ;Elevator

;goes down.

040640 67 22 BEQ.S CLEAR ;No movement

;for elevator

040642 52 00 ADDQ.B #01,D0 ;Elevator

;goes up.

040644 12 00 MOVE.B D0,D1

040646 00 01 00 ORI.B #$0F0,D1 ;Mask off

F0 ;corresponding

;to request keys

04064A 13 C1 00 MOVE.B D1,PORTA

08 03 00

040650 60 E6 BRA.S $DECIDE ;Determine if

;the elevator

;has to go up

;further

040652 04 00 DOWN: SUB.B #01,D0 ;Elevator

00 01 ;goes down

040656 12 00 MOVE.B D0,D1

040658 00 01 00 ORI.B #$0F0,D1

F0

04065C 13 C1 00 MOVE.B D1,PORTA

08 03 00

040662 60 D4 BRA.S DECIDE

Page 15: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

15

040664 5A 88 CLEAR: ADDQ.L #05,A0 ;Elevator

;reached

;requested

;floor

040666 13 D0 00 MOVE.B (A0),PORTA ;Send

08 03 00 ;appropriate

;code to clear

;the request

04066C 60 9C BRA.S REPEAT ;Continue the

;above process

04066E 22 3C 00 DELAY: MOVE.L #COUNT,D1 ;Duration for

00 60 00 ;which each

;LED is kept ON

040674 53 81 DELAY5: SUBQ.L #01,D1 ;during elevator

040676 66 FC BNE DELAY5 ;movement.

040678 4E 75 RTS

04067A 00 03 06 FLOOR: DC.W $0003 ;Codes for

04067C 06 09 DC.W $0609 ;clearing

04067E 00 E0 DC.W $00E0 ;the request

040680 D3 B6 DC.W $D3B6

040681 79 DC.B $79

COUNT: .EQU $6000

4.7 DEMONSTRATION PROGRAM FOR ESA 196 TRAINER

;Assume the interface is connected over J1 of the trainer.

;The trainer can be in KEYBOARD MODE or SERIAL MODE.

REG1 EQU 52H

REG2 EQU 54H

REG3 EQU 58H

REG4 EQU 62H

REG5 EQU 64H

PORT_A EQU 200H

PORT_B EQU 202H

CMD_PORT EQU 206H

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

8000 B1 82 52 LDB REG1,#82H ;Initialise

8003 C7 01 06 02 STB REG1,CMD_PORT ;Port A as O/P

8007 52 ;Port B as I/P.

8008 B1 00 54 LDB REG2,#00H ;Elevator at

Page 16: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

16

;the Ground floor

800B B0 54 52 LOOP1: LDB REG1,REG2 ;Clear request

800E 91 F0 52 ORB REG1,#0F0H ;(Upper 4 bits

8011 C7 01 00 02 STB REG1,PORT_A ;are used).

8015 52

8016 A1 88 80 58 LD REG3,#FLOOR

801A B3 01 02 02 LOOP2: LDB REG1,PORT_B ;Get the status

801E 52 ;of request keys

801F 91 F0 52 ORB REG1,#0F0H ;Ensure a known

8022 B0 52 62 LDB REG4,REG1 ;value for the

8025 79 FF 52 SUBB REG1,#0FFH ;unconnected bits.

8028 DF F0 JE LOOP2 ;Any request? No

;loop back.

802A B0 62 52 LOOP3: LDB REG1,REG4 ;Determine the

802D 18 01 52 SHRB REG1,#01 ;floor where

8030 DB 4C JC CAR ;service is

8032 B0 52 62 LDB REG4,REG1 ;required.

8035 20 00 SJMP DECIDE

8037 EF 3C 00 DECIDE: LCALL DELAY ;Get the floor

803A B2 58 52 LDB REG1,[REG3] ;number. Subtract

803D 78 54 52 SUBB REG1,REG2 ;current floor

;number.

8040 DE 11 JLT DOWN ;Elevator goes down

8042 DF 1E JE RESET ;No movement

;for the elevator.

8044 17 54 UP: INCB REG2 ;Elevator goes up.

8046 B0 54 52 LDB REG1,REG2

8049 91 F0 52 ORB REG1,#0F0H

804C C7 01 00 02 STB REG1,PORT_A ;Direction

8050 52 ;indicator.

8051 27 E4 SJMP DECIDE ;LEDs turned ON.

8053 15 54 DOWN: DECB REG2 ;Elevator goes

8055 B0 54 52 LDB REG1,REG2 ;down routine.

8058 91 F0 52 ORB REG1,#0F0H

805B C7 01 00 02 STB REG1,PORT_A ;Direction

805F 52 ;indicator LEDs

8060 27 D5 SJMP DECIDE ;turned ON.

8062 B1 05 52 RESET: LDB REG1,#05H

8065 74 58 52 ADDB REG1,REG3

8068 B0 52 58 LDB 58H,REG1

806B B2 58 52 LDB REG1,[REG3] ;Corresponding

806E C7 01 00 02 STB REG1,PORT_A ;request indicator

8072 52 ;LED turned OFF

8073 E7 95 FF LJMP LOOP1

8076 A1 00 40 64 DELAY: LD REG5,#4000H ;Time interval

Page 17: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

17

;between glow

807A E1 32 FD DLY: DJNZW 32H,DLY ;of successive

807D F0 RET ;LEDs.

807E 91 80 52 CAR: ORB REG1,#80H

8081 07 58 INC REG3

8083 B0 52 62 LDB REG4,REG1

8086 27 A2 SJMP LOOP3

Enter the following data in data memory D1 from 8088 to 8090

8088 00 03 06 FLOOR: DCB 00H,03H,06H

808B 09 00 E0 DCB 09H,00H,0E0H

808E D3 B6 79 DCB 0D3H,0B6H,79H

4.8 DEMONSTRATION PROGRAM FOR ESA 86/88-2 TRAINER

; Assume the interface is connected over J4 of the trainer.

; The trainer can be in KEYBOARD MODE or SERIAL MODE.

CS = 0.

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

2000 BA E6 FF MOVW DX,#0FFE6 ;Configure

;8255 for mode 0

2003 B0 82 MOVB AL,#82 ;Port A as O/P

;Port B as I/P

2005 EE OUTB DX

2006 31 C0 XORW AX,AX ;Ground floor

;initially

2008 88 E0 LOOP1: MOVB AL,AH ;AH = Floor

;position

200A 0C F0 ORB AL,#0F0 ;Deassert CLR

;Lines PA7 to

200C BA E0 FF MOVW DX,#0FFE0 ;PA4=1 port A

200F EE OUTB DX

2010 BA E2 FF MOVW DX,#0FFE2 ;Port B

2013 EC LOOP2: INB DX ;Get Request

;status

2014 24 0F ANDB AL,#0F ;Strip off

;higher nibble

2016 3C 0F CMPB AL,#0F ;Any request?

2018 74 F9 JZ LOOP2 ;No, continue

;polling

Page 18: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

18

201A BE 00 00 MOVW SI,#00 ;Index of

201D D0 C8 FINDF: RORB AL,1 ;requesting floor

201F 73 04 JNC FOUND ;Floor request

;found

2021 46 INCW SI

2022 EB F9 JMP SHORT FINDF ;Continue

2024 2E CS ;search

2025 8A 84 73 FOUND: MOVB AL,FCODE[SI] ;Get requesting

20 ;floor code

2029 38 E0 CMPB AL,AH ;Compare with

;current

;floor code

202B 77 0D JA GOUP ;Elevator has

;to go up

202D 72 22 JB GODN ;Elevator has

;to go down

202F 2E CS

202F 8A 84 77 CLEAR: MOVB AL,FCLR[SI] ;Correct floor

20 ;clear

2034 BA E0 FF MOVW DX,#0FFE0 ;Port A

2037 EE OUTB DX ;Clear request

2038 EB CE JMP SHORT LOOP1 ;Repeat all over

203A E8 2B 00 GOUP: CALL DELAY ;Delay to simulate

;motion

203D FE C4 INCB AH ;Elevator goes up

203F 86 C4 XCHGB AL,AH

2041 0C F0 ORB AL,#0F0 ;Elevator

;position code

2043 BA E0 FF MOVW DX,#0FFE0 ;On PA3-PA0

2046 EE OUTB DX

2047 24 0F ANDB AL,0F

2049 86 E0 XCHGB AH,AL

204B 38 E0 CMPB AL,AH ;Reached

;requested floor?

204D 75 EB JNZ GOUP ;No, continue

;moving elevator

204F EB DE JMP SHORT CLEAR ;Yes clear

;request

2051 E8 14 00 GODN: CALL DELAY ;Delay to

;simulate motion

2054 FE CC DECB AH ;Elevator

;goes down

2056 86 E0 XCHGB AH,AL

2058 0C F0 ORB AL,#0F0 ;Elevator

;position code

Page 19: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

19

205A BA E0 FF MOVW DX,#0FFE0 ;On PA3-PA0

205D EE OUTB DX

205E 24 0F ANDB AL,#0F

2060 86 C4 XCHGB AL,AH

2062 38 E0 CMPB AL,AH ;Reached

;requested floor

2064 75 EB JNZ GODN ;No continue

;moving elevator

2066 EB C7 JMP SHORT CLEAR ;Yes, clear

;request

2068 B9 00 08 DELAY: MOVW CX,#0800 ;Time interval

206B E2 FE LOOP $ ;between glow of

206D B9 FF FF MOVW CX,#0FFFF ;successive LED's

2070 E2 FE LOOP $

2072 C3 RET

2073 00 03 06 09 FCODE: DB 00H,03H,06H,09H ;Position codes

;for floors

2077 E0 D3 B6 79 FCLR: DB 0E0H,0D3H,0B6H,79H ;Clear position

;code for

;each floor

4.9 DEMONSTRATION PROGRAM FOR ESA 68-2 TRAINER

; Assume the interface is connected over J1 of the trainer.

; The trainer can be in Keyboard or Serial mode.

CNTLA EQU 0C801H

CNTLB EQU 0C803H

DIRA EQU 0C800H

DIRB EQU 0C802H

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

0400 ORG 400H ;USER RAM STARTS FROM 400H

0400 CC 05 50 LDD #550H ;INITIALISE THE STACK

0403 1F 04 TFR D,S

0405 4F CLRA

0406 B7 C8 01 STA CNTLA ;INITIALISE 6821

0409 B7 C8 03 STA CNTLB ;PORT A AS O/P

040C B7 C8 02 STA DIRB ;PORT B I/P.

040F B7 04 82 STA BREG ;ELEVATOR AT GROUND FLOOR

0412 43 COMA

0413 B7 C8 00 STA DIRA

0416 B7 C8 01 STA CNTLA

Page 20: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

20

0419 B7 C8 03 STA CNTLB

041C B6 04 82 LOOP1: LDA BREG ;CLEAR REQUEST

041F 8A F0 ORA #0F0H ;ONLY UPPER 4BITS ARE

;USED

0421 B7 C8 00 STA DIRA

0424 10 8E 04 77 LDY #FLOOR

0428 B6 C8 02 LOOP2: LDA DIRB ;GET THE STATUS OF

042B 8A F0 ORA #0F0H ;REQUEST KEYS

042D B7 04 80 STA CREG ;ENSURE A KNOWN VALUE

0430 80 FF SUBA #0FFH ;FOR THE UNCONNECTED BITS

0432 27 F4 BEQ LOOP2 ;ANY REQUEST ? NO, LOOP

;BACK.

0434 B6 04 80 LOOP3: LDA CREG ;DETERMINE THE FLOOR

0437 46 RORA ;WHERE SERVICE IS

;REQUIRED

0438 B7 04 80 STA CREG

043B 24 05 BCC DECIDE

043D A6 A0 LDA ,Y+

043F 7E 04 34 JMP LOOP3

0442 8D 2A DECIDE: BSR DELAY ;GET THE FLOOR NUMBER

0444 A6 A4 LDA Y ;SUBTRACT CURRENT FLOOR

0446 B0 04 82 SUBA BREG ;NUMBER

0449 2B 0F BMI DOWN ;ELEVATOR GOES DOWN

044B 27 1A BEQ RESET ;NO MOVEMENT

044D 7C 04 82 UP: INC BREG ;ELEVATOR GOES UP

0450 B6 04 82 LDA BREG

0453 8A F0 ORA #0F0H ;DIRECTION INDICATOR

0455 B7 C8 00 STA DIRA ;LED'S TURNED ON

0458 20 E8 BRA DECIDE

045A 7A 04 82 DOWN: DEC BREG ;DOWN ROUTINE

045D B6 04 82 LDA BREG

0460 8A F0 ORA #0F0H

0462 B7 C8 00 STA DIRA

0465 20 DB BRA DECIDE

0467 A6 25 RESET: LDA 5,Y ;RESET ROUTINE

0469 B7 C8 00 STA DIRA ;CORRESPONDING REQUEST

046C 20 AE BRA LOOP1 ;LED'S TURNED OFF

046E CC FF FF DELAY: LDD #0FFFFH ;DELAY ROUTINE

0471 83 00 01 DL1: SUBD #1 ;TIME INTERVAL BETWEEN

0474 26 FB BNE DL1 ;GLOW OF SUCCESSIVE LEDS

0476 39 RTS

0477 00 03 06 FLOOR: FCB 00H,03H,06H

047A 09 00 E0 FCB 09H,00H,0E0H

047D D3 B6 79 FCB 0D3H,0B6H,79H

0480 00 00 CREG FDB 0

Page 21: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

21

0482 00 00 BREG FDB 0

4.10 DEMONSTRATION PROGRAM FOR ESA 68K-2 TRAINER

; Assume the interface is connected over J2 of the trainer.

; The trainer must be in SERIAL mode only.

PORTA EQU 800011H

PORTB EQU 800017H

PA_CT EQU 80000DH

PA_DI EQU 800005H

PB_CT EQU 80000FH

PB_DI EQU 800007H

ADDRESS OPCODE LABLE MNEMONICS COMMENTS

400400 13FC 0000 MOVE.B #0,PA_CT ;Initialise Port

0080 000D ;A in mode 0

400408 13FC 00FF MOVE.B #$FF,PA_DI ;Making Port A

0080 0005 ;O/P.

400410 4200 CLR.B D0 ;Elevator at

;ground floor

400412 1200 RE: MOVE.B D0,D1

400414 0001 00F0 ORI.B #$0F0,D1 ;Clear request

400418 13C1 0080 MOVE.B D1,PORTA

0011

40041E 207C 0040 MOVEA.L #FLOOR,A0

047E

400424 1439 0080 CHK: MOVE.B PORTB,D2

0017

40042A 0002 00F0 ORI.B #$0F0,D2 ;Ensure known

;value for

;unconnected bits

40042E 0C02 00FF CMPI.B #$0FF,D2 ;Any request?

400432 67F0 BEQ.S CHK ;No. loop

400434 4283 CLR.L D3

400436 0702 CNXT: BTST D3,D2

400438 6706 BEQ.S DEC

40043A 5203 ADDQ.B #01,D3

40043C 5288 ADDQ.L #01,A0

40043E 60F6 BRA.S CNXT

400440 6132 DEC: BSR.S DELAY

400442 1810 MOVE.B (A0),D4

400444 9800 SUB.B D0,D4

Page 22: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

22

400446 6D12 BLT.S DOWN

400448 6720 BEQ.S CLEAR

40044A 5200 ADDQ.B #01,D0

40044C 1200 MOVE.B D0,D1

40044E 0001 00F0 ORI.B #$0F0,D1

400452 13C1 0080 MOVE.B D1,PORTA

0011

400458 60E6 BRA.S DEC

40045A 5300 DOWN: SUBQ.B #01,D0 ;Elevator down

40045C 1200 MOVE.B D0,D1 ;direction

;indicator

40045E 0001 00F0 ORI.B #$0F0,D1 ;LEDs turned ON

400462 13C1 0080 MOVE.B D1,PORTA

0011

400468 60D6 BRA.S DEC

40046A 5A88 CLEAR: ADDQ.L #05,A0

40046C 13D0 0080 MOVE.B (A0),PORTA

0011

400472 609E BRA.S RE

400474 3A3C 7FFF DELAY: MOVE.W #$7FFF,D5 ;Time interval

;between glow

400478 57CD FFFE DE5: DBEQ D5,DE5 ;of successive

;LEDS.

40047C 4E75 RTS

40047E 00 03 06 FLOOR:.BYTE 00,03,06

400481 09 00 E0 .BYTE 09,00,E0H

400484 D3 B6 79 .BYTE D3H,B6H,79H

4.11 DEMONSTRATION PROGRAM FOR ESA-51 TRAINER

;Assume the interface is connected to J10 of the trainer.

;The trainer can be in KEYBOARD MODE or IN SERIAL MODE.

SEG EQU 0E8H

DPL EQU 82H

DPH EQU 83H

ADDRESS OPCODE LABEL MNEMONIC COMMENTS

8000 75 A0 E8 START: MOV P2,#SEG ;Initialize 8255

8003 78 03 MOV R0,#03H ;in mode 0

8005 74 82 MOV A,#82H ;PORTA as O/P

8007 F2 MOVX @R0,A ;PORTB as I/P

8008 E4 CLR A

Page 23: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

23

8009 F8 MOV R0,A ;Elevator at the

800A F9 MOV R1,A ;Ground Floor

800B E9 LOOP1: MOV A,R1

800C 44 F0 ORL A,#0F0H ;Clear request

800E 78 00 MOV R0,#00H ;(only upper 4

8010 F2 MOVX @R0,A ;bits are used)

8011 90 80 61 MOV DPTR,#FLOOR

8014 08 INC R0

8015 E2 LOOP2: MOVX A,@R0 ;Get the status

8016 44 F0 ORL A,#0F0H ;of request keys

8018 FA MOV R2,A ;Ensure a known

;value for the

8019 04 INC A ;unconnected

801A 60 F9 JZ LOOP2 ;bits any

;request?

801C EA LOOP3: MOV A,R2 ;No, loop back

801D 13 RRC A ;Determine the

801E FA MOV R2,A ;floor where

801F 50 03 JNC DECIDE ;service is

8021 A3 INC DPTR ;required

8022 80 F8 SJMP LOOP3

8024 12 80 4E DECIDE: LCALL DELAY

8027 E4 CLR A ;Get the floor

8028 93 MOVC A,@A+DPTR ;number

8029 B5 01 02 CJNE A,1,L1 ;Subtract current

;floor number

802C 80 14 SJMP RESET ;No movement for

;the elevator

802E 40 09 L1: JC DOWN ;Elevator goes

;down

8030 09 UP: INC R1 ;Elevator goes up

8031 E9 MOV A,R1

8032 44 F0 ORL A,#0F0H ;Direction

;indicator

8034 78 00 MOV R0,#00H ;LEDs turned ON

8036 F2 MOVX @R0,A

8037 80 EB SJMP DECIDE

8039 19 DOWN: DEC R1 ;Elevator down

803A E9 MOV A,R1

803B 44 F0 ORL A,#0F0H ;Direction

;indicator LED's

803D 78 00 MOV R0,#00H ;turned ON

803F F2 MOVX @R0,A

8040 80 E2 SJMP DECIDE

8042 74 05 RESET: MOV A,#05H ;Corresponding

Page 24: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

24

8044 25 82 ADD A,82H ;request

;indicator

8046 F5 82 MOV 82H,A ;LED turned OFF

8048 E4 CLR A

8049 F8 MOV R0,A

804A 93 MOVC A,@A+DPTR

804B F2 MOVX @R0,A

804C 80 BD SJMP LOOP1

804E C0 83 DELAY: PUSH DPH

8050 C0 82 PUSH DPL

8052 90 00 00 MOV DPTR,#00H

8055 A3 DELAY1: INC DPTR

8056 E5 83 MOV A,DPH

8058 45 82 ORL A,DPL

805A 70 F9 JNZ DELAY1

805C D0 82 POP DPL

805E D0 83 POP DPH

8060 22 RET

8061 00 03 06 FLOOR: DB 00H,03H,06H

8064 09 00 E0 DB 09H,00H,0E0H

8067 D3 B6 79 DB 0D3H,0B6H,79H

4.12 DEMONSTRATION PROGRAM FOR ESA 86/88-3 TRAINER

; Assume the interface is connected to J8 of the trainer.

; This program module illustrates the working if the elevator

; in both Upward and Downward directions

; The program can be executed in STAND-ALONE MODE or SERIAL

; MODE of operation.

; The program starts at memory location 0:2000H

; Please refer ESA 86/88-3 user's manual for mnemonic syntax

; suitable to trainer

Code Segment :0000H

FCODE EQU 2100H

FCLR EQU 2104H

ADDRESS OPCODE LABEL MNEMONIC COMMENTS

2000 BA E6 FF MOVW DX,0FFE6H ;Configure 8255

2003 B0 82 MOVB AL,82H ;Port A as o/p,

2005 EE OUTB DX,AL ;Port B as i/p

2006 33 C0 XORW AX,AX ;Initial stage is

;ground floor

Page 25: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

25

2008 8A C4 LOOP1: MOVB AL,AH ;AH is the floor

200A 0C F0 ORB AL,0F0H ;position

200C BA E0 FF MOVW DX,0FFE0H

200F EE OUTB DX,AL

2010 BA E2 FF MOVW DX,0FFE2H

2013 EC LOOP2: INB AL,DX ;Get request

2014 24 0F ANDB AL,0FH

2016 3C 0F CMPB AL,0FH

2018 74 F9 JZ LOOP2

201A BE 00 00 MOVW SI,00H

201D D0 C8 FINDF: RORB AL,01H

201F 73 03 JNC FOUND ;If requested

2021 46 INCW SI ;floor found,

;update pointer

2022 EB F9 JMP FINDF ;Else, continue

;search

2024 8A 84 00 21 FOUND: MOVB AL,[SI]FCODE ;Get requesting

2028 3A C4 CMPB AL,AH ;floor code and

;compare with

;current floor

;code

202A 77 0C JA GOUP ;If needed go UP

202C 72 21 JB GODN ;If needed go

;DOWN

202E 8A 84 04 21 CLEAR: MOVB AL,[SI]FCLR

2032 BA E0 FF MOVB DX,0FFE0H

2035 EE OUTB DX,AL

2036 EB D0 JMP LOOP1

2038 E8 2B 00 GOUP: CALL DELAY

203B FE C4 INCB AH ;Elevator goes UP

203D 86 C4 XCHGB AL,AH ;by one LED

203F 0C F0 ORB AL,0F0H

2041 BA E0 FF MOVW DX,0FFE0H

2044 EE OUTB DX,AL

2045 24 0F ANDB AL,0FH

2047 86 E0 XCHGB AH,AL

2049 3A C4 CMPB AL,AH

204B 75 EB JNZ GOUP

204D EB DF JMP CLEAR

204F E8 14 00 GODN: CALL DELAY

2052 FE CC DECB AH ;Elevator goes

2054 86 E0 XCHGB AH,AL ;DOWN by one LED

2056 0C F0 ORB AL,0F0H

2058 BA E0 FF MOVW DX,0FFE0H

205B EE OUTB DX,AL

Page 26: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

26

205C 24 0F ANDB AL,0FH

205E 86 C4 XCHGB AL,AH

2060 3A C4 CMPB AL,AH

2062 75 EB JNZ GODN

2064 EB C8 JMP CLEAR

2066 B9 00 08 DELAY: MOVW CX,0800H ;Delay between

2069 E2 FE LOOP $ ;glow of

;successive LEDs

206B B9 FF FF MOVW CX,0FFFFH

206E E2 FE LOOP $

2070 C3 RET

2100 ORG 2100H

2100 00 03 06 09 VALUE1: DB 00H,03H,06H,09H ;Position codes

;for floors

2104 E0 D3 B6 79 VALUE2: DB E0H,D3H,B6H,79H ;Clear code +

;Position code

4.13 DEMONSTRATION PROGRAM FOR ESA-51E TRAINER

;Assume the interface is connected to J5 of the trainer.

;The trainer can be in KEYBOARD MODE or IN SERIAL MODE.

SEG EQU 0E8H

DPL EQU 82H

DPH EQU 83H

P2 EQU 0A0H

ADDRESS OPCODE LABEL MNEMONIC COMMENTS

8000 75 A0 E8 START: MOV P2,#SEG ;Initialize 8255

8003 78 03 MOV R0,#03H ;in mode 0

8005 74 82 MOV A,#82H ;PORTA as O/P

8007 F2 MOVX @R0,A ;PORTB as I/P

8008 E4 CLR A

8009 F8 MOV R0,A ;Elevator at the

800A F9 MOV R1,A ;Ground Floor

800B E9 LOOP1: MOV A,R1

800C 44 F0 ORL A,#0F0H ;Clear request

800E 78 00 MOV R0,#00H ;(only upper 4

8010 F2 MOVX @R0,A ;bits are used)

8011 90 80 61 MOV DPTR,#FLOOR

8014 08 INC R0

8015 E2 LOOP2: MOVX A,@R0 ;Get the status

Page 27: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

27

8016 44 F0 ORL A,#0F0H ;of request keys

8018 FA MOV R2,A ;Ensure a known

;value for the

8019 04 INC A ;unconnected

801A 60 F9 JZ LOOP2 ;bits any

;request?

801C EA LOOP3: MOV A,R2 ;No, loop back

801D 13 RRC A ;Determine the

801E FA MOV R2,A ;floor where

801F 50 03 JNC DECIDE ;service is

8021 A3 INC DPTR ;required

8022 80 F8 SJMP LOOP3

8024 12 80 4E DECIDE: LCALL DELAY

8027 E4 CLR A ;Get the floor

8028 93 MOVC A,@A+DPTR ;number

8029 B5 01 02 CJNE A,1,L1 ;Subtract current

;floor number

802C 80 14 SJMP RESET ;No movement for

;the elevator

802E 40 09 L1: JC DOWN ;Elevator goes

;down

8030 09 UP: INC R1 ;Elevator goes up

8031 E9 MOV A,R1

8032 44 F0 ORL A,#0F0H ;Direction

;indicator

8034 78 00 MOV R0,#00H ;LEDs turned on

8036 F2 MOVX @R0,A

8037 80 EB SJMP DECIDE

8039 19 DOWN: DEC R1 ;Elevator down

803A E9 MOV A,R1

803B 44 F0 ORL A,#0F0H ;Direction

;indicator LED's

803D 78 00 MOV R0,#00H ;turned ON

803F F2 MOVX @R0,A

8040 80 E2 SJMP DECIDE

8042 74 05 RESET: MOV A,#05H ;Corresponding

8044 25 82 ADD A,82H ;request

;indicator

8046 F5 82 MOV 82H,A ;LED turned OFF

8048 E4 CLR A

8049 F8 MOV R0,A

804A 93 MOVC A,@A+DPTR

804B F2 MOVX @R0,A

804C 80 BD SJMP LOOP1

804E C0 83 DELAY: PUSH DPH

Page 28: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

28

8050 C0 82 PUSH DPL

8052 90 00 00 MOV DPTR,#00H

8055 A3 DELAY1: INC DPTR

8056 E5 83 MOV A,DPH

8058 45 82 ORL A,DPL

805A 70 F9 JNZ DELAY1

805C D0 82 POP DPL

805E D0 83 POP DPH

8060 22 RET

8061 00 03 06 FLOOR: DB 00H,03H,06H

8064 09 00 E0 DB 09H,00H,0E0H

8067 D3 B6 79 DB 0D3H,0B6H,79H

4.14 DEMONSTRATION PROGRAM FOR ESA 86/88E TRAINER

; Assume the interface is connected to J4 of the trainer.

; This program module illustrates the working if the elevator

; in both Upward and Downward directions

; The program can be executed in STAND-ALONE MODE or SERIAL

; MODE of operation.

; The program starts at memory location 0:2000H

; Please refer ESA 86/88E user's manual for mnemonic syntax

; suitable to trainer

Code Segment :0000H

FCODE EQU 2100H

FCLR EQU 2104H

ADDRESS OPCODE LABEL MNEMONIC COMMENTS

2000 BA E6 FF MOVW DX,0FFE6H ;Configure 8255

2003 B0 82 MOVB AL,82H ;Port A as o/p,

2005 EE OUTB DX,AL ;Port B as i/p

2006 33 C0 XORW AX,AX ;Initial stage is

;ground floor

2008 8A C4 LOOP1: MOVB AL,AH ;AH is the floor

200A 0C F0 ORB AL,0F0H ;position

200C BA E0 FF MOVW DX,0FFE0H

200F EE OUTB DX,AL

2010 BA E2 FF MOVW DX,0FFE2H

2013 EC LOOP2: INB AL,DX ;Get request

2014 24 0F ANDB AL,0FH

2016 3C 0F CMPB AL,0FH

Page 29: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

29

2018 74 F9 JZ LOOP2

201A BE 00 00 MOVW SI,00H

201D D0 C8 FINDF: RORB AL,01H

201F 73 03 JNC FOUND ;If requested

2021 46 INCW SI ;floor found,

;update pointer

2022 EB F9 JMP FINDF ;Else, continue

;search

2024 8A 84 00 21 FOUND: MOVB AL,FCODE[SI] ;Get requesting

2028 3A C4 CMPB AL,AH ;floor code and

;compare with

;current floor

;code

202A 77 0C JA GOUP ;If needed go UP

202C 72 21 JB GODN ;If needed go

;DOWN

202E 8A 84 04 21 CLEAR: MOVB AL,FCLR[SI]

2032 BA E0 FF MOVB DX,0FFE0H

2035 EE OUTB DX,AL

2036 EB D0 JMP LOOP1

2038 E8 2B 00 GOUP: CALL DELAY

203B FE C4 INCB AH ;Elevator goes UP

203D 86 C4 XCHGB AL,AH ;by one LED

203F 0C F0 ORB AL,0F0H

2041 BA E0 FF MOVW DX,0FFE0H

2044 EE OUTB DX,AL

2045 24 0F ANDB AL,0FH

2047 86 E0 XCHGB AH,AL

2049 3A C4 CMPB AL,AH

204B 75 EB JNZ GOUP

204D EB DF JMP CLEAR

204F E8 14 00 GODN: CALL DELAY

2052 FE CC DECB AH ;Elevator goes

2054 86 E0 XCHGB AH,AL ;DOWN by one LED

2056 0C F0 ORB AL,0F0H

2058 BA E0 FF MOVW DX,0FFE0H

205B EE OUTB DX,AL

205C 24 0F ANDB AL,0FH

205E 86 C4 XCHGB AL,AH

2060 3A C4 CMPB AL,AH

2062 75 EB JNZ GODN

2064 EB C8 JMP CLEAR

2066 B9 00 08 DELAY: MOVW CX,0800H ;Delay between

2069 E2 FE LOOP $ ;glow of

;successive LEDs

Page 30: Intel's MCS-51 family of microcontrollers and its ... viz 8085, Z-80, 6502, 8031, 8086/8088, ... 8C25 7E MOV A,M ;Get the floor ; number 8C26 90 ... ADDRESS OPCODE …

ELEVATOR INTERFACE

30

206B B9 FF FF MOVW CX,0FFFFH

206E E2 FE LOOP $

2070 C3 RET

2100 ORG 2100H

2100 00 03 06 09 VALUE1: DB 00H,03H,06H,09H ;Position codes

;for floors

2104 E0 D3 B6 79 VALUE2: DB E0H,D3H,B6H,79H ;Clear code +

;Position code