flat assembler
Message board for the users of flat assembler.
Index
> Main > 64-bits registers in 32-bits mode |
Author |
|
MazeGen 09 Nov 2005, 15:14
It is simply impossible. 32-bit processor doesn't know these registers. It means the processor can't decode them correctly.
|
|||
09 Nov 2005, 15:14 |
|
RedGhost 09 Nov 2005, 15:15
are you on a 32-bit processor.. or a 32-bit OS... if your processor is 64-bit, but your OS is 32, you can use the 64-bit registers/instructions fine, but if the processor is 32-bit you cannot
_________________ redghost.ca |
|||
09 Nov 2005, 15:15 |
|
cane 09 Nov 2005, 15:20
Let me clear things: I have a 64-bits processor and a 32-bits OS
The question was related to this kind of scenario. |
|||
09 Nov 2005, 15:20 |
|
cane 09 Nov 2005, 15:25
RedGhost wrote: if your processor is 64-bit, but your OS is 32, you can use the 64-bit registers/instructions fine ehm... how? Thanks! |
|||
09 Nov 2005, 15:25 |
|
vid 09 Nov 2005, 20:48
it isn't like in 16bit mode with 32bit regs? eg.
Code: db 66h mov ax,lower_word dw upper_word etc. |
|||
09 Nov 2005, 20:48 |
|
Kain 09 Nov 2005, 22:42
RedGhost wrote: are you on a 32-bit processor.. or a 32-bit OS... if your processor is 64-bit, but your OS is 32, you can use the 64-bit registers/instructions fine, but if the processor is 32-bit you cannot Really? I haven't been able to do this from Windows (32 bits WinXP running on 64bit AMD). _________________ :sevag.k |
|||
09 Nov 2005, 22:42 |
|
Tomasz Grysztar 09 Nov 2005, 22:54
No, on AMD64 the 64-bit registers and instructions are available only in long mode, they are not recognized in legacy and compatibility modes (since the REX prefixes used for those extensions use the 40h-4Fh opcodes range, and in compatibility modes they have old meaning, the short forms of INC/DEC instructions).
|
|||
09 Nov 2005, 22:54 |
|
vid 09 Nov 2005, 23:24
do the 64bit instruction have prefix in long mode? that would be stupid slowdown to everything.
|
|||
09 Nov 2005, 23:24 |
|
revolution 10 Nov 2005, 00:52
Quote: do the 64bit instruction have prefix in long mode? |
|||
10 Nov 2005, 00:52 |
|
LocoDelAssembly 10 Nov 2005, 00:56
Code: org 100h use64 mov rax, rax mov eax, eax int 20h -u 0D18:0100 48 DEC AX 0D18:0101 89C0 MOV AX,AX 0D18:0103 89C0 MOV AX,AX 0D18:0105 CD20 INT 20 Apparently you need the REX byte to access long registers and I think for the other things too. http://www.sandpile.org/aa64/opc_rex.htm |
|||
10 Nov 2005, 00:56 |
|
vid 10 Nov 2005, 01:59
i think one extra byte per instruction causes quite big slowdown with internal processor caches
|
|||
10 Nov 2005, 01:59 |
|
revolution 10 Nov 2005, 03:17
Quote: i think one extra byte per instruction causes quite big slowdown with internal processor caches Code: add rax,rbx ;64 bit add, one instruction, compare to ... add eax,ebx ;32 bit add and... adc edx,ecx ;another 32 bit add to complete the 64 bit addition |
|||
10 Nov 2005, 03:17 |
|
Tomasz Grysztar 10 Nov 2005, 11:16
Note also that you don't really need, for example, to do:
Code: mov rax,1 since Code: mov eax,1 does the same, as all operations on 32-bit registers zero-extend the result to the whole 64-bit register. This is directly related to the fact, that 32-bit is the default size of operations (when no prefix provided) in the long mode. And thus general rule is that you should use 32-bit operations everywhere where possible (well, in fact many of the 32-bit code should be directly portable into long mode, and even instruction encodings don't change at all). |
|||
10 Nov 2005, 11:16 |
|
cane 10 Nov 2005, 11:26
Thanks for helping me out! Now, to summarize things up: the only way to use 64-bits registers is to turn on long mode (use64 directive) which, though, prevents the code from running on a 32-bits OS. Is that correct?
|
|||
10 Nov 2005, 11:26 |
|
vid 10 Nov 2005, 12:36
usa64 directive doesn't "turn on the mode", it just tells assembler to assemble code that can be run in long mode. OS must run your code in long mode.
|
|||
10 Nov 2005, 12:36 |
|
cane 10 Nov 2005, 12:45
Yeah I meant that... but once I get the 64-bit assembled code there's no hope a 32-bit OS will run it.
|
|||
10 Nov 2005, 12:45 |
|
vid 10 Nov 2005, 13:36
in reality no. in theory you could make "64bit" code which will use only instructions that are same as in 32bit mode, and such one would be runable
|
|||
10 Nov 2005, 13:36 |
|
MazeGen 10 Nov 2005, 15:44
This thread could be also interesting in this topic.
|
|||
10 Nov 2005, 15:44 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.