Code: Select all
x=1
y=2
switch x,y ;or however
;x=2
;y=1
Code: Select all
x=1
y=2
switch x,y ;or however
;x=2
;y=1
Code: Select all
Procedure SwapL(*Value1.LONG,*Value2.LONG); swap two long-variables
save.l=*Value1\l
*Value1\l=*Value2\l
*Value2\l=save
EndProcedure
a.l=1
b.l=2
swapl(@a,@b)
debug a
debug b
Code: Select all
a = 1
b = 2
PUSH a
PUSH b
POP a
POP b
Debug a
Debug b
You mean, slower:horst wrote:a little faster
Code: Select all
a = 1
b = 2
InitialTime = GetTickCount_()
For i=0 To 1000000
PUSH a
PUSH b
POP a
POP b
Next i
Debug GetTickCount_()-InitialTime
InitialTime = GetTickCount_()
For i=0 To 1000000
MOV eax, a
XCHG eax, b
MOV a, eax
Next i
Debug GetTickCount_()-InitialTime
Code: Select all
a = 1 : b = 2
InitialTime = GetTickCount_()
For i=0 To 10000000
c=a
a=b
b=c
Next i
t0 = GetTickCount_()-InitialTime
InitialTime = GetTickCount_()
For i=0 To 10000000
PUSH a
PUSH b
POP a
POP b
Next i
t1 = GetTickCount_()-InitialTime
InitialTime = GetTickCount_()
For i=0 To 10000000
MOV eax, a
XCHG eax, b
MOV a, eax
Next i
t2 = GetTickCount_()-InitialTime
InitialTime = GetTickCount_()
For i=0 To 10000000
MOV eax,a
MOV ebx,b
MOV b,eax
MOV a,ebx
Next
t3 = GetTickCount_()-InitialTime
MessageRequester("result",Str(t0)+" / "+Str(t1)+" / "+Str(t2)+" / "+Str(t3),0)
Code: Select all
a = 1 : b = 2
InitialTime = GetTickCount_()
For i=0 To 10000000
c=a
a=b
b=c
Next i
t0 = GetTickCount_()-InitialTime
InitialTime = GetTickCount_()
For i=0 To 10000000
!PUSH dword[v_a]
!PUSH dword[v_b]
!POP dword[v_a]
!POP dword[v_b]
Next i
t1 = GetTickCount_()-InitialTime
InitialTime = GetTickCount_()
For i=0 To 10000000
!MOV eax,dword[v_a]
!XCHG eax,dword[v_b]
!MOV dword[v_a], eax
Next i
t2 = GetTickCount_()-InitialTime
InitialTime = GetTickCount_()
For i=0 To 10000000
!MOV eax,dword[v_a]
!MOV ebx,dword[v_b]
!MOV dword[v_b] ,eax
!MOV dword[v_a] ,ebx
Next
t3 = GetTickCount_()-InitialTime
MessageRequester("result",Str(t0)+" / "+Str(t1)+" / "+Str(t2)+" / "+Str(t3),0)
Code: Select all
a = 1 : b = 2
InitialTime = GetTickCount_()
For i=0 To 10000000
!MOV eax,dword[v_a]
!MOV ebx,dword[v_b]
!MOV dword[v_b] ,eax
!MOV dword[v_a] ,ebx
Next
t0 = GetTickCount_()-InitialTime
InitialTime = GetTickCount_()
For i=0 To 10000000
Next
t1 = GetTickCount_()-InitialTime
MessageRequester("result",Str(t0)+" / "+Str(t1),0)