flat assembler
Message board for the users of flat assembler.

Index > Main > 32 bit extended register addressing in 64 bit code

Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17284
Location: In your JS exploiting you and your system
revolution
Code:
add qword[r11],4        ;49 83 03 04
add qword[r11d],4       ;67 49 83 03 04 ??    
The first instruction above asembles as I expected but then I got an error with the second instruction.

Is it the case that r8d-r15d cannot be used as address registers? I checked the manuals and cannot find anything to indicate that they are not available. Of course I might have missed something, so does anyone else know if it is correct?
Post 25 Apr 2006, 12:45
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
I did overlook this problem. Can anyone with AMD64 (or EM64T) processor check out whether such encoded instruction works as expected?
Post 25 Apr 2006, 16:01
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Well not sure if this what you want
Code:
format ELF64 executable
segment readable executable
entry $

lea r11, [msg]
mov rax, 0FFFFFFFF00000000h
xor r11, rax
db 67h, 49h, 83h, 03h, 04h

        mov     edx,msg_size    ; CPU zero extends 32-bit operation to 64-bit
                                ; we can use less bytes than in case mov rdx,...
        lea     rsi,[msg]
        mov     edi,1           ; STDOUT
        mov     eax,1           ; sys_write
        syscall

        xor     edi,edi         ; exit code 0
        mov     eax,60          ; sys_exit
        syscall

segment readable writeable

msg db '0',0xA
msg_size = $-msg    


Quote:
ubuntu@ubuntu:~/Desktop/fasm$ ./fasm hello64.asm
flat assembler version 1.65.20
3 passes, 236 bytes.
ubuntu@ubuntu:~/Desktop/fasm$ ./hello64
4


If you need to test something else ask

Regards
Post 25 Apr 2006, 22:35
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17284
Location: In your JS exploiting you and your system
revolution
Thanks locodelassembly.

That clearly shows add [r11d],4 as a valid instruction. I think it is safe to assume that all r8d-r15d are valid 32 bit address registers.
Post 26 Apr 2006, 00:29
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Yes, it's safe Very Happy (if the code below is right)
Code:
format ELF64 executable
segment readable executable
entry $

mov rax, 0FFFFFFFF00000000h

rept 8 n:8 {
lea r#n, [msg]
xor r#n, rax
db 67h
add qword [r#n], 1
}
        mov     edx,msg_size    ; CPU zero extends 32-bit operation to 64-bit
                                ; we can use less bytes than in case mov rdx,...
        lea     rsi,[msg]
        mov     edi,1           ; STDOUT
        mov     eax,1           ; sys_write
        syscall

        xor     edi,edi         ; exit code 0
        mov     eax,60          ; sys_exit
        syscall

segment readable writeable

msg db '0',0xA
msg_size = $-msg    

Quote:
ubuntu@ubuntu:~/Desktop/fasm$ ./fasm hello64.asm
flat assembler version 1.65.20
3 passes, 343 bytes.
ubuntu@ubuntu:~/Desktop/fasm$ ./hello64
8
ubuntu@ubuntu:~/Desktop/fasm$
Post 26 Apr 2006, 01:03
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
Thus comes the 1.65.21 release. Wink
Post 26 Apr 2006, 07:56
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.