Home > Blockchain >  Having trouble determining the return value in assembly language
Having trouble determining the return value in assembly language

Time:12-10

I am new to the world of assembly language/code. I find it difficult to understand but I try my best. I'm just having trouble with some of the questions I need to answer for an assignment.

  1. I need to find out the return value of a specific program, if I pass echo $? as a command in the terminal, I get 10 as an answer. However my teacher's answer sheet says the answer is 9.

  2. I need to find out the return value of the main (of the same program) by examining a dump of the assembler code. Again, I think the answer is 10, because 0xa = 10. However, the answer sheet again says the answer is 9. Do I need to subtract a 1 from the return value by default or something? If so, why?

    0x000000000000069f < 0>:     55               push    %rbp
    0x00000000000006a0 < 1>:     48 89 e5         mov    %rsp,%rbp
    0x00000000000006a3 < 4>:     bf 05 00 00 00   mov    $0x5,           
  • Related