2

I've disassembled a executable with gdb and trying to compile it's code to eventually convert it to a C program. I'm using a website for this and when I try to compile, I get the error below:

main.asm:4: warning: `PTR' is not a NASM keyword [-w+ptr]
main.asm:4: error: comma, colon, decorator or end of line expected after operand

Here is the code, what is the problem with it?

    push   rbp
    mov    rbp,rsp
    sub    rsp,0x20
    mov    DWORD PTR [rbp-0x14],edi
    mov    QWORD PTR [rbp-0x20],rsi
    mov    edi,0x40
    call   0x5562bce95bc0 <malloc@plt>
    mov    QWORD PTR [rbp-0x8],rax
    mov    rax,QWORD PTR [rbp-0x8]
    mov    rdi,rax
    call   0x5562bce95e5a <read_input>
    test   eax,eax
    je     0x5562bce9667a <main+52>
    mov    eax,0x1
    jmp    0x5562bce966b9 <main+115>
    mov    rax,QWORD PTR [rbp-0x8]
    mov    rdi,rax
    call   0x5562bce95e91 <read_validate_part1>
    mov    rax,QWORD PTR [rbp-0x8]
    mov    rdi,rax
    call   0x5562bce95f3a <read_validate_part2>
    mov    rax,QWORD PTR [rbp-0x8]
    mov    rdi,rax
    call   0x5562bce95fef <read_validate_part3>
    mov    rax,QWORD PTR [rbp-0x8]
    mov    rdi,rax
    call   0x5562bce95c00 <free@plt>
    mov    eax,0x0
    call   0x5562bce962cf <cat_flag>
    mov    eax,0x0
    leave  
    ret  

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
JavaDumbell
  • 215
  • 2
  • 11
  • 2
    The problem is that it's GAS `.intel_syntax noprefix` syntax, not NASM syntax. Also it's disassembly with extra decoration on the call target names, not valid assembler input. Use `objconv` to disassemble into NASM syntax if that's what you want. – Peter Cordes Mar 05 '21 at 05:37

0 Answers0