-
-
Save sudhackar/0f566726180ce533a4c8062b2294f021 to your computer and use it in GitHub Desktop.
x86 bt instruction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* bt.c | |
* | |
* gcc -Wall -m32 -masm=intel -o "untitled" "untitled.c" (in directory: /tmp) | |
* | |
* Copyright 2018 Sudhakar Verma <sudhakar@payatu> | |
* | |
* This program is free software; you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation; either version 2 of the License, or | |
* (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU General Public License for more details. | |
* | |
* You should have received a copy of the GNU General Public License | |
* along with this program; if not, write to the Free Software | |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
* MA 02110-1301, USA. | |
* | |
* | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
void yes() { | |
puts("yes"); | |
exit(0); | |
} | |
void no() { | |
puts("no"); | |
exit(0); | |
} | |
int main(int argc, char **argv) { | |
int a; | |
a = atoi(argv[2]); | |
asm("push eax"); | |
a = atoi(argv[1]); | |
asm("pop ebx"); | |
asm("clc"); | |
asm("bt eax, ebx"); | |
asm("jc yes"); | |
asm("jnc no"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment