diff --git a/examples/benchmarks.results.text b/examples/benchmarks.results.text index 23da7c0..5c67cd9 100644 --- a/examples/benchmarks.results.text +++ b/examples/benchmarks.results.text @@ -68,27 +68,5 @@ Running benchmarks.prog exp() 10K 00:00:32 cos() 10K 00:00:06 - -Arty-A7-35T -76.92MHz, 64KB SRAM, 256MB DRAM, 16B instruction cache -running in DRAM (except corelib, stdlib, runtime) - Running benchmarks.prog - empty loop 10M 00:00:16 - write variable 10M 00:00:17 - read variable 10M 00:00:19 - integer addition 10M 00:00:24 - real addition 1M 00:00:30 - integer multiplication 1M 00:01:14 - real multiplication 1M 00:01:05 - integer division 1M 00:01:53 - real division 1M 00:01:13 - string indexing 1M 00:00:41 - string iteration 1M 00:00:21 - new/dispose 1k 1M 00:00:25 - new/dispose 128k 1M 00:00:26 - array copy 1k 10K 00:00:03 - array copy 128k 1K 00:00:48 - exp() 10K 00:00:32 - cos() 10K 00:00:06 diff --git a/pcomp/emit.pas b/pcomp/emit.pas index a201714..2ede4f0 100644 --- a/pcomp/emit.pas +++ b/pcomp/emit.pas @@ -111,7 +111,7 @@ begin emitIns2('BRANCH','@+2'); (* NOP, to make alignment explicit *) emitIns('.CPOOL'); (* header/prologue + 2 constants is 32 bytes *) - if useStdlib and not useStandalone then + if useStdlib then begin writeln(outfile, '%include "stdlib.lsym"'); writeln(outfile, '%incbin "stdlib.lib"'); @@ -312,12 +312,7 @@ begin emitArrayConsts; if useStandalone then - begin - emitInclude('corelib.s'); - emitInclude('runtime.s'); - emitInclude('float32.s'); - emitInclude('stdlib.s'); - end + emitInclude('corelib.s') else emitInclude('coreloader.lsym'); @@ -1064,7 +1059,6 @@ end; *) procedure emitProcedureCall(aProc: ProcRef); var procLabel: IdentString; - i:integer; begin (* pass pointer to stackframe of caller for nested procedures *) if aProc^.isNested then @@ -1075,17 +1069,9 @@ begin if aProc^.level > curProcedure^.level then emitIns2('LOADREG','FP') else - begin - (* Calling nested aProc with a lower nesting level. - Need to chase a chain of old BP pointers. *) - emitIns2('LOADREG', 'BP'); - (* BP points to the stackframe of the outer procedure, - @BP contains the stackframe of the procedure one step further - outwards, and so on. - *) - for i := aProc^.level + 1 to curProcedure^.level do - emitIns('LOADI'); - end; + (* TODO: calling nested aProc with a lower nesting level. + need to chase a chain of old BP pointers. *) + errorExit2('internal error: outward call of nested aProc not implemented', ''); end; emitFpAdjust(-curProcedure^.tempsSize); @@ -1264,7 +1250,7 @@ begin (* nothing to do *) end else - if (amount > 0) and (amount <= MaxTinyOffset) then + if amount <= MaxTinyOffset then emitIns2Int('INC', amount) else begin @@ -1280,7 +1266,7 @@ begin (* nothing to do *) end else - if (amount > 0) and (amount <= MaxTinyOffset) then + if amount <= MaxTinyOffset then emitIns2Int('DEC', amount) else begin diff --git a/pcomp/pcomp.pas b/pcomp/pcomp.pas index d7be8a5..0eca89d 100644 --- a/pcomp/pcomp.pas +++ b/pcomp/pcomp.pas @@ -2186,7 +2186,7 @@ begin if ch = '!' then (* special comment till end of line *) begin - while not (nextChar in [#13, #10]) do (* nothing *); + while not (nextChar = #13) do (* nothing *); readNextToken; end else @@ -2456,7 +2456,10 @@ begin begin digits := curToken.tokenText; if matchTokenOrNot(MinusToken) then + begin + readNextToken; digits := digits + curToken.tokenText; + end; parseInteger := integerFromString(digits); end; readNextToken; @@ -2809,8 +2812,6 @@ begin if checkToken(CommaToken) then begin - (* TODO: handle comma syntax for indexing a char - from an array of strings *) if elType.baseType <> ArrayType then errorExit2('invalid array subscript for', name) end; @@ -3230,22 +3231,10 @@ begin readNextToken; end; -(* Handle an array range part. Very similar to parseInteger - but additionally handles Boolean, Enum and Char types which - can be used for array indices *) procedure getRangePart(var value:integer; var typeReturn: TypeSpec); var cnst: ConstRef; - negate:boolean; - digits: string[12]; begin setBaseType(typeReturn, NoType); - negate := false; - - if checkToken(MinusToken) then - begin - negate := true; - readNextToken; - end; if checkToken(IdentToken) then begin @@ -3279,11 +3268,7 @@ begin else begin setBaseType(typeReturn, IntegerType); - digits := curToken.tokenText; - if negate then - insert('-', digits, 1); - value := integerFromString(digits); - readNextToken; + value := parseInteger; end; end; @@ -3448,9 +3433,9 @@ begin if savedType.baseType = NoType then savedType := elementType; emitLoadConstantInt(cnst^.intValue); - readNextToken; end; emitAddToSet; + readNextToken; end else if checkToken(NumberToken) then begin @@ -4014,8 +3999,6 @@ begin begin readNextToken; length := parseInteger; - if length < 1 then - errorExit2('invalid string length', ''); matchToken(RBracketToken); end; typSpec.size := getStringMemSize(length);