Skip to content

Step 5 of 11

Reset vector and sandwich layout

Goal

Complete program structure: reset at 0x0000, init_gpio subroutine, inicio, and loop.

ORG 0x0000 + GOTO inicio is the reset vector: on power-up the PIC jumps to inicio.

sandwich style: subroutines on top, main program below. init_gpio only has RETURN — we add TRIS in step 5.

  1. After CONFIG and before END, paste the structure from Your file so far (ORG, init_gpio, inicio, bucle).
  2. Check: one inicio label, one bucle with GOTO bucle.
  3. Build — BUILD SUCCESSFUL. The program does not light anything yet; that is normal.
  4. Mark this step done only if it builds.
						        LIST    P=18F4550
        #include <P18F4550.INC>

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

        ORG     0x0000
        GOTO    inicio

; --- subrutinas (medio sandwich) ---
init_gpio:
        RETURN

; --- programa principal (abajo) ---
inicio:
        CALL    init_gpio
bucle:
        GOTO    bucle

        END
					
						        ORG     0x0000
        GOTO    inicio

init_gpio:
        RETURN

inicio:
        CALL    init_gpio
bucle:
        GOTO    bucle
					
  • `ORG 0x0000` with `GOTO inicio` exists.
  • `init_gpio` with RETURN, `inicio` with CALL init_gpio, and infinite loop exist.
  • Builds with no errors.