DATO1 EQU 20H DATO2 EQU 21H DATO3 EQU 22H TECLA EQU 23H TECLA1 EQU 24H TECLA2 EQU 25H…
- User
DATO1 EQU 20H DATO2 EQU 21H DATO3 EQU 22H TECLA EQU 23H TECLA1 EQU 24H TECLA2 EQU 25H
ORG 00H GOTO STARTDELAY MOVLW .10 MOVWF DATO1 DELAY_3 MOVLW .100 MOVWF DATO2 DELAY_2 MOVLW .250 MOVWF DATO3 DELAY_1 DECFSZ DATO3,F GOTO DELAY_1 DECFSZ DATO2,F GOTO DELAY_2 DECFSZ DATO1,F GOTO DELAY_3
RETURNSTART BSF STATUS,05H ; CONFIGURACION DE PUERTOS MOVLW 0FH MOVWF TRISB MOVLW 0FFH MOVWF TRISC BCF STATUS,05H CLRF PORTB
VOLVER
CALL DELAYBSF PORTB,.6 ;ABRIMOS PUERTAAQUI0 MOVF PORTB,W MOVWF TECLA MOVLW 07H ANDWF TECLA,F MOVLW 07H XORWF TECLA,W BTFSS STATUS,Z GOTO AQUI0
BCF PORTB,.6 ; DESACTIVAMOS PUERTASEGUIR CALL DELAY
MOVF PORTB,W ; VERIFICAMOS QUE ENTREN LAS PERSONAS MOVWF TECLA MOVLW 07H ANDWF TECLA,F MOVLW 06H XORWF TECLA,W BTFSS STATUS,Z GOTO SEGUIRAQUI1 CALL DELAY MOVF PORTC,W ; VERIFICACION DE PISO DESEADO MOVWF TECLA1 MOVLW 07H ANDWF TECLA1,F MOVLW 00H XORWF TECLA1,W BTFSC STATUS,Z GOTO AQUI1
BSF PORTB,.7 ; CERRAMOS PUERTAAQUI2 MOVF PORTB,W MOVWF TECLA MOVLW 07H ANDWF TECLA,F MOVLW 07H XORWF TECLA,W BTFSS STATUS,Z GOTO AQUI2
BCF PORTB,.7 ;DESACTIVAMOS PUERTA CALL DELAY MOVF PORTB,W MOVWF TECLA MOVLW 07H ANDWF TECLA,W SUBWF TECLA1,W BTFSS STATUS,C GOTO BAJAR BSF PORTB,.4 ; ELEVADOR SUBIR AL PISOAQUI3 CALL DELAY MOVF PORTB,W MOVWF TECLA MOVLW 07H ANDWF TECLA,W XORWF TECLA1,W BTFSS STATUS,Z GOTO AQUI3
CALL DELAY BCF PORTB,.4 GOTO VOLVERBAJAR BSF PORTB,.5 ; ELEVADOR BAJAR AL PISO
AQUI4 CALL DELAY MOVF PORTB,W MOVWF TECLA MOVLW 07H ANDWF TECLA,W XORWF TECLA1,W BTFSS STATUS,Z GOTO AQUI4CALL DELAY BCF PORTB,.5 GOTO VOLVERSALIR CALL DELAY MOVF PORTC,W MOVWF TECLA2 MOVLW 70H ANDWF TECLA2,F SWAPF TECLA2,F MOVLW 00H XORWF TECLA2,W BTFSC STATUS,Z GOTO SEGUIR
BSF PORTB,.7 ; CERRAMOS PUERTAAQUI5 MOVF PORTB,W MOVWF TECLA MOVLW 07H ANDWF TECLA,F MOVLW 07H XORWF TECLA,W BTFSS STATUS,Z GOTO AQUI5
BCF PORTB,.7 ;DESACTIVAMOS PUERTA CALL DELAY MOVF PORTB,W MOVWF TECLA MOVLW 07H ANDWF TECLA,W SUBWF TECLA2,W BTFSS STATUS,C GOTO BAJAR1 BSF PORTB,.4 ; ELEVADOR SUBIR AL PISOAQUI6 CALL DELAY MOVF PORTB,W MOVWF TECLA MOVLW 07H ANDWF TECLA,W XORWF TECLA2,W BTFSS STATUS,Z GOTO AQUI6
CALL DELAY BCF PORTB,.4 GOTO VOLVERBAJAR1 BSF PORTB,.5 ; ELEVADOR BAJAR AL PISO
AQUI7 CALL DELAY MOVF PORTB,W MOVWF TECLA MOVLW 07H ANDWF TECLA,W XORWF TECLA2,W BTFSS STATUS,Z GOTO AQUI7CALL DELAY BCF PORTB,.5 GOTO VOLVER END - Assistant
The given code is a program designed to control an elevator. Here's a breakdown of what each section does:
-
Constants: The DATO1, DATO2, DATO3, TECLA, TECLA1, and TECLA2 labels are assigned memory addresses for storage.
-
Delay subroutine: This subroutine creates a delay by looping through nested decrement and skip instructions.
-
Initialization: This section initializes the ports and sets the TRISB and TRISC registers.
-
Volving loop: This loop repeatedly calls the delay subroutine.
-
Opening the door: Sets the .6 bit of PORTB to open the door and waits for a button press.
-
Checking for people: Waits for a button press on the .6 bit of PORTB.
-
Selecting desired floor: Waits for a button press on the .0-.2 bits of PORTC.
-
Closing the door: Sets the .7 bit of PORTB to close the door and waits for the door to fully close.
-
Moving elevator up: Sets the .4 bit of PORTB to move the elevator up and waits for it to reach the desired floor.
-
Moving elevator down: Sets the .5 bit of PORTB to move the elevator down and waits for it to reach the desired floor.
-
Exiting the elevator: Waits for a button press on the .4 and .5 bits of PORTC.
-
Closing the door after exiting: Sets the .7 bit of PORTB to close the door and waits for the door to fully close.
-
Moving elevator up after exiting: Sets the .4 bit of PORTB to move the elevator up and waits for it to reach the desired floor.
-
Moving elevator down after exiting: Sets the .5 bit of PORTB to move the elevator down and waits for it to reach the desired floor.
-
End of program.
-