Part VII: Quick Reference

This guide is part seven of the series, X86–64 Assembly Language Program. This article is more of a reference guide for those learning x86–64 Assembly Language. I hope you find the information and links at the bottom helpful. Registers General-purpose registers — there are 16 general-purpose registers — rax, rbx, rcx, rdx, rbp, rsp, rsi, rdi, r8, r9, r10, r11, r12, r13, r14, r15 data- section is used for declaring initialized data or constants bss- section is used for declaring non initialized variables text- section is used for code rdi- first argument rsi- second argument rdx- third argument rcx- fourth argument r8- fifth argument r9- sixth The first six integer or pointer arguments are passed in registers rdi, rsi, rdx, rcx, r8, r9. r10 is used as a static chain pointer in the case of nested functions. ...

December 20, 2021 · 4 min

Part VI: How to Determine String Length

This guide is part six of the series, X86–64 Assembly Language Program. How to Calculate String Length In order to calculate the length of a string, we’ll first need to know what determines the end of a given string. Strings in memory are represented as a pointer. The location pointed at is a byte of data representing a character followed by additional characters contiguous in memory. The important point is that this sequence of bytes is terminated by the byte 0x00. This is called the zero-termination character which is one method of terminating a string (C uses this approach, for example). There are methods of encoding strings that we won’t cover here. ...

November 28, 2021 · 3 min

Part V: Conditionals, Jumping, and Looping

This guide is part five of the series, X86–64 Assembly Language Program. Conditionals and Looping Assembly language supports conditionally jumping to a specific line of the code. Looping is actually just a special implementation of jumping. It’s a jump to the beginning of the “loop” until some condition is finally met. Essentially this post is about writing conditional statements to branch one of two ways depending on some condition. The core conditional operator is cmp which is short for ‘compare’. The cmp operator compares two values and then sets some flags indicating the relation of the two values. Flags can be checked using some other operators, namely: ...

November 1, 2021 · 2 min

Part IV: Sending Function Arguments and Receiving a Return Value

This guide is part four of the series, X86–64 Assembly Language Program. Sending Function Arguments and Returning a Result In the previous post of this series, we saw how to define and call functions in x86–64 Assembly. Now I wanted to know how to provide arguments to a function and return values. In other words, when this is done in a higher-level language, how is it translated at the Assembly code level? ...

October 25, 2021 · 3 min

Part III: Printing Command Line Arguments

This guide is part three of the series, X86–64 Assembly Language Program. Now that we’ve set up an efficient development environment, it’s time to write some actual Assembly Language code. In this guide, I’ll share the resources and processes I followed to build a simple Assembly Language program. Printing Command Line Arguments In order to demonstrate the concepts let’s write an assembly program that counts the number of unique words in a text file whose name is provided as an argument. ...

September 25, 2021 · 6 min

Part II: Finding an Efficient Development Cycle for writing Assembly Language

This guide is part two of the series, X86–64 Assembly Language Program. Now that GDB is working well with Docker, the next step is to find a development cycle that enables you to quickly run code and debug it if needed. I prefer to develop within VS Code rather than having to develop directly on the Docker container with vim. The question is how to develop on VS Code, then quickly compile, link, run and debug the code on the docker container that is now set up? ...

September 17, 2021 · 3 min

Part I: Getting Started Writing Assembly Language

This guide is part one of the series, X86–64 Assembly Language Program. This is a guide to setting up a low friction development environment to simplify writing and debugging assembly language programs. Why Learn Assembly Language He who hasn’t hacked assembly language as a youth has no heart Learning assembly language improves one’s foundational understanding of software. With improved fundamentals, you can judge the utility of upcoming technologies more accurately which I think is a super important skill set. Making the right bets on which technologies come to dominate means you can more optimally invest your time and even money. For example, it’s well known that those with a fundamental understanding of the cryptocurrency space immediately understood the value of blockchain and literally made millions of dollars with nearly no additional effort. ...

September 12, 2021 · 6 min