flat assembler
Message board for the users of flat assembler.
Index
> Main > 64 bit JMP question |
Author |
|
revolution 15 Sep 2013, 22:55
Fred wrote: I'm guessing that defining a label in the data section makes it an address, so how does a 32 bit value work? Can I expect it to always work? If you have more than 4GB of memory then problems can start. Also the OS can assign virtual addresses higher than 4GB even with less than 4GB of memory so this is not guaranteed to work. |
|||
15 Sep 2013, 22:55 |
|
bitRAKE 16 Sep 2013, 08:11
Just being silly...
Code: lea rax,[table] ; RIP relative movzx ecx,byte[rax+rcx] ; byte/word/dword lea rcx,[rcx*8+rax+table.size] jmp rcx struc TAB [A] { common .: forward db (A-(.+.size))/8 common align 8 .size = $ - . } table TAB .A,.B,.C align 8 .A: retn align 8 .B: add rbx,rdx retn align 8 .C: sub rbx,rdx retn |
|||
16 Sep 2013, 08:11 |
|
Fred 16 Sep 2013, 11:07
revolution: Ok - that makes sense. Thanks for the explanation.
bitRAKE: That one went past me, haha! Something about aligning labels and using that for jumping... I didn't quite get past the struc part. |
|||
16 Sep 2013, 11:07 |
|
bitRAKE 16 Sep 2013, 15:43
I took the absurd route of trying to minimize the table size, while at the same time getting the most from the table. Of course, this requires all the destination labels to be known a priori. RIP-relative and table relative offsets means the code/data can be located any where in address space; but the table does need to proceed the target addresses.
The STRUC just simplifies table generation. First a common name is created using the "." dot syntax. Next each argument is used to calculate a byte offset (which should be a multiple of eight : including a sanity check here wouldn't be too difficult). If the targets are beyond 8*255 then 16-bit word values could be used by changing the STRUC and MOVZX. It will error at assemble-time if that is the case. |
|||
16 Sep 2013, 15:43 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.