I'm working on an X32 object file, which uses 32-bit Integers, Longs and Pointers. I'm building the object file like so:
nasm -f elfx32 rdrand.S -DX32 -o rdrand-x32.o
rdrand.S
is multi-platofrm (X86, X32 and X64). Within the X86 block, 64-bit registers are available. So I am trying to (other code omitted to demonstrate the core problem):
%ifdef X32
%define buffer rdi ;; x32-abi (http://sites.google.com/site/x32abi/documents)
%define size rsi
rdrand rax ;; generate a 64-bit random value
mov [buffer], rax ;; save it to caller's buffer
%else
%define buffer ...
rdrand eax ;; generate a 32-bit random value
mov [buffer], eax ;; save it to caller's buffer
%endif
However, it appears NASM is not issuing the REX prefix on the instruction, so its resulting in:
line 100: error: no instruction for this cpu level
line 101: error: no instruction for this cpu level
I know rdrand rax
will work, so its a matter of getting NASM to issue the REX prefix. (I'm not sure about mov [buffer], rax
, but I'll get to that once I figure out the REX issue).
How do I tell NASM to issue the wide version of instruction?
I'm using Debian's version of NASM:
$ nasm -v
NASM version 2.11.05 compiled on Sep 9 2014
However, I'm not in an X32 enabled kernel at the moment.