Re: allow GOTO to also jmp to integer variables (dynamic)
Posted: Mon Mar 20, 2017 4:05 am
Nonsense, Ascii was removed to reduce the administrative overhead for the Pb team.nco2k wrote:same reason why ascii was removed.
http://www.purebasic.com
https://www.purebasic.fr/english/
Nonsense, Ascii was removed to reduce the administrative overhead for the Pb team.nco2k wrote:same reason why ascii was removed.
well the particular one that made me post the request was because i had to use inline assembly for a jmp into my jump table, a Goto would've been ideal and then i wouldn't need two CompilerIf/ElseIfs to handle jmp dword/qword for x86/64 http://purebasic.fr/english/viewtopic.php?f=12&t=67044GPI wrote:Can you post a example-Code, where you need "Goto" on pointers? Maybe there is a simpler better Method to solve your problem.
Or HereGPI wrote:Can you post a example-Code, where you need "Goto" on pointers? Maybe there is a simpler better Method to solve your problem.
Code: Select all
Macro GotoVariable(Variable)
; CompilerIf #PB_Compiler_Procedure=""
CompilerIf #PB_Processor_x64
! jmp qword [v_#variable]
CompilerElse
! jmp dword [v_#variable]
CompilerEndIf
CompilerElse
;Sorry don't know how to access a protected Variable in Asm here....
CompilerEndIf
EndMacro
Procedure test2()
Protected a
a=?label
GotoVariable(a)
Debug "Never2"
label:
Debug "ok2"
EndProcedure
a=?label
GotoVariable(a)
Debug "never"
label:
Debug "OK"
test2()
Code: Select all
SELECT a
case 0
Procedure_1()
case 1
Procedure_2()
case 3
Procedure_3()
default
Procedure_1()
Endselect
But I'm not willing to to create some hundred procedureslanginagel wrote:But in Purebasic we have Procedures.
Always smoking a cigarette while the processor is calculating, wouldn't good for my healthlanginagel wrote:Why not a SELECT instead?Should be easier to maintain.Code: Select all
SELECT a case 0 Procedure_1() case 1 Procedure_2() case 3 Procedure_3() default Procedure_1() Endselect
Keya wrote:well the particular one that made me post the request was because i had to use inline assembly for a jmp into my jump table, a Goto would've been ideal and then i wouldn't need two CompilerIf/ElseIfs to handle jmp dword/qword for x86/64 http://purebasic.fr/english/viewtopic.php?f=12&t=67044GPI wrote:Can you post a example-Code, where you need "Goto" on pointers? Maybe there is a simpler better Method to solve your problem.
But that's just a wrapper for the jmp instruction i'm already having to use, using the two CompilerIf/Else directives i mentioned it'd be good not to have to typeGPI wrote:But in your case maybe a Macro should be a good solution:Code: Select all
Macro GotoVariable(Variable) ; CompilerIf #PB_Compiler_Procedure="" CompilerIf #PB_Processor_x64 ! jmp qword [v_#variable] CompilerElse ! jmp dword [v_#variable] CompilerEndIf CompilerElse ;Sorry don't know how to access a protected Variable in Asm here.... CompilerEndIf EndMacro