flat assembler
Message board for the users of flat assembler.
Index
> Main > Access upper 32 bits of a 64-bit register from 32-bit code? |
Author |
|
revolution 18 Jun 2020, 13:08
No. There is no encoding that can allow it. The REX prefix is only in 64-bit code.
|
|||
18 Jun 2020, 13:08 |
|
revolution 18 Jun 2020, 13:48
BTW: Even if you could read/write the upper halves of the registers, it wouldn't help much. Because as soon as you write a new value to the lower half, the upper half is set to all zeros.
Code: mov rch, 1 ; using your rch example above mov ecx, -1 ; also sets the upper half to zeros mov eax, rch ; eax == 0 Last edited by revolution on 18 Jun 2020, 22:25; edited 1 time in total |
|||
18 Jun 2020, 13:48 |
|
pabloreda 18 Jun 2020, 14:06
You can use in pairs, store 2 32 bits values, for example
Code: mov ebx,-3 mov ecx,23 ; store in rbx the numbers 23|-3 and rbx,$ffffffff shl rcx,32 or rbx,rcx ;extract in rbx,rcx the numbers mov rcx,rbx shr rcx,32 shl rbx,32 shr rbx,32 I guess this work |
|||
18 Jun 2020, 14:06 |
|
revolution 19 Jun 2020, 06:15
pabloreda: In 32-bit code you can't access rbx or rcx.
|
|||
19 Jun 2020, 06:15 |
|
chriscurl 19 Jun 2020, 20:42
That was what I figured ... too bad. All those wasted registers just sitting there not being used! Maybe the best reason out there for migrating to 64 bit code.
|
|||
19 Jun 2020, 20:42 |
|
fasmnewbie 24 Jul 2020, 00:57
chriscurl wrote:
SHLD rax,rcx,32 should do the job. Upperhalf of RCX will be shifted/copied to lower-half of RAX (EAX). Warning: Upper half of RAX will not be cleared. |
|||
24 Jul 2020, 00:57 |
|
revolution 24 Jul 2020, 04:37
fasmnewbie wrote: SHLD rax,rcx,32 |
|||
24 Jul 2020, 04:37 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.