0

I am trying to perform a division by multiple subtraction in assembly code and am getting the following errors:

subtract.nasm:19: error: invalid combination of opcode and operands
subtract.nasm:20: error: invalid combination of opcode and operands
subtract.nasm:24: error: invalid combination of opcode and operands
subtract.nasm:25: error: invalid combination of opcode and operands

I cannot figure this out, any ideas on what it could be?

section .data

        VAL1: db 10
        VAL2: db 2

section.text

        global _start
_start:

        mov eax, VAL1
        mov ecx, VAL2
        mov ebx, 0

sub_loop:

        sub eax,eax,ebx
        add ebx,ebx,1

        test eax,eax
        jnz sub_loop
        add edx,eax,ecx
        sub ebx,ebx,1

        mov eax,1
        mov ebx,0
        int 80h
gfdb
  • 311
  • 2
  • 9
  • 1
    `add ebx,ebx,1` There's no such form of `add`. Same goes for `sub`. Perhaps you meant to use `add ebx,1` (or `inc ebx`). – Michael Mar 30 '20 at 10:31
  • x86 is a CISC machine where typical instructions have only 2 operands, not 3. Look at basically any x86 example or compiler output or manual. IDK if you were trying to port ARM or MIPS code or something? – Peter Cordes Mar 30 '20 at 10:35
  • i am trying to do the equivalent of += 1 for the ebx,ebx, 1. I was looking at a similar example written in ARM, that is likely why you say that. – gfdb Mar 30 '20 at 10:51
  • Thank you very much Peter and Michael! – gfdb Mar 30 '20 at 13:49

0 Answers0