#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
char message1[]="Input the number of times for looping in the range of 0-12:";
char message9[] = "\nThe program will run";
char message10[] = "times.\n";
char message2[]="\nEnter an alphabet or a numeric digit:";
char message3[] = "Output:\n";
char message4[] = "\na.Number of upper-case alphabets made by user:%ecx\n";
char message5[]="\nb.Number of lower-case alphabets made by user: %ebx\n",edx;
char message6[]="\nc.Average of numeric inputs made by user: %eax\n",eax ;
char message7[] = "\nThe program exists without looping.";
char message8[] = "Type in any integer and press RETURN key to finish:";
char format[]="%u";
int times;
int counter;
int digit;
int end;
_asm {
lea eax, message1;
push eax;
call printf;
add esp, 4;
lea eax, counter;
push eax;
lea eax, format;
push eax;
call scanf_s;
add esp, 8;
mov eax, counter;
cmp eax, 0;
jle nequal;
lea eax, message9;
push eax;
call printf;
add esp, 4;
lea eax, times;
push eax;
lea eax, format;
push eax;
call printf;
add esp, 4;
lea eax, message10;
push eax;
call printf;
add esp, 4;
mov ebx, 0;
for_loop:
lea eax, message2;
push eax;
call printf;
add esp, 4;
lea eax, digit;
push eax;
lea eax, format;
push eax;
call scanf_s;
add esp, 8;
inc ebx;
cmp ebx, counter;
jl for_loop;
Uppercase:
lea eax, message3;
push eax;
call printf;
add esp, 4;
lea eax, message4;
push eax;
call printf;
add esp, 4;
mov ah, 1;
cmp al, 'A';
jb next1;
cmp al, 'Z';
ja next1;
mov ecx, 0;
inc ecx;
jmp exit;
Lowercase:
next1:
lea eax, message5;
push eax;
call printf;
add esp, 4;
cmp al, 'a';
jb next2;
cmp al, 'z';
ja next2;
mov edx, 0;
inc edx;
jmp exit;
Numeric:
next2:
lea eax, message6;
push eax;
call printf;
add esp, 4;
cmp al, '0';
jb next3;
cmp al, '9';
ja next3;
mov eax, 0;
add eax, digit;
jmp exit;
next3:
jl for_loop;
exit:
jmp finish;
nequal:lea eax, message7;
push eax;
call printf;
add esp, 4;
finish:lea eax, message8;
push eax;
call printf;
add esp, 4;
lea eax, end;
push eax;
lea eax, format;
push eax;
call scanf_s;
add esp, 8;
}
return 0;
}
这样输出的数字会特别大。。我想输出我所输入的数字,问题在哪里。
以及如果我需要统计一句话中的字母和我所输入数字的平均值,应该怎么写代码?