Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.os.development > #18617

Re: x64 address indexed by 32-bit address

From wolfgang kern <nowhere@never.at>
Newsgroups alt.os.development
Subject Re: x64 address indexed by 32-bit address
Date 2024-01-30 10:14 +0100
Organization A noiseless patient Spider
Message-ID <upaema$u5og$1@dont-email.me> (permalink)
References <uodu7l$35iiq$1@dont-email.me>

Show all headers | View raw


On 19/01/2024 14:42, Paul Edwards wrote:
> Hi.
> 
> I am using a slightly modified GCC 3.2.3
> to generate x64 code, and using PDPCLIB
> and running under Linux x64.
...
> Now I have this code:
...
> printf("as negative is %x\n", p[-1]);

> which is generating (for that last line):
> 
> LM1873:
>          movl    $4294967295, %eax
>          addq    -64(%rbp), %rax
>          movsbl  (%rax),%esi
>          movl    $LC445, %edi
>          movb    $0, %al
>          call    _printf

> That first instruction - the movl - has
> negative 1 as an unsigned value. 

of course because it's just the lower part of RAX
where the upper part become zeroed by a move to EAX.

> I tried manually changing the generated assembler
> to $-1 but the result appears to be the
> same (I may have stuffed up the test).

you have to make RAX -1
XOR RAX,RAX
DEC RAX
but what's wrong with: DEC instead of ADD -1
__
wolfgang

Back to alt.os.development | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: x64 address indexed by 32-bit address wolfgang kern <nowhere@never.at> - 2024-01-30 10:14 +0100
  Re: x64 address indexed by 32-bit address wolfgang kern <nowhere@never.at> - 2024-02-01 09:29 +0100
  Re: x64 address indexed by 32-bit address Paul Edwards <mutazilah@gmail.com> - 2024-02-02 16:12 +0800
    Re: x64 address indexed by 32-bit address wolfgang kern <nowhere@never.at> - 2024-02-02 14:16 +0100
  Re: x64 address indexed by 32-bit address Paul Edwards <mutazilah@gmail.com> - 2024-02-13 14:24 +0800

csiph-web