1

I am working through a modified version of binary bomb, but I am stuck on what the value of %rsi is. Does it have something to do with line 5 and moving value into rax?

Thanks

Dump of assembler code for function phase_2:

=> 0x00000000004011c7 <+0>: sub    $0x8,%rsp
0x00000000004011cb <+4>:    cmp    $0x3,%rdi  //contains 3 values
0x00000000004011cf <+8>:    je     0x4011df <phase_2+24>  //check values if equal to three
0x00000000004011d1 <+10>:   callq  0x401bd7 <bomb_explosion>
0x00000000004011d6 <+15>:   mov    $0xffffffffffffffff,%rax
0x00000000004011dd <+22>:   jmp    0x401214 <phase_2+77>
0x00000000004011df <+24>:   not    %rsi
...

1 Answers1

2

RSI contains the second argument to the function. (The first argument is in RDI.)

For x86-64 systems that conform to the System V ABI (Linux, OS X, most UNIX in general; Windows uses a different calling convention), the first six integer and pointer parameters to a function are in RDI, RSI, RDX, RCX, R8, and R9. Floating-point arguments are passed in XMM (SSE) registers.

Matteo Italia
  • 123,740
  • 17
  • 206
  • 299
prl
  • 11,716
  • 2
  • 13
  • 31
  • so in this phase, `%rdi` would be the checking the number of inputs (the first register), what value would `%rsi` hold to perform a NOT operation on it, the value of `rax`? –  Sep 25 '17 at 06:10
  • There is nothing in the code fragment you provided to confirm or deny that rdi might be some type of count of the number of inputs, but that would not be a common usage. I *could* see it being a count of the number of entries in an array (pointed to by one of the other parameters), but there is no evidence here to support that either. The value of rax is undefined throughout the code you have provided us. NOT can be performed on any 'value' that might be in rsi. Note that prl has apparently answered the question "Value of %rsi in assembly code." New questions should not be appended to old. – David Wohlferd Sep 25 '17 at 06:27
  • @copernicus1996: yeah, some other bomb questions recently have had callers that pass a `sscanf` return value as the first argument. e.g. https://stackoverflow.com/questions/46320479/jmpq-and-lea-and-how-does-rdi-register-work-in-binary-bomb – Peter Cordes Sep 25 '17 at 14:42