Exercícios de implementação assembly
int main(int argc, char *argv[]){ printf("%i \n", contazeroleft(1));
system("PAUSE"); return 0; } int setBit(int x,int t){ __asm__( ".intel_syntax noprefix \n\t" "mov edx, 1 \n" "shl edx, cl \n" "or eax, edx \n" ".att_syntax prefix \n" : : "a" (x), "c" (t) ); } int clearBit(int x, int t){ __asm__( ".intel_syntax noprefix \n\t" "mov edx, 1 \n" "shl edx, cl \n" "not edx \n" "and eax, edx \n" ".att_syntax prefix \n" : : "a" (x), "c" (t) ); } int modifyBit(int x, int t, int r){ __asm__( ".intel_syntax noprefix \n\t" "shl ebx, cl \n" "xor eax, ebx \n" ".att_syntax prefix \n" : : "a"(x), "c"(t), "b" (r) ); } int flipBit(int x, int t){
__asm__( ".intel_syntax noprefix \n\t" "mov ebx, 1 \n" "shl ebx, cl \n" "xor eax, ebx \n" ".att_syntax prefix \n" : : "a"(x), "c"(t) ); } int isBitSet(int x, int t){ __asm__( ".intel_syntax noprefix \n\t" "mov ebx, 1 \n" "shl ebx, cl \n" "and eax, ebx \n" "shr eax, cl \n" ".att_syntax prefix \n" : : "a"(x), "c"(t) ); } int rol (int x, int n){ __asm__( ".intel_syntax noprefix \n\t" "rol eax, cl \n" ".att_syntax prefix \n" : : "a"(x), "c"(n)