мелкие правки

This commit is contained in:
AntKrotov committed 2019-10-04 18:18:10 +03:00
1 parent 173b3ec380
commit d0e1665120
53 files changed
+395 -203

No files matched your search

BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
BSD 2-Clause License
Copyright (c) 2018, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
Redistribution and use in source and binary forms, with or without
+2
View File
@@ -0,0 +1,2 @@
for %%f in (samples\MSP430\*.ob07) do Compiler.exe %%f msp430
@pause
+2
View File
@@ -0,0 +1,2 @@
for %%f in (samples\Windows\Console\*.ob07) do Compiler.exe %%f console64
@pause
+1 -1
View File
@@ -1,2 +1,2 @@
Compiler.exe source\Compiler.ob07 kos -out source\Compiler.kex -stk 2
Compiler.exe source\Compiler.ob07 kos -out source\Compiler.kex -stk 2
@pause
+1 -1
View File
@@ -1,2 +1,2 @@
Compiler.exe source\Compiler.ob07 elfexe -out source\Compiler32 -stk 2
Compiler.exe source\Compiler.ob07 elfexe -out source\Compiler32 -stk 2
@pause
+2
View File
@@ -0,0 +1,2 @@
Compiler.exe source\Compiler.ob07 elfexe64 -out source\Compiler -stk 2
@pause
+2 -2
View File
@@ -1,2 +1,2 @@
Compiler.exe source\Compiler.ob07 console -out source\Compiler32.exe -stk 2
@pause
Compiler.exe source\Compiler.ob07 console -out source\Compiler32.exe -stk 2
@pause
+2 -2
View File
@@ -1,2 +1,2 @@
Compiler.exe source\Compiler.ob07 console64 -out source\Compiler.exe -stk 2
@pause
Compiler.exe source\Compiler.ob07 console64 -out source\Compiler.exe -stk 2
@pause
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
@@ -1,64 +1,64 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
All rights reserved.
*)
MODULE UNIXTIME;
VAR
days: ARRAY 12, 31, 2 OF INTEGER;
PROCEDURE init;
VAR
i, j, k, n0, n1: INTEGER;
BEGIN
FOR i := 0 TO 11 DO
FOR j := 0 TO 30 DO
days[i, j, 0] := 0;
days[i, j, 1] := 0;
END
END;
days[ 1, 28, 0] := -1;
FOR k := 0 TO 1 DO
days[ 1, 29, k] := -1;
days[ 1, 30, k] := -1;
days[ 3, 30, k] := -1;
days[ 5, 30, k] := -1;
days[ 8, 30, k] := -1;
days[10, 30, k] := -1;
END;
n0 := 0;
n1 := 0;
FOR i := 0 TO 11 DO
FOR j := 0 TO 30 DO
IF days[i, j, 0] = 0 THEN
days[i, j, 0] := n0;
INC(n0)
END;
IF days[i, j, 1] = 0 THEN
days[i, j, 1] := n1;
INC(n1)
END
END
END
END init;
PROCEDURE time* (year, month, day, hour, min, sec: INTEGER): INTEGER;
RETURN ((year - 1970) * 365 + days[month - 1, day - 1, ORD(year DIV 4 = 0)] + (year - 1969) DIV 4) * 86400 + hour * 3600 + min * 60 + sec
END time;
BEGIN
init
END UNIXTIME.
(*
BSD 2-Clause License
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
MODULE UnixTime;
VAR
days: ARRAY 12, 31, 2 OF INTEGER;
PROCEDURE init;
VAR
i, j, k, n0, n1: INTEGER;
BEGIN
FOR i := 0 TO 11 DO
FOR j := 0 TO 30 DO
days[i, j, 0] := 0;
days[i, j, 1] := 0;
END
END;
days[ 1, 28, 0] := -1;
FOR k := 0 TO 1 DO
days[ 1, 29, k] := -1;
days[ 1, 30, k] := -1;
days[ 3, 30, k] := -1;
days[ 5, 30, k] := -1;
days[ 8, 30, k] := -1;
days[10, 30, k] := -1;
END;
n0 := 0;
n1 := 0;
FOR i := 0 TO 11 DO
FOR j := 0 TO 30 DO
IF days[i, j, 0] = 0 THEN
days[i, j, 0] := n0;
INC(n0)
END;
IF days[i, j, 1] = 0 THEN
days[i, j, 1] := n1;
INC(n1)
END
END
END
END init;
PROCEDURE time* (year, month, day, hour, min, sec: INTEGER): INTEGER;
RETURN ((year - 1970) * 365 + days[month - 1, day - 1, ORD(year DIV 4 = 0)] + (year - 1969) DIV 4) * 86400 + hour * 3600 + min * 60 + sec
END time;
BEGIN
init
END UnixTime.
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+64
View File
@@ -0,0 +1,64 @@
(*
BSD 2-Clause License
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
MODULE UnixTime;
VAR
days: ARRAY 12, 31, 2 OF INTEGER;
PROCEDURE init;
VAR
i, j, k, n0, n1: INTEGER;
BEGIN
FOR i := 0 TO 11 DO
FOR j := 0 TO 30 DO
days[i, j, 0] := 0;
days[i, j, 1] := 0;
END
END;
days[ 1, 28, 0] := -1;
FOR k := 0 TO 1 DO
days[ 1, 29, k] := -1;
days[ 1, 30, k] := -1;
days[ 3, 30, k] := -1;
days[ 5, 30, k] := -1;
days[ 8, 30, k] := -1;
days[10, 30, k] := -1;
END;
n0 := 0;
n1 := 0;
FOR i := 0 TO 11 DO
FOR j := 0 TO 30 DO
IF days[i, j, 0] = 0 THEN
days[i, j, 0] := n0;
INC(n0)
END;
IF days[i, j, 1] = 0 THEN
days[i, j, 1] := n1;
INC(n1)
END
END
END
END init;
PROCEDURE time* (year, month, day, hour, min, sec: INTEGER): INTEGER;
RETURN ((year - 1970) * 365 + days[month - 1, day - 1, ORD(year DIV 4 = 0)] + (year - 1969) DIV 4) * 86400 + hour * 3600 + min * 60 + sec
END time;
BEGIN
init
END UnixTime.
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+64
View File
@@ -0,0 +1,64 @@
(*
BSD 2-Clause License
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
MODULE UnixTime;
VAR
days: ARRAY 12, 31, 2 OF INTEGER;
PROCEDURE init;
VAR
i, j, k, n0, n1: INTEGER;
BEGIN
FOR i := 0 TO 11 DO
FOR j := 0 TO 30 DO
days[i, j, 0] := 0;
days[i, j, 1] := 0;
END
END;
days[ 1, 28, 0] := -1;
FOR k := 0 TO 1 DO
days[ 1, 29, k] := -1;
days[ 1, 30, k] := -1;
days[ 3, 30, k] := -1;
days[ 5, 30, k] := -1;
days[ 8, 30, k] := -1;
days[10, 30, k] := -1;
END;
n0 := 0;
n1 := 0;
FOR i := 0 TO 11 DO
FOR j := 0 TO 30 DO
IF days[i, j, 0] = 0 THEN
days[i, j, 0] := n0;
INC(n0)
END;
IF days[i, j, 1] = 0 THEN
days[i, j, 1] := n1;
INC(n1)
END
END
END
END init;
PROCEDURE time* (year, month, day, hour, min, sec: INTEGER): INTEGER;
RETURN ((year - 1970) * 365 + days[month - 1, day - 1, ORD(year DIV 4 = 0)] + (year - 1969) DIV 4) * 86400 + hour * 3600 + min * 60 + sec
END time;
BEGIN
init
END UnixTime.
-2
View File
@@ -1,2 +0,0 @@
Compiler.exe source\Compiler.ob07 elfexe64 -stk 2
@pause
+17 -17
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
@@ -2574,12 +2574,12 @@ BEGIN
END translate;
PROCEDURE prolog (code: IL.CODES; modname: ARRAY OF CHAR; target, stack_size: INTEGER);
PROCEDURE prolog (modname: ARRAY OF CHAR; target, stack_size: INTEGER);
VAR
ModName_Offs, entry, L: INTEGER;
BEGIN
ModName_Offs := tcount * 8 + CHL.Length(code.data);
ModName_Offs := tcount * 8 + CHL.Length(IL.codes.data);
Numbers_Offs := ModName_Offs + LENGTH(modname) + 1;
ASSERT(UTILS.Align(Numbers_Offs, 16));
@@ -2626,7 +2626,7 @@ BEGIN
END prolog;
PROCEDURE epilog (code: IL.CODES; modname: ARRAY OF CHAR; target: INTEGER);
PROCEDURE epilog (modname: ARRAY OF CHAR; target: INTEGER);
VAR
i, n: INTEGER;
number: Number;
@@ -2673,13 +2673,13 @@ BEGIN
i := 0;
WHILE i < tcount DO
BIN.PutData64LE(prog, CHL.GetInt(code.types, i));
BIN.PutData64LE(prog, CHL.GetInt(IL.codes.types, i));
INC(i)
END;
i := 0;
WHILE i < CHL.Length(code.data) DO
BIN.PutData(prog, CHL.GetByte(code.data, i));
WHILE i < CHL.Length(IL.codes.data) DO
BIN.PutData(prog, CHL.GetByte(IL.codes.data, i));
INC(i)
END;
@@ -2698,13 +2698,13 @@ BEGIN
number := number.next(Number)
END;
exp := code.export.first(IL.EXPORT_PROC);
exp := IL.codes.export.first(IL.EXPORT_PROC);
WHILE exp # NIL DO
BIN.Export(prog, exp.name, exp.label);
exp := exp.next(IL.EXPORT_PROC)
END;
import(code.import)
import(IL.codes.import)
END epilog;
@@ -2732,12 +2732,12 @@ BEGIN
END rsave;
PROCEDURE CodeGen* (code: IL.CODES; outname: ARRAY OF CHAR; target: INTEGER; options: PROG.OPTIONS);
PROCEDURE CodeGen* (outname: ARRAY OF CHAR; target: INTEGER; options: PROG.OPTIONS);
VAR
path, modname, ext: PATHS.PATH;
BEGIN
tcount := CHL.Length(code.types);
tcount := CHL.Length(IL.codes.types);
Win64RegPar[0] := rcx;
Win64RegPar[1] := rdx;
@@ -2756,7 +2756,7 @@ BEGIN
REG.Init(R, push, pop, mov, xchg, rload, rsave, {rax, r10, r11}, {rcx, rdx, r8, r9});
code.bss := MAX(code.bss, MAX(code.dmin - CHL.Length(code.data), 8));
IL.set_bss(MAX(IL.codes.bss, MAX(IL.codes.dmin - CHL.Length(IL.codes.data), 8)));
Numbers := LISTS.create(NIL);
Numbers_Count := 0;
@@ -2768,14 +2768,14 @@ BEGIN
NewNumber(ORD(-BITS(LSR(ASR(ROR(1, 1), 10), 1)))); (* {0..51, 63} *)
NewNumber(LSR(ASR(ROR(1, 1), 9), 2)); (* {52..61} *)
prog := BIN.create(code.lcount);
BIN.SetParams(prog, code.bss, 1, WCHR(1), WCHR(0));
prog := BIN.create(IL.codes.lcount);
BIN.SetParams(prog, IL.codes.bss, 1, WCHR(1), WCHR(0));
X86.SetProgram(prog);
prolog(code, modname, target, options.stack);
translate(code.commands, tcount * 8);
epilog(code, modname, target);
prolog(modname, target, options.stack);
translate(IL.codes.commands, tcount * 8);
epilog(modname, target);
BIN.fixup(prog);
IF target IN {mConst.Target_iConsole64, mConst.Target_iGUI64, mConst.Target_iDLL64} THEN
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+39 -34
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
@@ -171,7 +171,7 @@ TYPE
END;
CODES* = POINTER TO RECORD
CODES = RECORD
last: COMMAND;
begcall: CMDSTACK;
@@ -204,6 +204,24 @@ VAR
commands, variables: C.COLLECTION;
PROCEDURE set_dmin* (value: INTEGER);
BEGIN
codes.dmin := value
END set_dmin;
PROCEDURE set_bss* (value: INTEGER);
BEGIN
codes.bss := value
END set_bss;
PROCEDURE set_rtl* (idx, label: INTEGER);
BEGIN
codes.rtl[idx] := label
END set_rtl;
PROCEDURE NewCmd (): COMMAND;
VAR
cmd: COMMAND;
@@ -253,7 +271,7 @@ PROCEDURE getlast* (): COMMAND;
END getlast;
PROCEDURE PutByte (codes: CODES; b: BYTE);
PROCEDURE PutByte (b: BYTE);
BEGIN
CHL.PushByte(codes.data, b)
END PutByte;
@@ -268,11 +286,11 @@ BEGIN
i := 0;
n := LENGTH(s);
WHILE i < n DO
PutByte(codes, ORD(s[i]));
PutByte(ORD(s[i]));
INC(i)
END;
PutByte(codes, 0)
PutByte(0)
RETURN res
END putstr;
@@ -285,8 +303,8 @@ VAR
BEGIN
IF codes.charoffs[c] = -1 THEN
res := CHL.Length(codes.data);
PutByte(codes, c);
PutByte(codes, 0);
PutByte(c);
PutByte(0);
codes.charoffs[c] := res
ELSE
res := codes.charoffs[c]
@@ -304,7 +322,7 @@ BEGIN
res := CHL.Length(codes.data);
IF ODD(res) THEN
PutByte(codes, 0);
PutByte(0);
INC(res)
END;
@@ -313,17 +331,17 @@ BEGIN
i := 0;
WHILE i < n DO
IF endianness = little_endian THEN
PutByte(codes, ORD(codes.wstr[i]) MOD 256);
PutByte(codes, ORD(codes.wstr[i]) DIV 256)
PutByte(ORD(codes.wstr[i]) MOD 256);
PutByte(ORD(codes.wstr[i]) DIV 256)
ELSIF endianness = big_endian THEN
PutByte(codes, ORD(codes.wstr[i]) DIV 256);
PutByte(codes, ORD(codes.wstr[i]) MOD 256)
PutByte(ORD(codes.wstr[i]) DIV 256);
PutByte(ORD(codes.wstr[i]) MOD 256)
END;
INC(i)
END;
PutByte(codes, 0);
PutByte(codes, 0)
PutByte(0);
PutByte(0)
RETURN res
END putstrW;
@@ -338,20 +356,20 @@ BEGIN
res := CHL.Length(codes.data);
IF ODD(res) THEN
PutByte(codes, 0);
PutByte(0);
INC(res)
END;
IF endianness = little_endian THEN
PutByte(codes, c MOD 256);
PutByte(codes, c DIV 256)
PutByte(c MOD 256);
PutByte(c DIV 256)
ELSIF endianness = big_endian THEN
PutByte(codes, c DIV 256);
PutByte(codes, c MOD 256)
PutByte(c DIV 256);
PutByte(c MOD 256)
END;
PutByte(codes, 0);
PutByte(codes, 0);
PutByte(0);
PutByte(0);
codes.wcharoffs[c] := res
ELSE
@@ -931,18 +949,6 @@ BEGIN
END flt;
PROCEDURE odd*;
BEGIN
AddCmd0(opODD)
END odd;
PROCEDURE ord*;
BEGIN
AddCmd0(opORD)
END ord;
PROCEDURE shift_minmax* (op: CHAR);
BEGIN
CASE op OF
@@ -1143,7 +1149,6 @@ BEGIN
numRegsFloat := pNumRegsFloat;
endianness := pEndianness;
NEW(codes);
NEW(codes.begcall);
codes.begcall.top := -1;
NEW(codes.endcall);
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+13 -13
View File
@@ -582,7 +582,7 @@ BEGIN
END Neg;
PROCEDURE translate (code: IL.CODES);
PROCEDURE translate;
VAR
cmd, next: COMMAND;
@@ -593,7 +593,7 @@ VAR
cc: INTEGER;
BEGIN
cmd := code.commands.first(COMMAND);
cmd := IL.codes.commands.first(COMMAND);
WHILE cmd # NIL DO
@@ -1643,7 +1643,7 @@ BEGIN
END WriteHex;
PROCEDURE CodeGen* (code: IL.CODES; outname: ARRAY OF CHAR; target: INTEGER; options: PROG.OPTIONS);
PROCEDURE CodeGen* (outname: ARRAY OF CHAR; target: INTEGER; options: PROG.OPTIONS);
VAR
i, adr, heap, stack, TextSize, TypesSize, bits, n: INTEGER;
@@ -1668,12 +1668,12 @@ BEGIN
ram := MIN(MAX(ram, minRAM), maxRAM);
rom := MIN(MAX(rom, minROM), maxROM);
IF code.bss > ram - minStackSize - RTL.VarSize THEN
IF IL.codes.bss > ram - minStackSize - RTL.VarSize THEN
ERRORS.Error(204)
END;
Labels := CHL.CreateIntList();
FOR i := 1 TO code.lcount DO
FOR i := 1 TO IL.codes.lcount DO
CHL.PushInt(Labels, 0)
END;
@@ -1681,28 +1681,28 @@ BEGIN
mem[i] := 0
END;
TypesSize := CHL.Length(code.types) * 2;
TypesSize := CHL.Length(IL.codes.types) * 2;
CodeList := LISTS.create(NIL);
RelList := LISTS.create(NIL);
REG.Init(R, Push, Pop, mov, xchg, NIL, NIL, {R4, R5, R6, R7}, {});
prolog(ram);
translate(code);
translate;
epilog;
Code.address := 10000H - rom;
Code.size := Fixup(Code.address, IntVectorSize + TypesSize);
Data.address := Code.address + Code.size;
Data.size := CHL.Length(code.data);
Data.size := CHL.Length(IL.codes.data);
Data.size := Data.size + ORD(ODD(Data.size));
TextSize := Code.size + Data.size;
IF Code.address + TextSize + MAX(code.dmin - Data.size, IntVectorSize + TypesSize) > 10000H THEN
IF Code.address + TextSize + MAX(IL.codes.dmin - Data.size, IntVectorSize + TypesSize) > 10000H THEN
ERRORS.Error(203)
END;
Bss.address := RTL.ram + RTL.VarSize;
Bss.size := code.bss + ORD(ODD(code.bss));
Bss.size := IL.codes.bss + ORD(ODD(IL.codes.bss));
heap := Bss.address + Bss.size;
stack := RTL.ram + ram;
ASSERT(stack - heap >= minStackSize);
@@ -1724,15 +1724,15 @@ BEGIN
adr := Data.address;
FOR i := 0 TO CHL.Length(code.data) - 1 DO
mem[adr] := CHL.GetByte(code.data, i);
FOR i := 0 TO CHL.Length(IL.codes.data) - 1 DO
mem[adr] := CHL.GetByte(IL.codes.data, i);
INC(adr)
END;
adr := 10000H - IntVectorSize - TypesSize;
FOR i := TypesSize DIV 2 - 1 TO 0 BY -1 DO
PutWord(CHL.GetInt(code.types, i), adr)
PutWord(CHL.GetInt(IL.codes.types, i), adr)
END;
FOR i := 0 TO 15 DO
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+10 -10
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
@@ -613,7 +613,7 @@ BEGIN
stroffs := StringW(e);
IL.StrAdr(stroffs)
END;
IL.codes.dmin := stroffs + p.type.size;
IL.set_dmin(stroffs + p.type.size);
IL.Param1
ELSE
LoadConst(e);
@@ -1113,7 +1113,7 @@ BEGIN
IF e.obj = eCONST THEN
ARITH.odd(e.value)
ELSE
IL.odd
IL.AddCmd0(IL.opODD)
END
|PROG.stORD:
@@ -1127,7 +1127,7 @@ BEGIN
END
ELSE
IF isBoolean(e) THEN
IL.ord
IL.AddCmd0(IL.opORD)
END
END;
e.type := tINTEGER
@@ -3228,10 +3228,10 @@ VAR
id := PROG.getIdent(rtl, SCAN.enterid(name), FALSE);
IF (id # NIL) & (id.import # NIL) THEN
IL.codes.rtl[idx] := -id.import(IL.IMPORT_PROC).label;
IL.set_rtl(idx, -id.import(IL.IMPORT_PROC).label);
id.proc.used := TRUE
ELSIF (id # NIL) & (id.proc # NIL) THEN
IL.codes.rtl[idx] := id.proc.label;
IL.set_rtl(idx, id.proc.label);
id.proc.used := TRUE
ELSE
ERRORS.WrongRTL(name)
@@ -3349,12 +3349,12 @@ BEGIN
PROG.DelUnused(PARS.program, IL.DelImport);
IL.codes.bss := PARS.program.bss;
IL.set_bss(PARS.program.bss);
CASE CPU OF
| cpuAMD64: AMD64.CodeGen(IL.codes, outname, target, options)
| cpuX86: X86.CodeGen(IL.codes, outname, target, options)
|cpuMSP430: MSP430.CodeGen(IL.codes, outname, target, options)
| cpuAMD64: AMD64.CodeGen(outname, target, options)
| cpuX86: X86.CodeGen(outname, target, options)
|cpuMSP430: MSP430.CodeGen(outname, target, options)
END
END compile;
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+59 -4
View File
@@ -1,13 +1,13 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
MODULE UTILS;
IMPORT HOST, UNIXTIME;
IMPORT HOST;
CONST
@@ -24,6 +24,11 @@ CONST
max32* = 2147483647;
TYPE
DAYS = ARRAY 12, 31, 2 OF INTEGER;
VAR
time*: INTEGER;
@@ -48,6 +53,8 @@ VAR
bit_diff*: INTEGER;
days: DAYS;
PROCEDURE FileRead* (F: INTEGER; VAR Buffer: ARRAY OF BYTE; bytes: INTEGER): INTEGER;
RETURN HOST.FileRead(F, Buffer, bytes)
@@ -114,6 +121,11 @@ BEGIN
END GetCurrentDirectory;
PROCEDURE GetUnixTime* (year, month, day, hour, min, sec: INTEGER): INTEGER;
RETURN ((year - 1970) * 365 + days[month - 1, day - 1, ORD(year DIV 4 = 0)] + (year - 1969) DIV 4) * 86400 + hour * 3600 + min * 60 + sec
END GetUnixTime;
PROCEDURE UnixTime* (): INTEGER;
VAR
year, month, day, hour, min, sec: INTEGER;
@@ -124,7 +136,7 @@ BEGIN
res := HOST.UnixTime()
ELSE
HOST.now(year, month, day, hour, min, sec);
res := UNIXTIME.time(year, month, day, hour, min, sec)
res := GetUnixTime(year, month, day, hour, min, sec)
END
RETURN res
@@ -201,9 +213,52 @@ BEGIN
END Log2;
PROCEDURE init (VAR days: DAYS);
VAR
i, j, n0, n1: INTEGER;
BEGIN
FOR i := 0 TO 11 DO
FOR j := 0 TO 30 DO
days[i, j, 0] := 0;
days[i, j, 1] := 0;
END
END;
days[ 1, 28, 0] := -1;
FOR i := 0 TO 1 DO
days[ 1, 29, i] := -1;
days[ 1, 30, i] := -1;
days[ 3, 30, i] := -1;
days[ 5, 30, i] := -1;
days[ 8, 30, i] := -1;
days[10, 30, i] := -1;
END;
n0 := 0;
n1 := 0;
FOR i := 0 TO 11 DO
FOR j := 0 TO 30 DO
IF days[i, j, 0] = 0 THEN
days[i, j, 0] := n0;
INC(n0)
END;
IF days[i, j, 1] = 0 THEN
days[i, j, 1] := n1;
INC(n1)
END
END
END
END init;
BEGIN
time := GetTickCount();
COPY(HOST.eol, eol);
maxreal := 1.9;
PACK(maxreal, 1023)
PACK(maxreal, 1023);
init(days)
END UTILS.
+1 -1
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
+19 -19
View File
@@ -1,7 +1,7 @@
(*
BSD 2-Clause License
Copyright (c) 2018, 2019, Anton Krotov
Copyright (c) 2018-2019, Anton Krotov
All rights reserved.
*)
@@ -573,7 +573,7 @@ BEGIN
END GetRegA;
PROCEDURE translate (code: IL.CODES; pic: BOOLEAN; stroffs: INTEGER);
PROCEDURE translate (pic: BOOLEAN; stroffs: INTEGER);
VAR
cmd: COMMAND;
@@ -586,7 +586,7 @@ VAR
float: REAL;
BEGIN
cmd := code.commands.first(COMMAND);
cmd := IL.codes.commands.first(COMMAND);
WHILE cmd # NIL DO
@@ -2087,7 +2087,7 @@ BEGIN
END translate;
PROCEDURE prolog (code: IL.CODES; pic: BOOLEAN; target, stack, dllinit, dllret: INTEGER);
PROCEDURE prolog (pic: BOOLEAN; target, stack, dllinit, dllret: INTEGER);
VAR
reg1, entry, L, dcount: INTEGER;
@@ -2143,7 +2143,7 @@ BEGIN
Reloc(BIN.RDATA, 0)
END;
dcount := CHL.Length(code.data);
dcount := CHL.Length(IL.codes.data);
pushc(tcount);
@@ -2176,7 +2176,7 @@ BEGIN
END prolog;
PROCEDURE epilog (code: IL.CODES; pic: BOOLEAN; modname: ARRAY OF CHAR; target, stack, ver, dllinit, dllret, sofinit: INTEGER);
PROCEDURE epilog (pic: BOOLEAN; modname: ARRAY OF CHAR; target, stack, ver, dllinit, dllret, sofinit: INTEGER);
VAR
exp: IL.EXPORT_PROC;
path, name, ext: PATHS.PATH;
@@ -2227,14 +2227,14 @@ BEGIN
fixup;
dcount := CHL.Length(code.data);
dcount := CHL.Length(IL.codes.data);
FOR i := 0 TO tcount - 1 DO
BIN.PutData32LE(program, CHL.GetInt(code.types, i))
BIN.PutData32LE(program, CHL.GetInt(IL.codes.types, i))
END;
FOR i := 0 TO dcount - 1 DO
BIN.PutData(program, CHL.GetByte(code.data, i))
BIN.PutData(program, CHL.GetByte(IL.codes.data, i))
END;
program.modname := CHL.Length(program.data);
@@ -2248,33 +2248,33 @@ BEGIN
BIN.Export(program, "lib_init", dllinit);
END;
exp := code.export.first(IL.EXPORT_PROC);
exp := IL.codes.export.first(IL.EXPORT_PROC);
WHILE exp # NIL DO
BIN.Export(program, exp.name, exp.label);
exp := exp.next(IL.EXPORT_PROC)
END;
import(code.import);
import(IL.codes.import);
code.bss := MAX(code.bss, MAX(code.dmin - CHL.Length(code.data), 4));
IL.set_bss(MAX(IL.codes.bss, MAX(IL.codes.dmin - CHL.Length(IL.codes.data), 4)));
BIN.SetParams(program, code.bss, stack * (1024 * 1024), WCHR(ver DIV 65536), WCHR(ver MOD 65536));
BIN.SetParams(program, IL.codes.bss, stack * (1024 * 1024), WCHR(ver DIV 65536), WCHR(ver MOD 65536));
END epilog;
PROCEDURE CodeGen* (code: IL.CODES; outname: ARRAY OF CHAR; target: INTEGER; options: PROG.OPTIONS);
PROCEDURE CodeGen* (outname: ARRAY OF CHAR; target: INTEGER; options: PROG.OPTIONS);
VAR
dllret, dllinit, sofinit: INTEGER;
opt: PROG.OPTIONS;
BEGIN
tcount := CHL.Length(code.types);
tcount := CHL.Length(IL.codes.types);
opt := options;
CodeList := LISTS.create(NIL);
program := BIN.create(code.lcount);
program := BIN.create(IL.codes.lcount);
dllinit := NewLabel();
dllret := NewLabel();
@@ -2290,9 +2290,9 @@ BEGIN
REG.Init(R, push, pop, mov, xchg, NIL, NIL, {eax, ecx, edx}, {});
prolog(code, opt.pic, target, opt.stack, dllinit, dllret);
translate(code, opt.pic, tcount * 4);
epilog(code, opt.pic, outname, target, opt.stack, opt.version, dllinit, dllret, sofinit);
prolog(opt.pic, target, opt.stack, dllinit, dllret);
translate(opt.pic, tcount * 4);
epilog(opt.pic, outname, target, opt.stack, opt.version, dllinit, dllret, sofinit);
BIN.fixup(program);