mousemovex() and mousemovey() is determined by how far the mouse has moved since the command was last called. So if you call it every loop and you never move 20 units in one loop it will never work as they are set to 0 when called. Save them to variables and inc them each loop.
m_x = 0
x = mousemovex()
m_x = m_x + x
if m_x >= 20
m_x_reached = 1
m_x = 0
endif
if m_x_reached = 1
m_x_reached = 0
xspot=xspot+20
x=0
endif
Or something similar.
[edit] This is an example. Though using mouse position commands might be easier.
sync on : sync rate 0
m_x = 0
m_y = 0
position mouse 0,0
do
cls
x = mousemovex()
m_x = m_x + x
if m_x >= 20
m_x_reached = 1
m_x = 0
xdir = 1
endif
if m_x <= -20
m_x_reached = 1
m_x = 0
xdir = -1
endif
if m_x_reached = 1
m_x_reached = 0
xspot=xspot+(20*xdir)
x=0
endif
y=mousemovey()
m_y = m_y + y
if m_y >= 20
m_y_reached = 1
m_y = 0
ydir = 1
endif
if m_y <= -20
m_y_reached = 1
m_y = 0
ydir = -1
endif
if m_y_reached = 1
m_y_reached = 0
yspot=yspot+(20*ydir)
y=0
endif
`Left=S Right=O
if mouseclick()=1
text xspot, yspot, "S"
endif
if mouseclick()=2
text xspot, yspot, "O"
endif
set cursor 5,5
print
sync
loop