Guide: Discovering Assembly
To follow this guide, you will need to navigate to the guides/discovering-assembly/support directory.
-
Open the
ex1.asmfile and read the comments. Assemble it by using themakeutility and run it. Using gdb, go through the program line by line (thestartcommand followed bynext) and observe the changes in register values after executing themovandaddinstructions. Ignore the sequence ofPRINTF32instructions. -
Open the
ex2.asmfile and read the comments. Assemble it by using themakeutility and run it. Using gdb, observe the change in theeipregister when executing thejmpinstruction. To skip thePRINTF32instructions, add a breakpoint at thejump_incominglabel (thebreakcommand followed byrun). -
Open the
ex3.asmfile and read the comments. Assemble it by using themakeutility and run it. Using gdb, navigate through the program using breakpoints. Follow the program flow. Why is15displayed first and then3? Because of the jump at line 9. Where does the jump at line 25 point to? To thezone1label. -
Open the
ex4.asmfile and read the comments. Assemble it by using themakeutility and run it. Using gdb, go through the program. Why isn’t the jump at line 12 taken? Because thejeinstruction jumps if theZFbit in theFLAGSregister is set. This bit is set by thecmpinstruction, which calculates the difference between the values of theeaxandebxregisters without storing the result. However, theaddinstruction at line 11 clears this flag because the result of the operation is different from 0.