Skip to content

Step 10 of 11

Review final program and save

Goal

Have the final commented .ASM saved and working — template for other labs.

Compare your file with the version below. Add comments if missing.

Full path: CONFIG → reset → TRIS → LAT → PORT. You will repeat this order in First LED and Practice 1.

  1. Align comments with the final version below.
  2. Save guia-puertos.asm in your course folder (backup).
  3. Simulate one last time: button controls LED.
  4. Mark step done and continue to the test (step 10).
						        LIST    P=18F4550
        #include <P18F4550.INC>

        CONFIG  FOSC = HS
        CONFIG  WDT = OFF
        CONFIG  LVP = OFF
        CONFIG  PBADEN = OFF

        ORG     0x0000
        GOTO    inicio

; --- init: direccion de pines (TRIS) ---
init_gpio:
        BCF     TRISB, 0      ; RB0 → salida (LED)
        BSF     TRISB, 1      ; RB1 → entrada (pulsador NA)
        RETURN

; --- programa principal ---
inicio:
        CALL    init_gpio
        BCF     LATB, 0       ; LED apagado al inicio
bucle:
        BTFSC   PORTB, 1      ; lee RB1 con PORT
        BCF     LATB, 0       ; suelto → apaga LED (LAT)
        BTFSS   PORTB, 1
        BSF     LATB, 0       ; presionado → enciende LED
        GOTO    bucle

        END
					
  • My program matches the final logic and builds.
  • I saved a copy of the `.ASM`.
  • I can explain TRIS, LAT, and PORT out loud.