Hi Programmednew,
Well, just at a glance you might try nested IF...THEN's instead of using the "AND"s (try to get rid of all of the AND's if you can).

The "PULSEOUT"s can be replaced with something like:

PortB.0 = 1 ; Make PortB.0 'high'
pause 1000 ; or whatever pause you need
PortB.0 = 0 ; Make portb.0 'low'

Try to get rid of all the PULSEOUT's too.

Using the "HIGH" command automatically makes the pin an output, so these two commands could be changed:

TRISA.2 = 0
High PORTA.2

To just this:
HIGH PORTA.2

Better yet, can all the "HIGHs and "LOW"s and just set your TRIS registers as needed then use:

PortA.2 = 1

Arch