Assembly Language for Beginners
3.10 String to number conversion (atoi()) Non-optimizing Xcode 4.6.3 (LLVM) and Keil 6/2013 Non-optimizing LLVM does not generat ...
3.10. STRING TO NUMBER CONVERSION (ATOI()) rt=rt*10 + (*s-'0'); s++; }; return rt; }; int main() { printf ("%d\n", my_atoi ("123 ...
3.10. STRING TO NUMBER CONVERSION (ATOI()) There is no instruction for multiplication by 10, two LEA instruction do this instead ...
3.10. STRING TO NUMBER CONVERSION (ATOI()) Optimizing Keil 6/2013 (Thumb mode) Listing 3.25: Optimizing Keil 6/2013 (Thumb mode) ...
3.10. STRING TO NUMBER CONVERSION (ATOI()) ; variable to be returned (rt) is in W0, ready to be used in caller function ret .L4: ...
3.10. STRING TO NUMBER CONVERSION (ATOI()) ; ESI=0 here if there was no minus sign and 1 if it was lea eax, [rdx-48] ; any chara ...
3.10. STRING TO NUMBER CONVERSION (ATOI()) The compilers do this often, so it’s important to recognize these tricks. Another exa ...
3.11 Inline functions Try to explain, what happened and why. 3.11 Inline functions Inlined code is when the compiler, instead of ...
3.11. INLINE FUNCTIONS strcmp() Listing 3.31: strcmp() example bool is_bool (char *s) { if (strcmp (s, "true")==0) return true; ...
3.11. INLINE FUNCTIONS mov dl, BYTE PTR [eax] cmp dl, BYTE PTR [ecx] jne SHORT $LN7@is_bool test dl, dl je SHORT $LN8@is_bool mo ...
3.11. INLINE FUNCTIONS strlen() Listing 3.34: strlen() example int strlen_test(char *s1) { return strlen(s1); }; Listing 3.35: O ...
3.11. INLINE FUNCTIONS Listing 3.39: Optimizing GCC 4.9.1 x64 f: mov QWORD PTR [rdi], 0 mov QWORD PTR [rdi+8], 0 mov QWORD PTR [ ...
3.11. INLINE FUNCTIONS Listing 3.43: memcpy() example void memcpy_7(char inbuf, char outbuf) { memcpy(outbuf+10, inbuf, 7); }; L ...
3.11. INLINE FUNCTIONS push edi mov edi, DWORD PTR _outbuf$[esp+4] add edi, 10 mov ecx, 32 rep movsd pop edi pop esi ret 0 _memc ...
3.11. INLINE FUNCTIONS test edi, 2 mov BYTE PTR [edx+10], al mov eax, 122 je .L7 .L25: movzx edx, WORD PTR [esi] add edi, 2 add ...
3.12 C99 restrict. $LN6@memcmp_123: sbb eax, eax or eax, 1 pop esi ret 0 _memcmp_1235 ENDP strcat() This is inlined strcat() as ...
3.12. C99 RESTRICT calculate nextsum_product[i]—on this stage, we need to load from memory the already calculated sum[i]andprod ...
3.12. C99 RESTRICT jne .L6 .L1: pop rbx rsi rdi rbp r12 r13 r14 r15 ret Listing 3.54: GCC x64: f2() f2: push r13 r12 rbp rdi rsi ...
3.13 Branchlessabs()function 3.13 Branchlessabs()function Let’srevisitanexampleweconsideredearlier1.14.2onpage141andaskourselves ...
3.14 Variadic functions. Listing 3.56: Optimizing GCC 4.9 ARM64 my_abs: ; sign-extend input 32-bit value to X0 64-bit register: ...
«
22
23
24
25
26
27
28
29
30
31
»
Free download pdf