Assembly Language for Beginners
3.4. FIBONACCI NUMBERS Let’s load it in OllyDbg once again: Figure 3.2:OllyDbg: last call off() Now thenextvariable is present i ...
3.4. FIBONACCI NUMBERS Let’s investigate the stack more closely. The author has again added his comments: 0029FC14 00E0103A RETU ...
3.5 CRC32 calculation example (* n (factorial (- n 1))))) Tail call is important because compiler can rework this code easily in ...
3.5. CRC32 CALCULATION EXAMPLE 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0 ...
3.5. CRC32 CALCULATION EXAMPLE and ebx, 255 ; EBX = hash & 0xff ; XOR EDI, EBX (EDI=EDI^EBX) - this operation uses all 32 bi ...
3.6 Network address calculation example 3.6 Network address calculation example As we know, a TCP/IP address (IPv4) consists of ...
3.6. NETWORK ADDRESS CALCULATION EXAMPLE uint32_t netmask=form_netmask(netmask_bits); uint32_t ip=form_IP(ip1, ip2, ip3, ip4); u ...
3.6. NETWORK ADDRESS CALCULATION EXAMPLE Take the fourth (lowest) byte, apply OR operation to this byte and return the value. T ...
3.6. NETWORK ADDRESS CALCULATION EXAMPLE ; ECX=000000bb shl eax, 8 ; EAX=00ddcc00 or eax, ecx ; EAX=00ddccbb movzx ecx, BYTE PTR ...
3.6. NETWORK ADDRESS CALCULATION EXAMPLE Optimizing MSVC 2012 does almost the same, but without unnecessary reloading of the inp ...
3.7 Loops: several iterators push eax push ecx call _set_bit inc bl movzx edx, bl add esp, 8 mov ecx, eax cmp edx, esi jl SHORT ...
3.7. LOOPS: SEVERAL ITERATORS ; R8=cnt test r8, r8 ; cnt==0? exit then je SHORT $LN1@f npad 11 $LL3@f: mov eax, DWORD PTR [rdx] ...
3.7. LOOPS: SEVERAL ITERATORS There is nocountervariable any more: GCC concluded that it is not needed. The last element of thea ...
3.7. LOOPS: SEVERAL ITERATORS ; store 32-bit word at $a0: sw $a3, 0($a0) ; add 0x1C (28) to $a1 at each iteration: addiu $a1, 0x ...
3.8 Duff’s device inc r10 mov DWORD PTR [r9+rcx], r11d add r9, 12 add rax, 28 cmp r10, r8 jb .B1.8 jmp exit just_copy:: ; R8 = c ...
3.8. DUFF’S DEVICE *(uint64_t*)dst=0; dst=dst+8; }; // work out the tail switch(count & 7) { case 7: dst++ = 0; case 6: dst+ ...
3.8. DUFF’S DEVICE movsxd rax, r8d cmp rax, r9 jb SHORT $LL19@bzero $LN11@bzero: ; work out the tail and edx, 7 dec rdx cmp rdx, ...
3.9 Division using multiplication Unrolled loops are slower than short loops if there is a fast cache betweenRAMandCPUand the bo ...
3.9. DIVISION USING MULTIPLICATION Listing 3.20: Non-optimizing GCC 4.4.1 public f f proc near arg_0 = dword ptr 8 push ebp mov ...
3.9. DIVISION USING MULTIPLICATION ; takes argument in a1 ; returns quotient in a1, remainder in a2 ; cycles could be saved if o ...
«
21
22
23
24
25
26
27
28
29
30
»
Free download pdf