NASM Coding: Constants and String Length

  1. Using literals in your code. Example:
    mov rax, 10
    mov rbx, 0xA
    mov rcx, 'A'

    Explanation: This is probably the most straightforward way to work with constants, as any number or character literal is considered a constant: just write the literal(s) directly in the code (=

    .text
    section) inside the instructions you call.

Quick summary for NASM x86_64 constants:

  1. equ
    defines fixed values, such as a string's length (in bytes/chars).
  2. %define
    can be used as a macro: code substitution.
  3. Number and character literals like
    oah
    or
    'z'
    can be directly embedded in the code.