| Index | Manual | Download | Source | Macros | Embedded word Case ins.
Sitemap | Links | Forum | Tests | Projects

# calcwinc.htm
MainCon

This is a CON module of EuroTool program EuroCalc for Windows.

             EUROASM CPU=X64,SIMD=yes,Unicode=no, Debug=yes
    calcwinc PROGRAM Format=COFF,Width=64
             %DROPMACRO *
             INCLUDE1 winabi.htm,cpuext.htm,wins.htm,winscon.htm, status32.htm, string64.htm, debug.htm
             INCLUDE1 winf64.htm, stdcal64.htm
             INCLUDEHEAD argument.htm
             LINK ../objlib/winapi.lib
    [.text]

MainCon
  The MainCon procedure is executed both in console and in graphic mode.

    [.text]
    MainCon:: PROC
        WinABI GetCommandLineA
        MOV RSI,RAX
        LEA RDI,[InpBuffer::]
        XOR EAX,EAX
    .20:LODSB
        CMP AL,0
        JE .30:
        CMP AL,' '
        JBE .20:
        CMP AL,'"'
        JE .35:
    .25:LODSB                              ; 0-th argument is not in quotes.
        CMP AL,0
        JE .30:
        CMP AL,' '
        JA .25:
        JMP .40:
    .30:DEC RSI
        JMP .40:
    .35:LODSB                              ; 0-th argument is in quotes.
        CMP AL,0
        JE .30:
        CMP AL,'"'
        JNE .35:
    .40:LODSB                              ; 0-th argument (eurocalc.exe itself) was skipped.
        CMP AL,0
        JE .50:
        CMP AL,' '
        JBE .40:
        STOSB
        JMP .40:
    .50:LEA RSI,[InpBuffer::]
        CMPB [RSI],0
        JE MsgLoopMain::                   ; Go to  GUI module.
        LEA RDI,[Pbuffer::]                ; InpBuffer RSI is a zero-terminated string with the input expression.
        CALL Parse::                       ; Parse the ASCIIZ string at RSI.
        MOV [PbufferEnd::],RDI             ; Store numbers, parenthesis and functions to RDI=Pbuffer.
        JNC .60:
        GetLength$ RSI

    : Debug rsi

        StdOutput =B"Syntax error in math expression ",
        StdOutput RSI,Size=RCX,Eol=yes
        JMP .90:
    .60:LEA RSI,[Pbuffer::]
        MOV RDX,[PbufferEnd::]
        LEA RDI,[InpBuffer::]
        CALL EchoExpression::
        LEA RDI,[InpBuffer::]
        StdOutput RDI
        LEA RSI,[Pbuffer::]
        MOV RDX,[PbufferEnd::]
        LEA RDI,[Nbuffer::]
        CALL Deparent::                    ; Remove N-records for parenthesis.
        MOV [NbufferEnd::],RDI
        JNC .70:
        StdOutput =B"Unbalanced parenthesis.",Eol=yes
        JMP .90:
    .70:CALL Calculate::
        JNC .80:
        StdOutput ="Error in expression or division by 0.",Eol=yes
        JMP .90:
    .80:LEA RBX,[OutBuffer::]
        Invoke DisplayDecimal::,R8,R9,RBX
        LEA RSI,[OutBuffer::]
        StdOutput RSI,Eol=yes
    .90:TerminateProgram
        ENDP MainCon

      %IF %^DEBUG
    DebugOutput PROC
       StdOutput RSI,Size=RCX
       RET
       ENDP DebugOutput
      %ENDIF

      ENDPROGRAM calcwinc

▲Back to the top▲