Basic Gun Page 3: Coding the Carrier

This part if fairly easy. One has to turn the LED on, wait 13 instructions, turn it off, wait 13 instructions, then go back to turning it on again. Here is the code that does the job. Note that the LED is on portb,1. The numbers in the comments are keeping track of the number of instructions used.

fire    bsf     portb,1     ;Turn on LED, 13
        nop                 ;1
        nop                 ;2
        nop                 ;3
        nop                 ;4
        nop                 ;5
        nop                 ;6
        nop                 ;7
        nop                 ;8
        nop                 ;9
        nop                 ;10
        nop                 ;11
        nop                 ;12
        bcf     portb,1     ;Turn off LED, 13
        nop                 ;1
        nop                 ;2
        nop                 ;3
        nop                 ;4
        nop                 ;5
        nop                 ;6
        nop                 ;7
        nop                 ;8
        nop                 ;9
        nop                 ;10
        goto    fire        ;11, 12

This code creaes a 38.5khz carrier frequency. Remember that the goto command takes two instructions.