Hi,
Try this:
	Code:
	Position    VAR WORD
Target      VAR WORD
Distance    VAR WORD
Position = 1234
Main:
    HSEROUT[13, "You're at position: ", DEC Position, 13]
    HSEROUT["Enter new target: ",13]
    HSERIN[DEC Target]
    ' Actual calculation starts here.
    ' When done the variable Distance contains the
    ' number of "ticks" to target in two's complement format.
    Distance = Target - Position
    IF Distance.15 = 0 THEN             ' Distance is positive
        If Distance > 1790 THEN
            Distance = Distance - 3580
        Endif
    ENDIF
    IF Distance.15 = 1 THEN              ' Distance is negative
        IF ABS Distance > 1790 THEN
            Distance = Distance + 3580
        ENDIF
    ENDIF
    ' End of calculation, result now in Distance.
Done:
    IF Distance.15 = 1 THEN             ' Distance is negative
        HSEROUT["CCW "]
    ELSE
        HSEROUT["CW "]
    ENDIF
    HSEROUT[DEC ABS Distance, " ticks.", 13]
    Position = Target
Goto Main
 /Henrik.
				
			
Bookmarks