Program 06: Addition of Two 8-bit Numbers
PIC18F4550 · Assembly

PROCESSOR 18F4550
   #include <xc.inc>

   PSECT mycode

        MOVLW     025H           ; W = 25H (first 8-bit value)
        MOVWF     20H, a         ; store first value at 20H

        MOVLW     037H           ; W = 37H (second 8-bit value)
        MOVWF     21H, a         ; store second value at 21H

        MOVF      20H, W, a      ; W = 25H
        ADDWF     21H, W, a      ; W = 25H + 37H = 5CH
        MOVWF     22H, a         ; store result at 22H

   HERE:
       GOTO       HERE           ; stay here so the result can be observed
