I was looking at Project Euler Problem 48:The series, 11 + 22 + 33 + ... + 1010 = 10405071317.Find the last ten digits of the series, 11 + 22 + 33 + ... + 10001000.In Python I can do this with a single line : sum((x**x for x in xrange(1,1001))But the assembly equivalent of this would be 100 lines and a real challenge.Should I be doing some of these puzzles in assembly to gain some insight into low-level programming and understand how the computer actually works?
Should I try to do practice problems in assembly?
self improvement;assembly
Beyond learning assembly, I believe that learning how a low-level language like C is compiled is highly valuable. So my answer is yes, but then again I'm probably biased because I enjoy low-level programming.For example, just understanding how simple statements are compiled. The following function,int func(int val){  int num = val * 5;  return num;}...becomes (the interesting bit at least):movl    %edi, -20(%rbp)movl    -20(%rbp), %edxmovl    %edx, %eaxsall    $2, %eaxaddl    %edx, %eaxThis code takes the argument from the stack (val, the parameter to func), shifts it the left 2 places (multiply by 2^2 or 4) and then adds the original value to the result. The end result is a multiplication by 5. An example like this illustrates a number of things to be aware of, such as compiler optimizations. Instead of calling an instruction to directly multiply by 5, it shifts two places to multiply by 4 and then adds the original value. I found examples like this to greatly improve my understanding of things at a lower level.Generate assembler output from gcc with the -S option. However, be aware that the results will vary by compiler and optimization level.Anyway, I don't think being an assembly language programmer is the same as understanding assembly. Again, I feel that programming in a language like C and knowing how it gets put into machine code is a valuable practice.