0

I have written a assembly program that is supposed to get some values from the user and then do some sums. However the visual studio 2017 I am using does not recognize the_getchar method

I have researched many different ways of accepting input but this seems to be the best. the system simply wont accept the _getchar methods

.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

and this is my code i am using to initiate the assembly

#include <iostream>

extern "C" int multi();

void main()
{
    printf("%d%",multi());
    std:getchar();
}

I simply want to get the program to accept input from the user. I will do validation at a latter stage. Is there any reason why it isn't accepting the _getchar?

error code is this My error. Image was the easiest way to show

Ruud Helderman
  • 10,563
  • 1
  • 26
  • 45

0 Answers0