New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What was it like to learn x86-64 Assembly? #66
Comments
|
I think one of the difficult things in assembly is that it's easy to understand what a single instruction does, but it's hard to get an overview of what a group of instructions are actually doing.
Assembly is very different from other programming languages. There are no variables, data types, conditional statements, or loops. Function arguments and return values are passed in registers. |
@ErikSchierboom Good to think about when we consider what we expect all programmers to know. |
Definitely. |
@iHiD @ErikSchierboom Just to clarify, there are other ways to accomplish this. Instead of variables, we store data in registers, or on the stack. Instead of data types we use keywords like mov eax, dword [rsi] Conditional statements are achieved by using jump instructions, for example: if (x == 1)
// Do this
else
// Do that Could be written as: mov eax, x
cmp eax, 1
jne .else
; Do this
jmp .endif
.else:
; Do that
.endif: Loops are also achieved by using jump instructions, for example: for (int i = 0; i < 10; i++)
// Do something Could be written as: mov ecx, 0
.loop_start:
; Do something
add ecx, 1
cmp ecx, 10
jl .loop_start |
This track must mark the first time that I ever really thought about and manually needed to observe call conventions (and especially System V ABI) and the difference between caller-saved and callee-saved registers. Personally, what helped lot was working other language tracks in parallel. Having already solved some of the same problems in one or more higher-level language allowed me to concentrate on coding in assembly. Most of the time I ignored Compiler Explorer to prevent myself from copying a compiler's work instead of mentally laying out the instructions myself. I often needed to step through the execution of what I wrote to fix bugs, so I came to appreciate GDB on the command line even more.
Yikes, so many opcodes and instructions for testing and branching. I really came to miss boolean operators and block statements from higher-level languages. What helped, though, was the clear picture on how arrays are laid out in memory in C, C++, Rust etc. At first an odd thing to me was the tendency to tip the balance between micro-optimization and readability in hand-written assembly toward faster and smaller code. For example, the typical In closing, I'd like to add that the mentoring in this track was fantastic. All comments and tips for improvement have been very helpful and the tone was encouraging. I really liked that experience! |
I'm not sure if suggestions are appropriate but it would be nice with some "HARD" or "MEDIUM" extra exercises, like for example, a full AES-256 implementation, or something useful like that. ;) General background ramblings (feel free to ignore): |
We're closing this issue as it was part of our research for the v3 version of Exercism which has just been released. Thanks everyone for chipping in! It has been greatly appreciated. |
We’ve recently started a project to find the best way to design our tracks, in order to optimize the learning experience of students.
As a first step, we’ll be examining the ways in which languages are unique and the ways in which they are similar. For this, we’d really like to use the knowledge of everyone involved in the Exercism community (students, mentors, maintainers) to answer the following questions:
Could you spare 5 minutes to help us by answering these questions? It would greatly help us improve the experience students have learning x86-64 Assembly :)
Note: this issue is not meant as a discussion, just as a place for people to post their own, personal experiences.
Want to keep your thoughts private but still help? Feel free to email me at erik@exercism.io
Thank you!
The text was updated successfully, but these errors were encountered: