Note that there are some explanatory texts on larger screens.

plurals
  1. PODive into the assembly
    primarykey
    data
    text
    <p>Function in <code>c</code>:</p> <pre><code>PHPAPI char *php_pcre_replace(char *regex, int regex_len, char *subject, int subject_len, zval *replace_val, int is_callable_replace, int *result_len, int limit, int *replace_count TSRMLS_DC) { pcre_cache_entry *pce; /* Compiled regular expression */ /* Compile regex or get it from cache. */ if ((pce = pcre_get_compiled_regex_cache(regex, regex_len TSRMLS_CC)) == NULL) { return NULL; } .... } </code></pre> <p>Its assembly:</p> <pre><code>php5ts!php_pcre_replace: 1015db70 8b442408 mov eax,dword ptr [esp+8] 1015db74 8b4c2404 mov ecx,dword ptr [esp+4] 1015db78 56 push esi 1015db79 8b74242c mov esi,dword ptr [esp+2Ch] 1015db7d 56 push esi 1015db7e 50 push eax 1015db7f 51 push ecx 1015db80 e8cbeaffff call php5ts!pcre_get_compiled_regex_cache (1015c650) 1015db85 83c40c add esp,0Ch 1015db88 85c0 test eax,eax 1015db8a 7502 jne php5ts!php_pcre_replace+0x1e (1015db8e) php5ts!php_pcre_replace+0x1c: 1015db8c 5e pop esi 1015db8d c3 ret </code></pre> <p>The c function call <code>pcre_get_compiled_regex_cache(regex, regex_len TSRMLS_CC)</code> corresponds to <code>1015db7d~1015db80</code> which pushes the 3 parameters to the stack and call it.</p> <p>But my doubt is,among so many registers,how does the compiler decide to use <code>eax</code>,<code>ecx</code> and <code>esi</code>(this is special,as it's restored before using,why?) as the intermediate to carry to the stack?</p> <p>There must be some hidden indication in c that tells the compiler to do it this way,right?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload