title: How to call an enum in an asm file?
body: <p>I am working on an assignment for class and I have one last part of the assignment before I am done. I am given a C++ file that I am not allowed to edit, and I am writing the .asm for it. My last snag in the project is that:
  1. My _Divide function when given 2 regular values should access the enum, but I do not know how to call to it and not hit _PrintResult by accident. 
  2. When dividing by 0, I can get it to display the "Display of Division by zero" but not the "Attempted division by zero." </p>
  
  <p>Here is the .cpp:
      include </p>
  
  <pre><code>using namespace std;
  
  enum ResultCode { ShowSquare, ShowMultiply, ShowDivide, ShowRemainder,
  ShowDivideFailure };
  enum SuccessCode { Failure, Success };
  
  extern "C" SuccessCode Divide(long, long, long &amp;, long &amp;);
  extern "C" long Multiply(long, long);
  extern "C" void PrintResult(ResultCode, long);
  extern "C" long Square(long);
  
  void main()
  {
  long Num1;
  long Num2;
  long Result;
  long Remainder;
  do
  {
      cout &lt;&lt; "Enter Number to Square" &lt;&lt; endl;
      cin &gt;&gt; Num1;
      Result = Square(Num1);
      cout &lt;&lt; "Square is: " &lt;&lt; Result &lt;&lt; endl;
      cout &lt;&lt; "Enter two numbers to multiply" &lt;&lt; endl;
      cin &gt;&gt; Num1 &gt;&gt; Num2;
      Result = Multiply(Num1, Num2);
      cout &lt;&lt; "Result of multiply is: " &lt;&lt; Result &lt;&lt; endl;
      cout &lt;&lt; "Enter mumber to divide into then number to divide by" &lt;&lt; endl;
      cin &gt;&gt; Num1 &gt;&gt; Num2;
      if (Divide(Num1, Num2, Result, Remainder) == Success)
          cout &lt;&lt; "Result is " &lt;&lt; Result &lt;&lt; " and remainder is " &lt;&lt; Remainder 
  &lt;&lt; endl;
      else
          cout &lt;&lt; "Attempted division by zero, ";
  } while (Result &gt; 0);
  }
  
  void PrintResult(ResultCode PrintCode, long Value)
  {
  switch (PrintCode)
  {
  case ShowSquare:
      cout &lt;&lt; "Display of square is: " &lt;&lt; Value &lt;&lt; endl;
      break;
  case ShowMultiply:
      cout &lt;&lt; "Display of multiply is: " &lt;&lt; Value &lt;&lt; endl;
      break;
  case ShowDivide:
      cout &lt;&lt; "Display of divide is " &lt;&lt; Value &lt;&lt; endl;
      break;
  case ShowRemainder:
      cout &lt;&lt; "Display of remainder is " &lt;&lt; Value &lt;&lt; endl;
      break;
  case ShowDivideFailure:
      cout &lt;&lt; "Display of Division by zero" &lt;&lt; endl;
      break;
  default:
      cout &lt;&lt; "Error in assembly routines" &lt;&lt; endl;
  }
  }
  </code></pre>
  
  <p>And here is what I have so far:</p>
  
  <pre><code>.386
  
  .model flat
  
  .code
  
  public    _Square
  public    _Multiply
  public    _Divide
  extern    _PrintResult:proc
  
  
  ShowSquare = 0
  ShowMultiply = 1
  ShowDivideFailure = 4
  
  Failure = 0
  Success = 1
  
  _Square        proc
              mov     eax, [esp + 4]
              imul    eax, eax
          push    eax
  
          push    eax
          push    0
          call    _PrintResult
          add     esp, 8
  
          pop     eax
          ret
  _Square        endp
  
  _Multiply    proc
          mov         eax, [esp + 8]
          mov         ebx, [esp + 4]
          imul        eax, ebx
          push        eax
  
          push        eax
          push        1
          call        _PrintResult
  
          add        esp, 12
          mov        eax, [esp + 8]
          mov        ebx, [esp + 4]
          imul    eax, ebx
  
          ret
  _Multiply    endp
  
  
  _Divide        proc
  
  Start1:
  mov            eax, [esp+4]
  mov            ebx, [esp+8]
  
  cmp            ebx,0
  je            Failure1
  
  cdq
  idiv        ebx
  mov            ebx, edx
  jmp            Success1
  
  Success1:
  
  push        eax
  push        eax
  push        2
  call        _PrintResult
  add            esp, 8
  pop            eax
  
  push        ebx
  push        ebx
  push        3
  call        _PrintResult
  add            esp, 8
  pop            ebx
  
  push        eax
  push        eax
  push        0
  call        _SuccessCode
  
  Failure1:
  
          ret
  _Divide        endp
  
  
  end
  </code></pre>