70

Bootloaders in asm ;_;

why am I doing this to myself?

Comments
  • 16
    +1 for those comments in code. My team should learn of that.
  • 1
    I remember having to do that for a school assignment, but never got the hang of x86 asm
  • 1
    @LuxARTS Thanks, but outside of assembler, comments are a bad friend, IMHO
  • 1
    I'm kind of jealous. I know a bit of assembly but it's one of those things I wish I would have invested more time into.
  • 2
    @gnulinuxer4fun Why? If you need to share your code or modify an old one you have to spent time analyzing the code. That's a waste of time. With comments (good comments) that time is spent in the job. Also, commenting the code will make the documentation process easier and faster (see Doxygen).
  • 1
    @Haxk20 I use asm for ARM devices and it's not too difficult. X86 it's harder for me.
  • 1
    Where you learn to do this?
  • 2
    @LuxARTS

    You know - function names should be enough to read the code. Whats best, in your opinion?

    a)

    void doStuff () { //calculates the sum of pressed keys

    aaa (); //initialize

    bbb (); //make sure input is correct

    ccc (); //calculate

    }

    b)

    void calculateSumOfKeysPressed () { //calculates the sum of pressed keys

    initialize (); //initialize

    checkInput (); //make sure input is correct

    sumUp (); //calculate

    }

    c)

    void calculateSumOfKeysPressed () {

    initialize ();

    checkInput ();

    sumUp ();

    }

    I'd argue that c is the best, because its quickly skimmed through and very expressive
  • 1
    @beegC0de i'm an undergraduate at the fuck all university
  • 1
    @gnulinuxer4fun what text are you guys using
  • 0
    @beegC0de are you asking about which font I use?

    i use firacode font ligatures
  • 1
    @gnulinuxer4fun no which textbook
  • 1
    @gnulinuxer4fun yep, because all functions consist of other function calls... Stop being a purist ahole, comments help.
  • 0
    @beegC0de ZE INTERNET and a lot of watching compiler output and many nice internet friends
  • 0
    @aviophile Well what if... you put everything inside a function? If you have the need to comment, it means that you code uncleanly - or (in rare occasions) it means that something is really hard to get... in THIS case, you may put in a comment
  • 2
    @gnulinuxer4fun of course the option C is the best but that's because you wrote the function names. Comments are notes to understand the algorithms blocks inside the functions. Plus, commenting inline it's for short notes. Having the documentation in the code it's a lot easier to read and understand.
  • 1
    It's quite useful to know/have some experience with assembly language. I wouldn't question why you are doing it to yourself, as long as you are either enjoying it and/or gaining knowledge from it!

    I always find a great sense of accomplishment from achieving even a relatively small goal in assembly language. Such as the time I wrote some code that could invoke a C routine with arguments provided in an array (like JavaScript's "apply" function method). Was used in something I wrote that attached to a process as a debugger, copied some of the stack and then executed a routine locally with the same arguments.

    Didn't use it for much in the end, but was enjoyable doing weird things in code!
  • 1
    @Haxk20 that's an interesting opinion. I usually prefer arm or mips. X86 is just painfully large and complicated imho. But to each their own.
  • 1
    That's some top-notch asm commenting I've ever seen
  • 0
  • 1
    @maushax I'm surprised I haven't yet found an internet forum / debate board dedicated to clean code.
  • 1
    @Lor-inc github :D
  • 1
    @gnulinuxer4fun it's rare, generally github is more a collection of counterexamples.
  • 0
    @Lor-inc Yea they are made to teach you how not to be ;-)
  • 1
    That's comments-porn.
  • 1
    @BinaryByter Comments are super useful in a professional environment.

    A project evolves over time and has a tendency to get messy. It helps yourself but more importantly the following devs to stay clean.

    I know it's a bit hard to get it before being fully immersed into a professionnal work environment but do yourself (and others) a favor and get used to it before.
  • 0
    @Cultist If your time can keep the code clean, comments will mess up the code. Just comment WHY you do things, if that question isnt obvious
Add Comment