16. Lets write some assembly code#

UNDER CONSTRUCTION

In this chapter we will get going and write some simple assembly code, “build” it and run it within a “debugger” so that we can get a sense of how everything fits together.

To do this we will use three terminal sessions one terminal to run an ascii editor, one to run the shell on its own so that we can compile our source code, and one to run our debugger. We use three different terminals so that we can stay organized and avoid having to constantly stop and start the different programs. In some sense we are using multiple terminals to form our own Integrated Development Environment (IDE) where we are using each terminal as if it were a sub-window of our IDE. In actuality the editor that we will be using (emacs) has support for integrating all three tasks within itself but for the moment we will keep things separate to make sure we know what is going on and not tie ourselves to this particular editor (there are many others including the popular VIM).

16.1. Setup#

16.2. Writing the Source Code#

16.3. Assembling - Translating the Source Code an Object File#

16.4. Linking - Translating the Object file into an Executable#

16.5. Running with GDB#

16.6. Running with out GDB#

16.7. Automate assembling and linking with Make#

16.8. Fixing our code to exit “nicely”#