The task is simple: Create an if-statement from scratch in x86 assembly that runs in as few clock-cycles as possible.
- Must be x86 assembly.
- Can't use any of the conditional jump/branch instructions (e.g.
je,jne,jz,jg,jge,jl,jle). - Can use
jmpto jump to existing blocks of code. - Can use
cmpif necessary. - Can't call any external libraries or functions.
- Can't use
call. - Free to use any of the other available instructions in the Intel docs.
- No C.
- Any of the ~7 Intel Core architectures are acceptable (listed on page 10). Ideally Nehalem (Intel Core i7).
- The
ifstatement needs to check arbitrary conditions. Basically replicating the functionality of any one of theje,jge, etc. conditional jumps.
The winning answer is one that uses the fewest clock cycles possible. That is, it can have the most operations per second. Approximate clock cycle summaries are here: http://www.agner.org/optimize/instruction_tables.pdf. Calculating clock cycles can happen after the answer is posted.
if-statement" mean? Would something likejmp [eax]be ok? \$\endgroup\$ifstatement needs to check arbitrary conditions. Basically replicating the functionality of any one of theje,jge, etc. conditional jumps. \$\endgroup\$