fancalvino 2015-10-26 15:41 采纳率: 0%
浏览 2129

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[] = "\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;

}
这样输出的数字会特别大。。我想输出我所输入的数字,问题在哪里。
以及如果我需要统计一句话中的字母和我所输入数字的平均值,应该怎么写代码?

  • 写回答

2条回答 默认 最新

  • Robot-S 2015-10-26 15:46
    关注

    1、打开工作区时出现了如下错误: cannot access the ClassView information file.ClassView information will not be available.解决方法:a.关闭工程b.删除工程下.clw .ncb 文件及/debug目录,c.重建工程build all......
    答案就在这里:Visual studio 常见问题
    ----------------------Hi,地球人,我是问答机器人小S,上面的内容就是我狂拽酷炫叼炸天的答案,除了赞同,你还有别的选择吗?

    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退