17
operand
6y

I started learning ASM x86_64, so I chose MASM with VS 2013 because is the best for debugging

So I just waste like 2 hours trying to make a simple program like printing fibonacci numbers to start with ASM

The problem started when using printf function, after calling printf function, local vars became garbage, after googling and looking for the ultimate answer for the problem I found the site with the ultimate answer (https://cs.uaf.edu/2017/fall/...) and it was that MASM64 when calling a function you must allocate space with the actual space from the current function + the allocated space for the printf

Comments
  • 2
    learning assembler

    is a waste of life
  • 4
    At lower levels nothing is done for you.
  • 1
    @SukMikeHok it really is, specially considering that a compiler will always create better assembler
  • 2
    @SukMikeHok well actually no, it has been fun, at least I know how the variables values are saved into the ram
  • 0
    @bkwilliams well it just MASM x64
  • 3
    I had ASM in college and it was somewhat interesting because you get to know how does things work on low level but practically I never used it outside of college.
  • 5
    writing in asm was my full time job😅
  • 3
    @SukMikeHok no, it isn't.

    1) learning assembly will make you a better C programmer because you'll have a better guess what assembly the compiler is likely to create on the target CPU.

    2) you'll gain a better understanding of C because C is, tongue in cheek, the best portable macro assembler ever.

    3) wherever C is too high level, you still need assembly.

    4) when you are unsure whether the compiler actually spits out what you want, you need to read the disassembly. While compiler bugs are not really likely, subtle code bugs are.
  • 1
    Some knowledge of the c calling convention might help you.

    Assembly is really fun.
  • 0
    Is you are a Linux person, try writing with the at&t syntax and use GAS as your assembler. Things start to make more sense when you don't have to deal with window's weirdness.

    Also att syntax makes more sense.
  • 3
    @AleCx04 Knowing assembly is very useful for optimization reasons. Especially for languages like C++ where one can inline handwritten assembly into the "normal" code. V8, for instance, has a bunch of handwritten Assembly for the various architectures they Support.
    Inlining assembly in c++ is the perfect storm of high-level abstractions and low-level optimizations. And not a waste of life.
  • 1
    @Batburger i can see what you mean my dude. I should have stated that it was a waste in my case.
  • 2
    Assembly is love.
Add Comment