flat assembler
Message board for the users of flat assembler.
Index
> Main > How to declare array of labels? |
Author |
|
revolution 20 Nov 2015, 08:30
You probably want to use LEA instead of MOV and a dword override:
Code: lea ebx,[list] ;... jmp dword[ebx] Code: mov ebx,1 jmp [list+ebx*4] Last edited by revolution on 20 Nov 2015, 09:14; edited 1 time in total |
|||
20 Nov 2015, 08:30 |
|
SergeASM 20 Nov 2015, 09:02
Thanks, but
list dd m1,m2 causes error in proc32.inc if list contains more than 1 label... Serge |
|||
20 Nov 2015, 09:02 |
|
revolution 20 Nov 2015, 09:13
You can declare each one on a separate line.
|
|||
20 Nov 2015, 09:13 |
|
SergeASM 20 Nov 2015, 09:59
Thanks, now FASM translate it successful.
Serge |
|||
20 Nov 2015, 09:59 |
|
l_inc 20 Nov 2015, 15:40
SergeASM
I'd like to give a clarification here. The macro local has different syntax and is not supposed to support initialization at all. For unclear reasons it has a fallback handling if the local variable declaration could not be parsed according to the defined syntax. This allows to write things like local <list dd m1,m2,m3>, but these should be considered a hack. What's not gonna work anyway is using multiple lines with local, of which only the first one contains the label name. A more compliant (but not a cleverer way) is to use the macros locals/endl for this use case. A better way is to define the label table outside of the procedure (e.g. directly after it), because this won't produce a runtime overhead for local variables initialization. _________________ Faith is a superposition of knowledge and fallacy |
|||
20 Nov 2015, 15:40 |
|
SergeASM 20 Nov 2015, 19:17
l_inc
Please give a small example how to do that, thanks. Serge |
|||
20 Nov 2015, 19:17 |
|
l_inc 21 Nov 2015, 02:12
SergeASM
Code: proc myproc selector mov ecx,[selector] and ecx,3 jmp [.table+ecx*4] ;.table dd .m0, .m1, .m2, .m3 ;<-- the table could be put here as well, but this might affect performance .m0: xor eax,eax ;mov eax,0 jmp .exit .m1: mov eax,1 jmp .exit .m2: mov eax,2 jmp .exit .m3: mov eax,3 .exit: ret endp .table dd .m0, .m1, .m2, .m3 _________________ Faith is a superposition of knowledge and fallacy |
|||
21 Nov 2015, 02:12 |
|
revolution 21 Nov 2015, 02:50
I think you forgot the 'align 4'
|
|||
21 Nov 2015, 02:50 |
|
l_inc 21 Nov 2015, 02:53
revolution
Yes, I did. _________________ Faith is a superposition of knowledge and fallacy |
|||
21 Nov 2015, 02:53 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.