问题描述
- visual studio 内联汇编问题
-
#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[] = "
The program will run";
char message10[] = "times.
";
char message2[]="
Enter an alphabet or a numeric digit:";
char message3[] = "Output:
";
char message4[] = "
a.Number of upper-case alphabets made by user:%ecx
";
char message5[]="
b.Number of lower-case alphabets made by user: %ebx
",edx;
char message6[]="
c.Average of numeric inputs made by user: %eax
",eax ;
char message7[] = "
The 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;
}
这样输出的数字会特别大。。我想输出我所输入的数字,问题在哪里。
以及如果我需要统计一句话中的字母和我所输入数字的平均值,应该怎么写代码?
解决方案
单步调试下,代码太多。
解决方案二:
1、打开工作区时出现了如下错误: cannot access the ClassView information file.ClassView information will not be available.解决方法:a.关闭工程b.删除工程下.clw .ncb 文件及/debug目录,c.重建工程build all......
答案就在这里:Visual studio 常见问题
----------------------
时间: 2024-11-01 16:49:36