endbr64:
push rbp
mov rbp,rsp
push rbx
sub rsp,0x18
mov DWORD PTR [rbp-0x14],edi
cmp DWORD PTR [rbp-0x14],0x0
je 0x1185 <fib+28>
cmp DWORD PTR [rbp-0x14],0x1
jne 0x118c <fib+35>
mov eax,0x1
jmp 0x11aa <fib+65>
mov eax,DWORD PTR [rbp-0x14]
sub eax,0x1
mov edi,eax
call 0x1169 <fib>
mov ebx,eax
mov eax,DWORD PTR [rbp-0x14]
sub eax,0x2
mov edi,eax
call 0x1169 <fib>
add eax,ebx
add rsp,0x18
pop rbx
pop rbp
ret
main:
endbr64
push rbp
rbp,rsp
mov rax,QWORD PTR [rip+0x2e50] # 0x4010 <stdout@@GLIBC_2.2.5>
mov esi,0x0
mov rdi,rax
call 0x1060 <setbuf@plt>
mov edi,0x1c
call 0x1169 <fib>
mov esi,eax
lea rdi,[rip+0xe24] # 0x2004
mov eax,0x0
call 0x1070 <printf@plt>
mov eax,0x0
pop rbp
ret

- 328,167
- 45
- 605
- 847

- 1
1 Answers
PTR
is MASM syntax, and originally wasn't support by NASM (mostly because MASM syntax is inconsistent and harder to read).
Recently NASM developers added code to detect if PTR
is used and warn people if it is, so that if people mistakenly try to use MASM syntax when the assembler is expecting NASM syntax they have a better idea of why things went wrong. This warning is enabled by default. The warning can be disabled (-w-ptr
) if you want things to go wrong instead.
There are 2 solutions that make sense:
a) convert the code into NASM syntax (e.g. mov DWORD PTR [rbp-0x14],edi
would become mov [rbp-0x14],edi
).
b) Enable the (new, experimental, partial) "masm compatibility" package (put the %use masm
directive at the start of the code). This may not work well because some things (e.g. mov eax,foo
) depend on how the symbol was defined, which isn't information that NASM tracks (consistent syntax means that it never needed that information to begin with) making it ambiguous (possibly assembled wrong).

- 35,656
- 2
- 39
- 66
-
Note that no NASM options are going to help you compile `objdump` output like `call 0x1060
` without at least a bit of thought on the user's part. `objconv` can disassemble into NASM that's ready to assemble. – Peter Cordes Apr 23 '21 at 11:09 -
`%use masm` is a useful suggestion, might be good to post that as an answer on [x86, difference between BYTE and BYTE PTR](https://stackoverflow.com/q/13790146). We already have [warning: \`PTR' is not a NASM keyword \[-w+ptr\]](https://stackoverflow.com/q/66487318) as a signpost, this question doesn't look like it has any future value except for your answer (which like I said could go elsewhere) – Peter Cordes Apr 23 '21 at 11:12