News for hackers. Stuff that matters.
Re:Echo – Assembly program that prints the first positional ... by __michaelg on Monday January 02, 2017 @07:42AM (#13300830)
It looks like Kelsey didn't write a lot of assembly before. There are quite a few things you either wouldn't do -- like `cld` for no reason -- or most people (and compilers) would do otherwise -- e.g., `xor ebx, ebx` instead of `mov ebx, 0`.

Besides, 32 bit (⊙_⊙')

Re:Echo – Assembly program that prints the first positional ... by kelseyhightower on Monday January 02, 2017 @08:38AM (#13301081)
Yes, this is my first assembly program. I had to look up every instruction and it took me hours to understand even the basics, but it was worth it. I have a much better understanding of x86 assembly and plan to write larger programs to continue learning in 2017.

I went with 32 bit because all the examples were 64 bit so I forced to learn the nasm and ld flags to get my program to compile, link, and run. I also learned a lot about the different registers available to 32 and 64 bit programs.

Re:Echo – Assembly program that prints the first positional ... by userbinator on Monday January 02, 2017 @09:15AM (#13301213)
What caught my attention was the segment register use --- besides the fact that Linux runs processes in flat mode, the more common way to es = ds is push ds; pop es.

That said, it does look better than compiler output and distinctly has the style of hand-written Asm; the 3 pops at the beginning, for example, would be something no compiler I've seen can do. (Minor "optimisation" --- rethinking your register use can eliminate some superfluous moves.)