简体   繁体   中英

Assembly Language nasm error

I have written the following assembly code as prescribed by my text book in the intel 64 bit syntax

Section .text
global _short
_start:
        jmp short    Gotocall
shellcode:
        pop             rcx
        xor             eax,eax
        mov byte        [rcx+8], al
        lea             rdi, [rax]
        mov long        [rcx+8], rdi
        mov long        [rcx+12], eax
        mov byte        al, 0x3b
        mov             rsi, rax
        lea             rdi, [esi+8]
        lea             edx, [esi+12]
        int             0x80

Gotocall:

        call            shellcode
        db              '/bin/shJAAAAKKKK'

but i get a nasm error in line 10 like this asmshell.asm:10: error: mismatch in operand sizes Can anybody tell me what mistake is their in my code.

And can anybody please tell me some good references to the 64 bit intel assembly instructions.

If you mean the error is on line 10

mov long [rcx+8], rdi

I was about to ask you what size long qualifier is, but the next line

mov long [rcx+12], eax

shows that you are moving two different sizes of register to the same size destination. In the first case the 64-bit register rdi , in the second case the 32-bit register eax , and long cannot satisfy them both.

Why not just drop the long since by specifying the register, the assembler knows the size of the destination? But sadly, you have only allowed 4 bytes memory to store a 64-bit register, given away by the [rcx+8] followed by [rcx+12] .

Perhaps you intended

mov long [rcx+8], edi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM