Debugging assembly code requires specialized tools to observe the state of registers, memory, and the execution flow.
nasm -f elf64 -g -F dwarf program.asm ld -o program program.o
gdb ./program
layout reg
: Displays register values.break [label]
: Sets a breakpoint at a label.run
: Starts program execution.next
: Executes the next instruction.info registers
: Displays the contents of registers.disassemble [label]
: Displays assembly instructions starting from a label.gdb ./program ; Start debugging layout reg ; View register layout break _start ; Set a breakpoint at the '_start' label run ; Execute the program next ; Step through the instructions info registers ; Observe the register values