While I was studying computer science, I spent only a short amount of time on assembly programming, but I found it fascinating. The ability to run a program by speaking to the CPU was pretty cool. It was a topic I wanted to revisit.
Late last year I picked up "Low Level Programming" (C, Assembly, and Programming Execution on Intel 64 Architecture) by Igor Zhirkov.
The book hits all the topics I wanted to go deeper on:
- Assembly language
- Virtual memory
- Writing a programming language (hence compilers)
- C programming
In the book, I'll eventually create a Forth compiler. This leads to being able to create your own programming language.
I'll also go deeper into modern C programming, including using Assembly in C.
The end of the second chapter stopped me like a freight train. This is the first assignment, and it is a doozy. It involves writing code to handle string-based processing: string length, converting int to string, and string to int, printing to stdout, reading keyboard input, string copy and string equality.
I'm still working on this assignment. It's not terribly hard, but it takes time and focus, which can be hard to come by on nights and weekends, where I may only have an hour or two to study. This kind of assignment I have to do in pieces. So progress has slowed.
If you want to go through this book, treat it like a textbook for a college course. You'll need to do some research as you go through it.
For Assignment 2, read the entirety of section 2.7. Otherwise, you're not going to know which registers to expect input from. Also:
- Learn to use gdb (GNU Debugger, Appendix A) or you won't see what's happening in your code.
- For system call information, use Appendix C.
Follow along in the official repo
This is where you'll find:
- answers to questions posed throughout the chapters: https://github.com/Apress/low-level-programming/blob/master/questions/answers/001.md
- errata: https://github.com/Apress/low-level-programming/blob/master/errata.md
- code listings and answers to assignments
Keep a notebook to go along with it. You'll want to write down registers, the stack, and their contents to keep track of processing.
The Intel manual is massive, but you will not need it all, just a tiny percentage. When you look up an instruction, such as MOV, click to Volume 2 in your PDF reader, and then scroll down the table of contents to the Instructions list. You can also use the combined index at the very end of the document, but I found Volume 2's table of contents to be easiest.
Keep this cheat sheet handy: http://www.cheat-sheets.org/saved-copy/ascii_a4.pdf
- University of Washington: Assembly Programming III CSE 351 Spring 2017 lecture notes.
- Linux System Calls
- 64-bit Linux system call list
- System calls reference
Well, I'm still plugging through the book (Low Level Programming, not the Intel reference), and won't go faster by writing blog posts, so back to work!
Update (Mar 3, 2019): https://startupnextdoor.com/assembly-language-string-library-so-far/