flat assembler
Message board for the users of flat assembler.

Index > Main > al vs. ah

Author
Thread Post new topic Reply to topic
cryo1970



Joined: 21 Oct 2014
Posts: 2
cryo1970
I am new to assembly. I have searched the Internet but cannot find an answer to this question:

Why does
Code:
format ELF64 executable
entry start

start:

  mov  r13, test_byte
  mov  al, [r13]

  mov  rax, 60
  xor  rdi, rdi
  syscall

test_byte  db  'a'    

assemble (with fasm test.asm test) and run fine, while
Code:
format ELF64 executable
entry start

start:

  mov  r13, test_byte
  mov  ah, [r13]

  mov  rax, 60
  xor  rdi, rdi
  syscall

test_byte  db  'a'    

fails with following error:
disallowed combination of registers.

???

If I use for example rbx instead of r13 there is no problem moving the byte pointed to into both al and ah. What is the difference? Please enlighten me on this....
Post 21 Oct 2014, 07:31
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 730
tthsqe
the error reported by fasm is accurate. that combinary of regiseter and mod/rm is not allowed. see the intel manuals, the one I am looking at has a table called

Table 3-1. Register Codes Associated With +rb, +rw, +rd, +ro
Post 21 Oct 2014, 08:25
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17327
Location: In your JS exploiting you and your system
revolution
The registers AH, BH CH and DH cannot be used in all places in 64-bit mode. There are encoding restrictions in the instruction set. It is mostly a legacy thing concerning the history and evolution of the x86 instructions over time.

For the same reason SIL, DIL, BPL and SPL cannot be used in 32-bit mode.
Post 21 Oct 2014, 08:55
View user's profile Send private message Visit poster's website Reply with quote
cryo1970



Joined: 21 Oct 2014
Posts: 2
cryo1970
Thank you for both answers. I still have a LOT to learn. I shall do my homework and check with the Intel manual, when I get back home.

Have a nice day.
Post 21 Oct 2014, 09:46
View user's profile Send private message 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.