Skip to content

Instantly share code, notes, and snippets.

@farces
Created October 14, 2012 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save farces/3888239 to your computer and use it in GitHub Desktop.
Save farces/3888239 to your computer and use it in GitHub Desktop.
sample dumb assembly thing
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