Good question. I can't answer that either. I guess to answer that we would have to know more about the "red zone". He mentioned it once in his previous videos but never explains it. It seems to be some kind of special place reserved for some stuff. Maybe local variables. But I don't know exactly. >> Still awesome learning resource!
@@y.5107 Red zone is something the operating system will allocate after the stack pointer that mean you don't need to allocate memory for local use except if you want another stack frame you will need to allocate but the red zone will still there . This is only compiler optimization thing really. So the compiler will set that if you enable the optimzation. But this only work with AMD64 ABI.
But Imulq instruction is supossed to have only one operand , the other would be the register rax implicitly … so we should put one operand in register and then fetch the other, the result would be stored in rdx:rax Why does he use 2 operands for the imulq instruction ??
awesome! thanks for posting. That cleared a lot of things up for me.
5:25 why functions can access memory up to 128 bytes beyond %rsp?
Good question. I can't answer that either. I guess to answer that we would have to know more about the "red zone". He mentioned it once in his previous videos but never explains it. It seems to be some kind of special place reserved for some stuff. Maybe local variables. But I don't know exactly. >> Still awesome learning resource!
@@y.5107
Red zone is something the operating system will allocate after the stack pointer that mean you don't need to allocate memory for local use except if you want another stack frame you will need to allocate but the red zone will still there .
This is only compiler optimization thing really.
So the compiler will set that if you enable the optimzation.
But this only work with AMD64 ABI.
11:41 Could we do "leaq (%rdi), %rsi" instead of "leaq 16(%rsp), %rsi" as well, or am i missing something?
16(%rsp)
Rsp + 16
(%rsp)
rsp with out + 16
%rdi contains a literal "1" and not an address. So leaq (%rdi), %rsi means %rsi = 1. We want to save the address in %rsi and not the value
Amazing lecture
But Imulq instruction is supossed to have only one operand , the other would be the register rax implicitly … so we should put one operand in register and then fetch the other, the result would be stored in rdx:rax
Why does he use 2 operands for the imulq instruction ??
Should %edx be %rdx around 12:00?
I think although I'm a learner like you. edx is for 32bits
But the function take 32 bit argument not 64 bit
So we use the edx register for that
%edx refers to the low-order 4 bytes of the register %rdx.