x86 Assembly Crash Course: Memory and the Stack

Поділитися
Вставка
  • Опубліковано 18 лис 2024

КОМЕНТАРІ • 14

  • @sectorjeat
    @sectorjeat Рік тому

    Great videos as always!! I’d really want to watch more of this series!!

  • @ohp98
    @ohp98 2 роки тому +9

    This was a great video, very well explained, I'd be interested to see more content like this, do you have any good sources for learning x86 assembly?

  • @rty1955
    @rty1955 5 місяців тому +1

    Fun fact: IBM Maonframes dont have a stack, stack pointerb or stack operstions. They are simply not needed and is a silly concept.
    Memory is memory, use it anyway you want. Also special registers are silly too. Just give me many GENERAL purpose registers and a robust instriction set.

  • @kahnfatman
    @kahnfatman 29 днів тому

    In software engineering, trees grow downward.. So does the stack. No wonder ppl asked me to fix their printers as a software engineering student.

  • @Ubervisor_
    @Ubervisor_ 4 місяці тому

    Really good explanation!

  • @WistrelChianti
    @WistrelChianti 3 роки тому +13

    Maybe I got confused, in the first example I think you put the data on the stack and used the stack pointer to reference it. In the 2nd example you... ooooh I get it, you kinda "implemented push" but in a generic way. In essence you treated the value of the stack pointer as if it were a pointer that could have gone anywhere (at a guess) but of course, because it was the stack pointer, it was actually pointing to the top of the stack. I guess tthe only difference is that presumably push decrements the stack pointer first and then stores the input at that address, so in the 2nd example you are kinda overwriting whatever would have last been pushed to the stack? Sorry if I didn't get that right.

    • @doctorbobstone
      @doctorbobstone 3 роки тому +19

      Yep. The push instruction decrements the stack pointer and then writes the data to the memory locations it is now pointing at. In this tutorial we used mov to write the data, but we never decremented, so we overwrote whatever was on the top of the stack. In a normal situation, the function calling you would have written something at the top of the stack, so overwriting it would probably be bad. But here, we're calling exit immediately after, so while it may not be ideal, at least we don't stick around to regret overwriting that memory.
      I didn't actually know what was on the stack at the beginning of the process so I googled it. Turns out that we overwrote argc. Other things on the stack when the program starts running include argv (the arguments to the program), envp (the environment), and auvx, the ELF auxiliary vector (includes a bunch of fascinating low-level information, mostly for the benefit of the dynamic loader (which we are not using here)).

    • @jamesdupuis3249
      @jamesdupuis3249 4 місяці тому

      Beautiful reply thank you I am learning so much ​@@doctorbobstone

    • @bryanbisimotopinas345
      @bryanbisimotopinas345 Місяць тому

      @@doctorbobstone Thanks! Confirmed my understanding that he overwrote whatever was on the stack instead of pushing it down. Kinda important lol. Can you push the stack down manually without using opcode push?

  • @mlinaje
    @mlinaje Рік тому +1

    What would you recommend as editor, assembler (as, fasm, nasm) and debuger for Linux?
    Tanks in advance. I'm enjoying your videos.

    • @64_bit_coding
      @64_bit_coding Рік тому +1

      nasm syntax is pretty easy. use as if you like slightly harder and more advanced syntax. also gdb is a really good debugging toll since you can view memory, add breakpoints, and see other things