是作业,之前对汇编也是完全没有了解。
老师也只给了一个还有很大完善空间的文档。
在vs2017下
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
char message1[] = "Select total number of positive integers (between 2-5): ";
char message2[] = "\bEnter positive integer ";
char message3[] = ": ";
char message4[] = "\nProgram terminates and has looped ";
char message5[] = " times.";
char message6[] = "Your integers from lowest to highest is ";
char message7[] = "The total amount is ";
char message8[] = ".";
char format[] = "%d"; // format string for the scanf function
int n;
int num0;
int num1;
int num2;
int num3;
int num4;
int num5;
_asm {
lea eax, message1
push eax
call printf ;print 1st message
add esp,4
lea eax, n
push eax
lea eax, format
push eax
call scanf_s ;reading total number
add esp, 8
mov ecx, n
push ecx
lea ecx, format
push ecx
add esp,8
mov ecx,n
;=======以下内容出现问题================
s:
lea eax, message1
push eax
call printf; print 1st message
add esp, 4
loop s
}
return 0;
}
结果就是无限循环输出message1的内容。而替换成其他运算循环的结果是正确的。
我忽略了什么问题?
谢谢各位
老师也只给了一个还有很大完善空间的文档。
在vs2017下
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
char message1[] = "Select total number of positive integers (between 2-5): ";
char message2[] = "\bEnter positive integer ";
char message3[] = ": ";
char message4[] = "\nProgram terminates and has looped ";
char message5[] = " times.";
char message6[] = "Your integers from lowest to highest is ";
char message7[] = "The total amount is ";
char message8[] = ".";
char format[] = "%d"; // format string for the scanf function
int n;
int num0;
int num1;
int num2;
int num3;
int num4;
int num5;
_asm {
lea eax, message1
push eax
call printf ;print 1st message
add esp,4
lea eax, n
push eax
lea eax, format
push eax
call scanf_s ;reading total number
add esp, 8
mov ecx, n
push ecx
lea ecx, format
push ecx
add esp,8
mov ecx,n
;=======以下内容出现问题================
s:
lea eax, message1
push eax
call printf; print 1st message
add esp, 4
loop s
}
return 0;
}
结果就是无限循环输出message1的内容。而替换成其他运算循环的结果是正确的。
我忽略了什么问题?
谢谢各位