In Basic and Asm:
function Reverse(string s) as string
string t=s
sys le=len t
for i=1 to le
mid t,i,mid s,le-i+1
next
return t
end function
print reverse "abcdefghijklmnopqrstuvwxyz"
function Reverse(string s) as string
string t=s
sys le=len t
addr edi,t
addr esi,s
mov ecx,le
dec ecx
(
mov al,[esi]
mov [edi+ecx],al
inc esi
dec ecx
jge repeat
)
return t
end function
print reverse "abcdefghijklmnopqrstuvwxyz"
And another using byte pointers:
function Reverse(string s) as string
string t=s
sys le=len t
byte a at (strptr s)
byte b at (le-1+strptr t)
for i=1 to le
b=a : @b-- : @a++
next
return t
end function
print reverse "abcdefghijklmnopqrstuvwxyz"