Created
October 14, 2012 10:50
-
-
Save farces/3888239 to your computer and use it in GitHub Desktop.
sample dumb assembly thing
This file contains 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
void main() { | |
int i = 0; | |
while (i < 10) { | |
printf("Added 1 to i\n"); | |
i++; | |
} | |
printf("Done!\n"); | |
printf("Doing some assembly\n"); | |
/* replicate "while (i < 20) { i++; }" from assembly output. | |
[i] could be replaced by [ebp-12] as .asm states: | |
_i$ = -12 | |
cmp DWORD PTR _i$[ebp], 10; is equivalent to | |
cmp DWORD PTR [ebp+_i$], 10; */ | |
_asm { | |
dicks: | |
cmp DWORD PTR [i], 20; | |
jge over; | |
mov eax, DWORD PTR [i] | |
add eax,1; | |
mov DWORD PTR [i], eax; | |
jmp dicks; | |
over: | |
} | |
char out[3]; | |
sprintf_s(out, "%d", i); | |
printf(out); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment