This is a CON module of EuroTool program EuroCalc for Windows.
EUROASM CPU=X64,SIMD=yes,Unicode=no
calcwinc PROGRAM Format=COFF,Width=64
%DROPMACRO *
INCLUDE1 winabi.htm,cpuext.htm,wins.htm,winscon.htm, status32.htm, string64.htm ;;;;;;;;;;;;;;cpuext64.htm,
INCLUDE1 winf64.htm, stdcal64.htm
INCLUDEHEAD argument.htm
LINK ../objlib/winapi.lib
[.text]
[.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:
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
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
ENDPROGRAM calcwinc