0

Is there any problem with below code:

push ebp
    mov ebp, esp
    mov eax,[ebp+8]
    mov ebx, tasklist
    mul 8
    add ebx, eax
    mov [ebx], 0
    leave
    ret

I got two errors like below:

    mul 8 : invalid combination of opcode and operands
    move [ebx], 0 : error: operation size not specified
zx485
  • 28,498
  • 28
  • 50
  • 59
Ben Eslami
  • 70
  • 8
  • 3
    You cannot use [MUL](https://www.felixcloutier.com/x86/mul) with an immediate operand. Put the `8` into a register/variable first. See the link for the allowed OpCodes. For `mov [ebx], 0` you have to specify the size of the "variable" `EBX` points to. The syntax for this is assembler dependent: for NASM it'd be `mov BYTE [ebx],0`, for MASM it'd be `mov BYTE PTR [EBX], 0` for a BYTE size memory location. – zx485 Apr 01 '21 at 13:44
  • 1
    You could however use `imul eax, eax, 8`. – fuz Apr 01 '21 at 13:47
  • 3
    Or `shl eax,3`, or replace 3 instructions with `mov QWORD PTR [ebx+eax*8],0`, since this seems to be doing array indexing. – 1201ProgramAlarm Apr 01 '21 at 14:47
  • 1
    This error usually means that either you have a syntax error, or (more common for beginners) you are trying to assemble an instruction that doesn't exist. The first thing to check is always to go back to the architecture's instruction reference and check whether there actually exists a form of that instruction with the types of operands (register, memory, immediate) that you want to use. Not all combinations will necessarily exist. – Nate Eldredge Apr 01 '21 at 16:55

0 Answers0