How to Increment or Decrement a Register in x86 Assembly Language

x86 Assembly programming language


In this article, we show how to increment or decrement a register in x86 assembly language.

The inc operation increases the value of a register by 1.

The dec operation decreases the value of a register by 1.

The inc and dec operations operate on registers. They do not operate on variables or constants.

The inc does the same as the add operation with a 1.

The dec does the same as the sub operation with a 1.

Below we have code on incrementing the value of the AX register by 1.



So the first thing we do is move 10 into the AX register.

In hexadecimal, this is 0A.

After running the inc operation, this value increases to 0B (or 11 in decimal).

So this is how we can increase the value of a register by 1.

The same setup occurs with the dec operation.

Below we have code on decrementing the value of the AX register by 1.



Again, we have the same 10 we move into the AX register.

We then use the dec operation on the AX register, which decreases the value by 1, and we get 9.

So this is how we can decrease the value of a register by 1.

So this is how we can increment or decrement a register in the x86 assembly language.

Related Resources



HTML Comment Box is loading comments...