Created
November 5, 2013 13:56
-
-
Save orzFly/7319335 to your computer and use it in GitHub Desktop.
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
#include <stdio.h> | |
#include <stdlib.h> | |
int main (void) | |
{ | |
char get1[] = "Please input an integer:"; | |
char get2[]="posamount:"; | |
char get3[]="negamount:"; | |
char get4[]="input n: "; | |
char format[] = "%d"; | |
char format2[] = "%s%d\n"; | |
int input; | |
_asm{ | |
lea eax, get4 | |
push eax | |
call printf | |
add esp, 4 | |
lea eax, input | |
push eax | |
lea eax, format | |
push eax | |
call scanf | |
add esp,8 | |
mov edx, input | |
xor ebx, ebx | |
xor ecx, ecx | |
xloop: | |
dec edx | |
cmp edx, 0 | |
jl endloop | |
push ebx | |
push ecx | |
push edx | |
lea eax, get1 | |
push eax | |
call printf | |
add esp, 4 | |
lea eax,input | |
push eax | |
lea eax,format | |
push eax | |
call scanf | |
add esp,8 | |
pop edx | |
pop ecx | |
pop ebx | |
mov eax,input | |
cmp eax,0 | |
jg positive | |
je xloop | |
inc ecx | |
jmp xloop | |
positive: | |
inc ebx | |
jmp xloop | |
endloop: | |
push ecx | |
push ebx | |
lea eax, get2 | |
push eax | |
lea eax, format2 | |
push eax | |
call printf | |
add esp, 12 | |
lea eax, get3 | |
push eax | |
lea eax, format2 | |
push eax | |
call printf | |
add esp, 12 | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
可喜可贺 可喜可贺