# `inc`

[x86-64 Documentation](https://asm-editor.specy.app/documentation/x86.md) › [Instructions](https://asm-editor.specy.app/documentation/x86/instruction.md)

Web page: https://asm-editor.specy.app/documentation/x86/instruction/inc

**Increment by 1**

Category: Arithmetic

Adds 1 to the operand and stores the result there, leaving the carry flag unchanged.

8086 and later · accepts the `lock` prefix with a memory operand

[Intel's reference: INC](https://intel.github.io/SDM/instruction/INC.html)

Used in: [The x86-64 instruction set](https://asm-editor.specy.app/learn/courses/x86/introduction/the-x86-instruction-set.md) (x86-64 assembly), [Loops](https://asm-editor.specy.app/learn/courses/x86/think-in-assembly/loops.md) (x86-64 assembly), [Arithmetic, logic and bits](https://asm-editor.specy.app/learn/courses/x86/think-in-assembly/arithmetic-logic-and-bits.md) (x86-64 assembly), [Arrays, strings and the string instructions](https://asm-editor.specy.app/learn/courses/x86/think-in-assembly/arrays-strings-and-the-string-instructions.md) (x86-64 assembly), [Floating point and the x87 stack](https://asm-editor.specy.app/learn/courses/x86/think-in-assembly/floating-point-and-the-x87-stack.md) (x86-64 assembly), [Fill an array with the numbers from 1 to 10](https://asm-editor.specy.app/learn/courses/x86/examples/counting-loop.md) (x86-64 assembly), [The largest element](https://asm-editor.specy.app/learn/courses/x86/examples/max-of-an-array.md) (x86-64 assembly), [Length of a string](https://asm-editor.specy.app/learn/courses/x86/examples/string-length.md) (x86-64 assembly), [Reverse a string in place](https://asm-editor.specy.app/learn/courses/x86/examples/reverse-a-string.md) (x86-64 assembly), [Even or odd, count the set bits, multiply by shifting](https://asm-editor.specy.app/learn/courses/x86/examples/bit-tricks.md) (x86-64 assembly)

## Flags

| Flag | Effect |
| --- | --- |
| CF | not changed |
| PF | depends on the result |
| AF | depends on the result |
| ZF | depends on the result |
| SF | depends on the result |
| DF | not changed |
| OF | depends on the result |

## Forms

- `inc r/m` (8, 16, 32, 64)
  - `inc r/m8`
  - `inc r/m16`
  - `inc r/m32`: 386 and later
  - `inc r/m64`

## Operands

- `r/m`: A general-purpose register or memory location matching the operation’s size, for example `rax` or `qword [rbp-8]`.

## Description

It does *not* affect the carry
flag: to affect the carry flag, use [`ADD something,1`](https://asm-editor.specy.app/documentation/x86/instruction/add.md). `INC` affects all the other flags according to the result.

This instruction can be used with a `LOCK` prefix to allow atomic execution.

See also [`DEC`](https://asm-editor.specy.app/documentation/x86/instruction/dec.md).

## Example

```x86
global _start

section .text
_start:
        mov rax, 12
        mov rbx, 5
        mov rcx, 3
        mov rsi, 9

        inc rax

        mov rax, 60         ; syscall 60: exit
        xor rdi, rdi
        syscall
```
