Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

DATO1 EQU 20H DATO2 EQU 21H DATO3 EQU 22H TECLA EQU 23H TECLA1 EQU 24H TECLA2 EQU 25H…

  1. User

    DATO1 EQU 20H DATO2 EQU 21H DATO3 EQU 22H TECLA EQU 23H TECLA1 EQU 24H TECLA2 EQU 25H

          ORG 00H
          GOTO START
    

    DELAY 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
    RETURN

    START BSF STATUS,05H ; CONFIGURACION DE PUERTOS MOVLW 0FH MOVWF TRISB MOVLW 0FFH MOVWF TRISC BCF STATUS,05H CLRF PORTB
    VOLVER
    CALL DELAY

          BSF    PORTB,.6    ;ABRIMOS PUERTA
    

    AQUI0 MOVF PORTB,W MOVWF TECLA MOVLW 07H ANDWF TECLA,F MOVLW 07H XORWF TECLA,W BTFSS STATUS,Z GOTO AQUI0

          BCF    PORTB,.6    ; DESACTIVAMOS PUERTA
    

    SEGUIR 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   SEGUIR
    

    AQUI1 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 PUERTA
    

    AQUI2 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 PISO
    

    AQUI3 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   VOLVER 
    

    BAJAR 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 AQUI4

          CALL   DELAY
          BCF    PORTB,.5
          GOTO   VOLVER
    

    SALIR 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 PUERTA
    

    AQUI5 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 PISO
    

    AQUI6 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   VOLVER 
    

    BAJAR1 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 AQUI7

          CALL   DELAY
          BCF    PORTB,.5
          GOTO   VOLVER
     
          END
    
  2. Assistant

    The given code is a program designed to control an elevator. Here's a breakdown of what each section does:

    1. Constants: The DATO1, DATO2, DATO3, TECLA, TECLA1, and TECLA2 labels are assigned memory addresses for storage.

    2. Delay subroutine: This subroutine creates a delay by looping through nested decrement and skip instructions.

    3. Initialization: This section initializes the ports and sets the TRISB and TRISC registers.

    4. Volving loop: This loop repeatedly calls the delay subroutine.

    5. Opening the door: Sets the .6 bit of PORTB to open the door and waits for a button press.

    6. Checking for people: Waits for a button press on the .6 bit of PORTB.

    7. Selecting desired floor: Waits for a button press on the .0-.2 bits of PORTC.

    8. Closing the door: Sets the .7 bit of PORTB to close the door and waits for the door to fully close.

    9. Moving elevator up: Sets the .4 bit of PORTB to move the elevator up and waits for it to reach the desired floor.

    10. Moving elevator down: Sets the .5 bit of PORTB to move the elevator down and waits for it to reach the desired floor.

    11. Exiting the elevator: Waits for a button press on the .4 and .5 bits of PORTC.

    12. Closing the door after exiting: Sets the .7 bit of PORTB to close the door and waits for the door to fully close.

    13. 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.

    14. 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.

    15. End of program.