flat assembler
Message board for the users of flat assembler.
Index
> Main > Jump table |
Author |
|
crc 18 Jun 2005, 21:03
Shouldn't you use RAX for 64-bit code?
|
|||
18 Jun 2005, 21:03 |
|
r22 18 Jun 2005, 21:40
64bit addresses are 8bytes so
Code: call [JMPTable+RAX*8] JMPTable dq F1, F2, F3 F1: ...ret F2: ...ret F3: ...ret When RAX = 0, F1 will be called When RAX = 1, F2 will be called etc. Hopefully that helps. |
|||
18 Jun 2005, 21:40 |
|
woody 18 Jun 2005, 23:48
Thanks r22. Much appreciated.
Don't think you have to use the rax register to use as an index, eax seems to work just fine. I think the natural register to uses in th x64 range is still 32 bit with the option of 64 its unless of course when it comes to addressing memory. But anyway thanks for help. Woody. |
|||
18 Jun 2005, 23:48 |
|
smiddy 19 Jun 2005, 03:47
Please forgive my ignorance, but how does this apply to reference variables too? I am trying to learn them as the next portion of my own project will require them I suspect. Like so:
Code: Functions: CallTableAddress rq 1 ; 0.call-table address. Function1 rq 1 ; 1. Function2 rq 1 ; 2. ... call [Function1] Is this correct? |
|||
19 Jun 2005, 03:47 |
|
Vasilev Vjacheslav 19 Jun 2005, 10:19
woody, this code is the part of microsoft optimization compiler
Code: proc _selecttable, lpParam mov eax,[lpParam] cmp eax,3 jb .case4 jmp dword [.jmptbl+eax*4] .case1: mov eax,1 jmp .out .case2: mov eax,2 jmp .out .case3: mov eax,3 jmp .out .case4: or eax,-1 .out: ret .jmptbl: dd .case1 dd .case2 dd .case3 endp _________________ [not enough memory] |
|||
19 Jun 2005, 10:19 |
|
woody 19 Jun 2005, 13:09
Hi all.
The code I'am writing is for an operating system based on unix as it was years ago.. Suppose the question should have been posted in the OS section of this forum but it seemed like a much more general assembler question (my ignorance in the use of FASM). The use of a jump table seems like a natural choice in my case as yours is Vasilev Vjacheslav. Which processor are you in the use of 32, 64bit . The trouble with using 64 bit registers that an extra byte is required in the make up of the instruction. I don't ever see the OS calls allowed been more than 4294967296 (hope that number is right!) so that is why I used a 32 bit register saves memory and it's just what I need. Woody |
|||
19 Jun 2005, 13:09 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.