Page 1 of 1
Chang 'Goto <label>' To 'Goto <?label>'
Posted: Wed Apr 19, 2017 5:21 pm
by gurj
Chang 'Goto <label>' To 'Goto <?label>'
so will can use Variables for label
Code: Select all
n=?label_1
For a=0 To 9
Goto n
label_1: :Debug 1:n=?label_2
label_2: :Debug 2
Next
Re: Chang 'Goto <label>' To 'Goto <?label>'
Posted: Thu Apr 20, 2017 7:53 am
by gurj
And add
Syntax:
Chang 'Gosub <label>' To 'Gosub <?label>'
so will can use Variables For label
Re: Chang 'Goto <label>' To 'Goto <?label>'
Posted: Thu Apr 20, 2017 10:49 am
by User_Russian
Code: Select all
EnableASM
n=?label_1
For a=0 To 9
jmp n
label_1: :Debug 1:n=?label_2
label_2: :Debug 2
Next
Re: Chang 'Goto <label>' To 'Goto <?label>'
Posted: Thu Apr 20, 2017 11:19 am
by gurj
thanks User_Russian!
Re: Chang 'Goto <label>' To 'Goto <?label>'
Posted: Thu Apr 20, 2017 1:47 pm
by gurj
as Gosub:
Code: Select all
EnableASM
n=?label_1
m=?re_1
JMP n
re_1:
n=?label_2
m=?re_2
JMP n
re_2:
Debug 3
End
label_1: :Debug 1
JMP m
label_2: :Debug 2
JMP m
Re: Chang 'Goto <label>' To 'Goto <?label>'
Posted: Thu Apr 20, 2017 2:32 pm
by mk-soft
Not saved...
Code: Select all
EnableASM
Define n
n=?label_1
push rsp
call qword [v_n]
pop rsp
n=?label_2
push rsp
call [v_n]
pop rsp
Debug 3
End
label_1:
a = 1
Debug 1
ret
label_2:
a = 2
Debug 2
ret
Re: Chang 'Goto <label>' To 'Goto <?label>'
Posted: Thu Apr 20, 2017 2:56 pm
by mk-soft
I do not know what you're up to. But the techniques with 'Goto' and 'Gusub' are not up-to-date.
There are better methods with jump marks to work. Here is a small example.
Code: Select all
Prototype ProtoInvoke()
Structure udtInvoke
Invoke.ProtoInvoke[0]
EndStructure
Procedure fc0()
Debug 0
EndProcedure
Procedure fc1()
Debug 1
EndProcedure
Procedure fc2()
Debug 2
EndProcedure
Procedure fc3()
Debug 3
EndProcedure
*fc.udtInvoke = ?MyFunctions
For i = 0 To 3
*fc\Invoke[i]()
Next
DataSection
MyFunctions:
Data.i @fc0()
Data.i @fc1()
Data.i @fc2()
Data.i @fc3()
EndDataSection
Code: Select all
Prototype ProtoInvoke()
Structure udtInvoke
Invoke.ProtoInvoke
EndStructure
Procedure fc0()
Debug 0
EndProcedure
Procedure fc1()
Debug 1
EndProcedure
Procedure fc2()
Debug 2
EndProcedure
Procedure fc3()
Debug 3
EndProcedure
Global NewList ToDo.udtInvoke()
Macro AddToDo(Function)
AddElement(ToDo())
ToDo()\Invoke = Function
EndMacro
AddToDo(@fc0())
AddToDo(@fc1())
AddToDo(@fc2())
AddToDo(@fc3())
ForEach ToDo()
ToDo()\Invoke()
Next
Re: Chang 'Goto <label>' To 'Goto <?label>'
Posted: Fri Apr 21, 2017 12:04 am
by gurj
thanks mk-soft !