Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: 64bit assembly


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 5 - Last Post: Oct 23, 2014 1:01 PM Last Post By: Rudy Velthuis (... Threads: [ Previous | Next ]
theodore panas

Posts: 2
Registered: 12/5/00
64bit assembly  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 21, 2014 7:10 AM
i am trying to compile the following code in delphi 64bit assembler without success

lea rcx, QWORD PTR [__ImageBase]
movzx eax, BYTE PTR [@@SWITCH_TABLE + rcx + rbp]
lea rax, [@@SWITCH_CASE_7 + rcx + rax]
jmp rax

@@SWITCH_CASE_7: ........
@@SWITCH_CASE_6: .........
@@SWITCH_CASE_5: .............
@@SWITCH_CASE_4: .............
@@SWITCH_CASE_3: ...........
@@SWITCH_CASE_2: .........
@@SWITCH_CASE_1: .............

.ALIGN 4

@@SWITCH_TABLE:
DB @@SWITCH_CASE_1 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_2 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_3 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_4 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_5 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_6 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_7 - @@SWITCH_CASE_7

any help will be appreciated
thnx
Just JJ

Posts: 44
Registered: 8/21/14
Re: 64bit assembly  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 21, 2014 9:51 PM   in response to: theodore panas in response to: theodore panas
On Tue, 21 Oct 2014 07:10:42 -0700, theodore panas wrote:
i am trying to compile the following code in delphi 64bit assembler
without success

lea rcx, QWORD PTR [__ImageBase]
movzx eax, BYTE PTR [@@SWITCH_TABLE + rcx + rbp]
lea rax, [@@SWITCH_CASE_7 + rcx + rax]
jmp rax

@@SWITCH_CASE_7: ........
@@SWITCH_CASE_6: .........
@@SWITCH_CASE_5: .............
@@SWITCH_CASE_4: .............
@@SWITCH_CASE_3: ...........
@@SWITCH_CASE_2: .........
@@SWITCH_CASE_1: .............

.ALIGN 4

@@SWITCH_TABLE:
DB @@SWITCH_CASE_1 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_2 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_3 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_4 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_5 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_6 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_7 - @@SWITCH_CASE_7

any help will be appreciated
thnx

Since you don't include the actual error message, I could only guess that
there's a syntax error at this line:

.ALIGN 4

Because AFAIK, BASM doesn't support assembly compiler directives.
Rudy Velthuis (...


Posts: 7,731
Registered: 9/22/99
Re: 64bit assembly  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 22, 2014 1:27 AM   in response to: Just JJ in response to: Just JJ
Just JJ wrote:

Since you don't include the actual error message, I could only guess
that there's a syntax error at this line:

.ALIGN 4

Because AFAIK, BASM doesn't support assembly compiler directives.

It supports .ALIGN. .NOFRAME and a few other directives, in 64 bit asm.

--
Rudy Velthuis http://www.rvelthuis.de

"It is better to be feared than loved, if you cannot be both."
-- Niccolo Machiavelli
Rudy Velthuis (...


Posts: 7,731
Registered: 9/22/99
Re: 64bit assembly  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 22, 2014 1:29 AM   in response to: theodore panas in response to: theodore panas
theodore panas wrote:

i am trying to compile the following code in delphi 64bit assembler
without success
lea rcx, QWORD PTR [__ImageBase]
movzx eax, BYTE PTR [@@SWITCH_TABLE + rcx + rbp]
lea rax, [@@SWITCH_CASE_7 + rcx + rax]
jmp rax

@@SWITCH_CASE_7: ........
@@SWITCH_CASE_6: .........
@@SWITCH_CASE_5: .............
@@SWITCH_CASE_4: .............
@@SWITCH_CASE_3: ...........
@@SWITCH_CASE_2: .........
@@SWITCH_CASE_1: .............

.ALIGN 4

@@SWITCH_TABLE:
DB @@SWITCH_CASE_1 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_2 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_3 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_4 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_5 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_6 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_7 - @@SWITCH_CASE_7

any help will be appreciated
thnx

Like Just JJ said, the exact error message is important.

Is the above an exact copy of your code (except for the .... parts)?

--
Rudy Velthuis http://www.rvelthuis.de

"I read about an Eskimo hunter who asked the local missionary
priest, ëIf I did not know about God and sin, would I go to
hell?í ëNo,í said the priest, ënot if you did not know.í ëThen
why,í asked the Eskimo earnestly, ëdid you tell me?í"
-- Annie Dillard
theodore panas

Posts: 2
Registered: 12/5/00
Re: 64bit assembly  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 22, 2014 4:00 AM   in response to: Rudy Velthuis (... in response to: Rudy Velthuis (...
the original code was:

lea rcx, QWORD PTR [__ImageBase]
movzx eax, BYTE PTR [imagerel(@@SWITCH_TABLE) + rcx + rbp]
lea rax, DWORD PTR [imagerel(@@SWITCH_CASE_7) + rcx + rax]
jmp rax

is the implementation of MurmurHash2 in 64bit assembly

the errors are:

for line movzx eax, byte ptr ................... and lea rax, dword ptr .........................

E2577 Assembler instruction requires a 32bit absolute address fixup which is invalid for 64bit

for line DB ....

E2105 Inline assembler syntax error

Rudy Velthuis (TeamB) wrote:
theodore panas wrote:

i am trying to compile the following code in delphi 64bit assembler
without success
lea rcx, QWORD PTR [__ImageBase]
movzx eax, BYTE PTR [@@SWITCH_TABLE + rcx + rbp]
lea rax, [@@SWITCH_CASE_7 + rcx + rax]
jmp rax

@@SWITCH_CASE_7: ........
@@SWITCH_CASE_6: .........
@@SWITCH_CASE_5: .............
@@SWITCH_CASE_4: .............
@@SWITCH_CASE_3: ...........
@@SWITCH_CASE_2: .........
@@SWITCH_CASE_1: .............

.ALIGN 4

@@SWITCH_TABLE:
DB @@SWITCH_CASE_1 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_2 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_3 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_4 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_5 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_6 - @@SWITCH_CASE_7
DB @@SWITCH_CASE_7 - @@SWITCH_CASE_7

any help will be appreciated
thnx

Like Just JJ said, the exact error message is important.

Is the above an exact copy of your code (except for the .... parts)?

--
Rudy Velthuis http://www.rvelthuis.de

"I read about an Eskimo hunter who asked the local missionary
priest, ëIf I did not know about God and sin, would I go to
hell?í ëNo,í said the priest, ënot if you did not know.í ëThen
why,í asked the Eskimo earnestly, ëdid you tell me?í"
-- Annie Dillard

Edited by: theodore panas on Oct 22, 2014 10:51 AM
Rudy Velthuis (...


Posts: 7,731
Registered: 9/22/99
Re: 64bit assembly [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 23, 2014 1:01 PM   in response to: theodore panas in response to: theodore panas
theodore panas wrote:

the original code was:

lea rcx, QWORD PTR [__ImageBase]
movzx eax, BYTE PTR [imagerel(@@SWITCH_TABLE) + rcx + rbp]
lea rax, DWORD PTR [imagerel(@@SWITCH_CASE_7) + rcx +
rax] jmp rax

is the implementation of MurmurHash2 in 64bit assembly

the errors are:

for line movzx eax, byte ptr ................... and lea rax, dword
ptr .........................

E2577 Assembler instruction requires a 32bit absolute address fixup
which is invalid for 64bit

for line DB ....

E2105 Inline assembler syntax error

Read this article by Allen Bauer, the head architect of Delphi:

http://blogs.embarcadero.com/abauer/2011/10/05/38939

That explains exactly this error message, why it happens and what you
can do against it.

--
Rudy Velthuis http://www.rvelthuis.de

"If you're sick and tired of the politics of cynicism and polls
and principles, come and join this campaign." -- George W. Bush
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02