Assembly Language for Beginners
1.22. MANIPULATING SPECIFIC BIT(S) ; do OR: ORR r0,r0,#0x80000000 BX lr ENDP negate PROC ; do XOR: EOR r0,r0,#0x80000000 BX lr E ...
1.22. MANIPULATING SPECIFIC BIT(S) BIC R3, R2, #0x80000000 ; copy from R3 to S0: FMSR S0, R3 BX LR set_sign ; copy from S0 to R2 ...
1.22. MANIPULATING SPECIFIC BIT(S) int main() { f(0x12345678); // test }; In this loop, the iteration count valueiis counting fr ...
1.22. MANIPULATING SPECIFIC BIT(S) TheIS_SETmacro is in fact the logical AND operation (AND) and it returns 0 if the specific bi ...
1.22. MANIPULATING SPECIFIC BIT(S) OllyDbg Let’s load this example into OllyDbg. Let the input value be0x12345678. Fori= 1, we s ...
1.22. MANIPULATING SPECIFIC BIT(S) SHLhas been executed: Figure 1.99:OllyDbg:i= 1,EDX= 1 ≪1 = 2 EDXcontain 1 ≪ 1 (or 2). This is ...
1.22. MANIPULATING SPECIFIC BIT(S) ANDsetsZFto 1, which implies that the input value (0x12345678) ANDed with 2 results in 0: Fig ...
1.22. MANIPULATING SPECIFIC BIT(S) Let’s trace a bit further andiis now 4.SHLis to be executed now: Figure 1.101:OllyDbg:i= 4,ii ...
1.22. MANIPULATING SPECIFIC BIT(S) EDX= 1 ≪ 4 (or0x10or 16): Figure 1.102:OllyDbg:i= 4,EDX= 1 ≪4 = 0x 10 This is another bit mas ...
1.22. MANIPULATING SPECIFIC BIT(S) ANDis executed: Figure 1.103:OllyDbg:i= 4, is there that bit in the input value? Yes. (ZF=0) ...
1.22. MANIPULATING SPECIFIC BIT(S) cmp [ebp+i], 1Fh jle short loc_80483D0 mov eax, [ebp+rt] add esp, 10h pop ebx pop ebp retn f ...
1.22. MANIPULATING SPECIFIC BIT(S) pop rbp ret Optimizing GCC 4.8.2 Listing 1.291: Optimizing GCC 4.8.2 1 f: 2 xor eax, eax ; rt ...
1.22. MANIPULATING SPECIFIC BIT(S) dec r8 ; R8-- jne SHORT $LL4@f fatret 0 f ENDP Here theROLinstruction is used instead ofSHL, ...
1.22. MANIPULATING SPECIFIC BIT(S) ARM + Optimizing Xcode 4.6.3 (LLVM) (ARM mode) Listing 1.294: Optimizing Xcode 4.6.3 (LLVM) ( ...
1.22. MANIPULATING SPECIFIC BIT(S) bne .L2 ; yes mov w0, w2 ; return rt ret The result is very similar to what GCC generates for ...
1.22. MANIPULATING SPECIFIC BIT(S) addiu $sp, -0x18 sw $fp, 0x18+var_4($sp) move $fp, $sp sw $a0, 0x18+a($fp) ; initialize rt an ...
1.22. MANIPULATING SPECIFIC BIT(S) Listing 1.298: Optimizing GCC 4.4.5 (IDA) f: ; $a0=a ; rt variable will reside in $v0: move $ ...
1.22. MANIPULATING SPECIFIC BIT(S) Check for specific bit (specified at runtime) This is usually done by this C/C++ code snippet ...
1.23 Linear congruential generator. Clear specific bit (known at compile stage) Just applyANDoperation with the inverted value: ...
1.23. LINEAR CONGRUENTIAL GENERATOR void my_srand (uint32_t init) { rand_state=init; } int my_rand () { rand_state=rand_state*RN ...
«
13
14
15
16
17
18
19
20
21
22
»
Free download pdf