OR... use a variable and increment/decrement it on each IF THEN statement... the only thing... i don't know how the movement will be produced... probably it will not going to be purely smooth.

try
Code:
PositionHB var byte
PositionLB var word
T9600      con 84   ' 9600 bauds

MAIN:
    IF (UP = 0) AND (DOWN=1) THEN
       serout2 FM, T9600 ,["W01 01 200", CR, LF] 'Write velocity limit value 
       if positionlb < 9999 then
          if positionhb != 27 then 
             positionlb = positionlb+1
             endif
          else
              positionlb = 0
              if positionhb < 27 then
                 positionhb = positionhb+1
                 endif
          endif

       serout2 FM,T9600,["P01 ",dec2 positionhb,dec4 positionlb,_
                         CR, LF] 'Send MOVETO_ABSOLUTE command
       ENDIF

    IF (DOWN = 0) AND (UP = 1) THEN
       serout2 FM, T9600 ,["W01 01 200", CR, LF] 'Write velocity limit value 
       if positionlb then
          positionlb = positionlb - 1
          else
              positionlb = 9999
              if positionhb then
                 positionhb = positionhb-1
                 endif
          endif

       serout2 FM,T9600,["P01 ",dec2 positionhb,dec4 positionlb,_
                         CR, LF] 'Send MOVETO_ABSOLUTE command
       ENDIF

    goto MAIN
    End
there's probably something i missed in the math condition but, this have to work... well i guess.