GDB, Tower of Hanoi, Function Calls =================================== Yesterday, I installed "gdb" on my democratic computer so I can debug my programi "hanoi.s"]1] using the command: gdb hanoi.s Here's an important thing to do if you want to use it: compile and link with the "-g" option, so the source and symbol table will be loaded. Viewing the output of "gdb" commands may be difficult because of text styling, which changes the colors of parts of the text. For example: digits in a dark color on the black background. You can disable styling by typing: set style enabled off Now, having set a breakpoint at symbol "move_discs", typing "run" and then using the command "step", I found the bug: "returning" to the wrong address. Why does it happen? Because "ret"[1] is a goto statement. It does not get the target address from the stack, but from the register x30 instead. So if you have a function calling another function, better store that register in memory. A stack would be a great place if your function is recursive. [1] gopher://zaibatsu.circumlunar.space/1/~zaphodb/phlog/hanoi.s [2] https://developer.arm.com/documentation/ddi0602/2022-09/Base-Instructions/RET--Return-from-subroutine-