![]() |
|
[Assembly] TEST Instruction Equivalent in C ? - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5) +---- Thread: [Assembly] TEST Instruction Equivalent in C ? (/showthread.php?tid=5559654) |
TEST Instruction Equivalent in C ? - RobotCrack - Feb 24, 2017 In need little bit help ! What PHP Code * - webdev77 - Feb 24, 2017 You don't need the test instruction in higher level languages because there are better ways to write the code. It's a bitwise and operation, so you can implement that if you wish. Truly, there is no direct equivalent to my knowledge, but there are many easy ways to achieve the same result. * - RobotCrack - Feb 24, 2017 (Feb 24, 2017 08:40 AM)webdev77 Wrote: You don't need the test instruction in higher level languages because there are better ways to write the code. It's a bitwise and operation, so you can implement that if you wish. Truly, there is no direct equivalent to my knowledge, but there are many easy ways to achieve the same result. Thanks. Appreciate it! * - Masm4ever - Feb 24, 2017 Code include \masm32\include\masm32rt.incOutput: Code test 4 succeededNow the same in C: Code #include <stdio.h>Some stupid brackets more but otherwise pretty much the same. P.S.: If you prefer "pure" assembler, you can use test ebx, 4: Code test ebx, 4* - movsx - Feb 24, 2017 (Feb 24, 2017 08:32 AM)RobotCrack Wrote: In need little bit help ! You don't need to worry about that, the compiler does. C is modeled as an 'abstract machine' * - electricalengineering - Feb 25, 2017 Test operation: if ( !(me & you) ) //where me and you == 0 { } equivalence: test eax, eax ; where eax is 0. ;zf = 1 je ... |