我编写了一个汇编程序,该程序应该从用户那里获取一些值,然后进行一些求和。但是我使用的Visual Studio 2017无法识别the_getchar方法
我研究了许多接受输入的方法,但这似乎是最好的。系统根本不会接受_getchar方法
.586 ;Enables assembly on non Priiliged intructions for the prntium processor
.model flat ,c ;model=Initialises the program memory mode, flat=Identifies the size of code and data pointers and
;c= identifies the naming and calling coventions
.stack 100h
.data ; This section will contain all of the static variables for our program
foo dd 0 ;Variable to be used to store into meory
.code ; Assembly code will be placed here
multi proc ; Start of the doit process. Like a method in C#. Method is called
;in the visual studio form Source
push esi ; \ preserve
push ebx ; | callee-preserve
push edi ; / registers
call _getchar ; read input; return result in EAX
mov esi, eax ; ESI = EAX
sub esi, 48 ; ESI -= '0'
call _getchar ; read input; return result in EAX
mov ebx, eax ; EBX = EAX
sub ebx, 48 ; EBX -= '0'
call _getchar ; read input; return result in EAX
mov edi, eax ; EDI = EAX
sub edi, 48 ; EDI -= '0'
call _getchar ; read input; return result in EAX
mov edx, eax ; EDX = EAX
sub edx, 48 ; EDX -= '0'
mov ecx, edi ; ECX = EDI
mov eax, esi ; EAX = ESI
add eax, ebx ; EAX += EBX
add eax, edx ; EAX += EDX
sub eax, ecx ; EAX -= ECX
mul ebx ; EDX:EAX = EAX * EBX
mov [foo], eax ; *foo = EAX
pop edi ; \ restore
pop ebx ; | callee-preserve
pop esi ; / registers
ret
multi endp ; End of the doit method
end ;End of program
这是我用来启动程序集的代码
#include <iostream>
extern "C" int multi();
void main()
{
printf("%d%",multi());
std:getchar();
}
我只是想让程序接受用户的输入。我将在稍后阶段进行验证。有什么理由不接受_getchar吗?