EuroTool Index Manual Download Source Macros


Sitemap Links Forum Tests Projects

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


         EUROASM CPU=X64, Unicode=no
         %DROPMACRO *
calclinc PROGRAM Format=COFF, Width=64
         INCLUDEHEAD1 argument.htm
         INCLUDE1 linabi.htm
[.text]
MainCon
The MainCon procedure is executed both in console and in graphic mode.
MainCon:: PROC
    LEA RDI,[InpBuffer::]
    GetArgCount Frame=RSP
    MOV [ArgCount::],RCX
    MOV EDX,1                          ; Start with %1.
.30:CMP RDX,[ArgCount::]
    JA .40:
    GetArg RDX,Frame=RSP
    JC .40:
    MOV AL,' '
    STOSB
    REP MOVSB
    INC EDX
    JMP .30:
.40:SUB EAX,EAX
    STOSB
    LEA RSI,[InpBuffer::]
    CMPB [RSI],0
    JNE .50:
    LEA RAX,[MainGui::]
    JMP RAX                            ; Go to  GUI module.
.50: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:
    MOV RCX,RSI
    LEA RSI,[InpBuffer::]
    SUB RCX,RSI
    StdOutput =B"Syntax error at ",
    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, Handle=2
    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:CALL DisplayDecimalProxy::
    LEA RSI,[OutBuffer::]
    StdOutput RSI,Eol=yes
.90:TerminateProgram
   ENDP MainCon
  ENDPROGRAM calclinc

▲Back to the top▲