Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #13928
| From | "Rod Pemberton" <do_not_have@notemailnot.cmm> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: x64 assembler & RIP for call/jmp absolute indirect |
| Date | 2012-07-13 03:35 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <jtoj0n$8jp$1@speranza.aioe.org> (permalink) |
| References | <5aec6524-87a3-49ba-89bc-cca28a61d453@fr28g2000vbb.googlegroups.com> |
"Alex McDonald" <blog@nospicedham.rivadpm.com> wrote in message
news:5aec6524-87a3-49ba-89bc-cca28a61d453@fr28g2000vbb.googlegroups.com...
> (posted to c.l.forth and c.l.asm.x86)
>
> While constructing a Forth assembler for x64 mode, I've added RIP
> addressing support, and come across a slight oddball encoding during
> testing the encodings. I've not yet been able to test this under an
> x64 system (that's what the assembler is for...) so I'm looking for
> anyone that can shed some light on the possible consequences of this.
> (Curly braces { } in the code below indicate a memory address; the
> equivalent of [$4111C] or [rip+$4111C] in other assemblers.)
>
> STC Experimental 32bit: 0.06.02 Build: 156
> mode64/32 ok ( set 64bit assembly )
> code x ok
> call { rip $4111C } ok
> call { $4111C } ok
> next; ok
> see x
> : x ( ? -- ? )
> \ std call compiles; code=$41B772 len=13 type=20
> \ defined in (console)
> ( $0 ) call qword { rip $4111C } \ FF154C114000
> ( $6 ) call qword { $4111C } \ FF14254C114000
> ( $D ) ret \ C3 ( end ) ok
>
> The first CALL is an "absolute indirect" to an 8byte address at
> absolute $4111C. The second is an explicit RIP encoding to an 8byte
> address at RIP+$4111C.
>
> Is this interpretation correct?
>
I left c.l.a.x. off. Lately, you're lucky if you get one reply there. So,
I won't consume your c.l.a.x. response, if it ever happens.
BTW, is your address encoding correct?
Your ORG appears to be zero, but if I disassemble the hex bytes you posted,
they seem to be at an address other than 0x4111C:
00000000 FF154C114000 call [rel 0x401152]
00000006 FF14254C114000 call [0x40114c]
I didn't check the manuals for the instruction encodings. But, these appear
to be the address bytes (little-endian,i.e., reverse...) from each
respectively:
00 40 11 4C (relative i.e., +6 bytes = 0x401152)
00 40 11 4C (absolute 0x40114c)
So, it seems they're both encoded for address 0x40114C instead of 0x4111C...
(That's with NDISASM from NASM 2.10.01 - current version.)
Trying this NASM code:
BITS 64
ORG 0
CALL QWORD [ REL sym ]
CALL QWORD [ sym ]
times 266511 db 0
sym: ;0x4111C
Disassembling that gives:
00000000 FF1516110400 call [rel 0x4111c]
00000006 FF14251C110400 call [0x4111c]
...
That looks more like $4111C to me.
The address bytes (little-endian):
00 04 11 16 + 6 (relative to end of current instruction)
00 04 11 1C + 0 (absolute)
Rod Pemberton
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar
x64 assembler & RIP for call/jmp absolute indirect Alex McDonald <blog@nospicedham.rivadpm.com> - 2012-07-11 09:25 -0700
Re: x64 assembler & RIP for call/jmp absolute indirect Alex McDonald <blog@nospicedham.rivadpm.com> - 2012-07-11 10:32 -0700
Re: x64 assembler & RIP for call/jmp absolute indirect mhx@iae.nl (Marcel Hendrix) - 2012-07-11 20:47 +0200
Re: x64 assembler & RIP for call/jmp absolute indirect Alex McDonald <blog@rivadpm.com> - 2012-07-11 12:31 -0700
Re: x64 assembler & RIP for call/jmp absolute indirect "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-07-13 03:35 -0400
Re: x64 assembler & RIP for call/jmp absolute indirect "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-07-13 03:44 -0400
Re: x64 assembler & RIP for call/jmp absolute indirect Alex McDonald <blog@rivadpm.com> - 2012-07-13 03:34 -0700
csiph-web