Mastodon

Low-Level Programming

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.

Low Level Programming

Content

The book hits all the topics I wanted to go deeper on:

  • Assembly language
  • Virtual memory
  • Compilers
  • 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.

Difficulty

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.

Recommendations

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

The repo: https://github.com/Apress/low-level-programming

This is where you'll find:

Notes

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.

Intel Instructions

Keep this PDF handy: Intel® 64 and IA-32 Architectures Software Developer’s Manual Combined Volumes: 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D and 4

Intel® 64 and IA-32 Architectures Software Developer’s Manual Combined Volumes: 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D and 4

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.

ASCII

Keep this cheat sheet handy: http://www.cheat-sheets.org/saved-copy/ascii_a4.pdf

Extra reference:

Going Forward

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/

comments powered by Disqus