Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For those that want to get started in assembly language programming, here's a suggestion. Write a simple skeleton in un-optimized C first. Next take a look at the generated code and replace or fill in the missing parts with assembly language.

When programming in assembly language, one starts with a blank slate. Every abstraction you want to construct, say a data structure or even a function call, you build from scratch. By starting with C you eliminate many dead-ends and false starts.

By adopting C's conventions for stack allocation of local variables and how parameters are pushed on the stack and how return values are passed back to callers, you get yourself situated on firm ground rather than floundering around trying to reinvent basic linkage of caller to called functions.



When learning MIPS, the lessons I followed recommended something similar to this. We didn't look at the compiled assembly but used C as a form of pseudocode for assembly. It was a valuable experience - especially the illumination on how close to the machine C is whilst looking much higher level to me before that.

I tested to see if writing the code first in Scheme or CL offered the same benefits. It did not - it was far easier to translate solutions from C to assembly. My only guess is that a lot of work in C is similar to what I had to do in assembly, where in Scheme there isn't such things. So C only took away handling the stack for procedures and what not, where as scheme took away that and the rest of what I would need to do in assembly. Long story short, the solution in C was closer to assembly than the solution in scheme.


I am not agree. The human writes assembly language in very different way, compared to the HLL compiler. Taking the compiler as a reference, you will get all the disadvantages and none of the advantages it have.

I would suggest simply to take some good quality, human written assembly language source and to try to modify it to fit your needs. Or start to program some small assembly language program from scratch and ask on the asm forums for help.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: