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.
Follow these steps
- After CONFIG and before END, paste the structure from Your file so far (ORG, init_gpio, inicio, bucle).
- Check: one
iniciolabel, onebuclewithGOTO bucle. - Build — BUILD SUCCESSFUL. The program does not light anything yet; that is normal.
- Mark this step done only if it builds.
Your file so far
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
What you add in this step
ORG 0x0000
GOTO inicio
init_gpio:
RETURN
inicio:
CALL init_gpio
bucle:
GOTO bucle
Checklist before you continue
- `ORG 0x0000` with `GOTO inicio` exists.
- `init_gpio` with RETURN, `inicio` with CALL init_gpio, and infinite loop exist.
- Builds with no errors.