Compare commits
No commits in common. "fbc72c54388ba9cd53f01ea678361e35c77ae02a" and "ab57b5ce7a518ba5fe2583c04e41109e81f68f7b" have entirely different histories.
fbc72c5438
...
ab57b5ce7a
10 changed files with 31 additions and 126 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -4,7 +4,6 @@ lib/stdlib.s
|
||||||
tests/*.s
|
tests/*.s
|
||||||
examples/*.s
|
examples/*.s
|
||||||
!runtime.s
|
!runtime.s
|
||||||
!stdlibwrap.s
|
|
||||||
*.o
|
*.o
|
||||||
*.exe
|
*.exe
|
||||||
*.bin
|
*.bin
|
||||||
|
|
|
||||||
|
|
@ -1051,16 +1051,3 @@ FLOAT32_ERR_TRUNC:
|
||||||
.BYTE "integer overflow",0
|
.BYTE "integer overflow",0
|
||||||
FLOAT32_ERR_DIVZ:
|
FLOAT32_ERR_DIVZ:
|
||||||
.BYTE "float division by zero",0
|
.BYTE "float division by zero",0
|
||||||
|
|
||||||
%export _ADDFLOAT32
|
|
||||||
%export _CMPFLOAT32
|
|
||||||
%export _CMPINTFLOAT32
|
|
||||||
%export _DIVFLOAT32
|
|
||||||
%export _FRACTFLOAT32
|
|
||||||
%export _GETFLOAT32EXP
|
|
||||||
%export _INTFLOAT32
|
|
||||||
%export _INTTOFLOAT32
|
|
||||||
%export _MULFLOAT32
|
|
||||||
%export _NEGFLOAT32
|
|
||||||
%export _SUBFLOAT32
|
|
||||||
%export _TRUNCFLOAT32
|
|
||||||
|
|
|
||||||
|
|
@ -387,7 +387,7 @@ READCHANW_XT:
|
||||||
|
|
||||||
; --- check if a string is already initialized
|
; --- check if a string is already initialized
|
||||||
; parameters: addr
|
; parameters: addr
|
||||||
; returns: 1 if it is initialized, 0 otherwise
|
; returns: 1 if it is initialied, 0 otherwise
|
||||||
_STRINGISINITED:
|
_STRINGISINITED:
|
||||||
LOADI.S1.X2Y ; load length field, keep addr
|
LOADI.S1.X2Y ; load length field, keep addr
|
||||||
CBRANCH.NZ STRIN_XT1 ; if not zero, it is already inited
|
CBRANCH.NZ STRIN_XT1 ; if not zero, it is already inited
|
||||||
|
|
@ -1616,7 +1616,7 @@ MEM_FREE_XT:
|
||||||
; Since the return stack is no longer valid afterwards, directly
|
; Since the return stack is no longer valid afterwards, directly
|
||||||
; jumps to _MAIN instead of using RET.
|
; jumps to _MAIN instead of using RET.
|
||||||
|
|
||||||
; parameters: [ _MAIN entry point, start of heap address ]
|
; parameters: [ start of heap address ]
|
||||||
_MEM_INIT:
|
_MEM_INIT:
|
||||||
; initialize anchor chunk with start of heap address
|
; initialize anchor chunk with start of heap address
|
||||||
; and heap size - header size
|
; and heap size - header size
|
||||||
|
|
@ -1663,9 +1663,7 @@ _MEM_INIT:
|
||||||
LOADCP _MEM_FREE ; add chunk to free list
|
LOADCP _MEM_FREE ; add chunk to free list
|
||||||
CALL
|
CALL
|
||||||
|
|
||||||
; get address of _MAIN from program header
|
LOADCP _MAIN
|
||||||
LOADCP _MAIN_PTR
|
|
||||||
LOADI
|
|
||||||
JUMP
|
JUMP
|
||||||
|
|
||||||
; allocate a string with MEM_ALLOC.
|
; allocate a string with MEM_ALLOC.
|
||||||
|
|
@ -1939,35 +1937,3 @@ NEWLINESTR:
|
||||||
.BYTE 13,10
|
.BYTE 13,10
|
||||||
|
|
||||||
.CPOOL
|
.CPOOL
|
||||||
|
|
||||||
%export _APPENDSTRING
|
|
||||||
%export _ARRAYTOSET
|
|
||||||
%export _BOUNDSCHECK
|
|
||||||
%export _CHARTOSTRING
|
|
||||||
%export _CHECK_ALLOC
|
|
||||||
%export _CLEARBIT
|
|
||||||
%export _CLEARMEM
|
|
||||||
%export _CMPSTRING
|
|
||||||
%export _CMPSTRINGL
|
|
||||||
%export _CMPWORDS
|
|
||||||
%export _COPYSTRING
|
|
||||||
%export _COPYWORDS
|
|
||||||
%export _ENUMCHECK
|
|
||||||
%export _INDEXSTRING
|
|
||||||
%export _INITSTRING
|
|
||||||
%export _INITSTRINGF
|
|
||||||
%export _INITSTRINGFROM
|
|
||||||
%export _ISCHARINSTRING
|
|
||||||
%export _ISINTINARRAY
|
|
||||||
%export _MEM_ALLOC
|
|
||||||
%export _MEM_INIT
|
|
||||||
%export _MEM_FREE
|
|
||||||
%export _RANGECHECK
|
|
||||||
%export _RUNTIME_ERR
|
|
||||||
%export _SETBIT
|
|
||||||
%export _SETSTRINGCHAR
|
|
||||||
%export _SETSTRINGLENGTH
|
|
||||||
%export _STRINGTOCHAR
|
|
||||||
%export _STRING_ALLOC
|
|
||||||
%export _TESTBIT
|
|
||||||
%export MEM_DUMP
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
|
|
||||||
.ORG 24576 + 32
|
|
||||||
.EQU _HEAP_SZ_PTR 24576 + 4
|
|
||||||
.EQU _STACK_SZ_PTR 24576 + 8
|
|
||||||
.EQU _MAIN_PTR 24576 + 12
|
|
||||||
|
|
||||||
%include "coreloader.lsym"
|
|
||||||
%include "runtime.s"
|
|
||||||
%include "float32.s"
|
|
||||||
%include "stdlib.s"
|
|
||||||
_MAIN:
|
|
||||||
|
|
@ -86,12 +86,6 @@ begin
|
||||||
countIns(1);
|
countIns(1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure emitInclude(s:string);
|
|
||||||
begin
|
|
||||||
writeln(outfile, '%include "',s,'"');
|
|
||||||
emitIns('.CPOOL');
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure emitPrologue;
|
procedure emitPrologue;
|
||||||
begin
|
begin
|
||||||
writeln(outfile, #9, '.ORG ', startAddress);
|
writeln(outfile, #9, '.ORG ', startAddress);
|
||||||
|
|
@ -101,21 +95,12 @@ begin
|
||||||
emitIns2Int('.WORD', defaultHeapSize);
|
emitIns2Int('.WORD', defaultHeapSize);
|
||||||
emitLabelRaw('_STACK_SZ_PTR');
|
emitLabelRaw('_STACK_SZ_PTR');
|
||||||
emitIns2Int('.WORD', defaultStackSize);
|
emitIns2Int('.WORD', defaultStackSize);
|
||||||
emitLabelRaw('_MAIN_PTR');
|
emitIns2Int('.WORD', 0);
|
||||||
emitIns2('.WORD', '_MAIN');
|
|
||||||
emitIns2('LOADCP','_END'); (* end of program is start of heap *)
|
emitIns2('LOADCP','_END'); (* end of program is start of heap *)
|
||||||
emitIns2('LOADCP', '_MEM_INIT'); (* MEM_INIT initializes heap and sets FP/RP *)
|
emitIns2('LOADCP', '_MEM_INIT'); (* MEM_INIT initializes heap and sets FP/RP *)
|
||||||
(* since RP is not initialized yet, we cannot use CALL
|
(* since RP is not initialized yet, we cannot use CALL
|
||||||
and MEM_INIT jumps to _MAIN after it is done *)
|
and MEM_INIT jumps to _MAIN after it is done *)
|
||||||
emitIns('JUMP');
|
emitIns('JUMP');
|
||||||
emitIns2('BRANCH','@+2'); (* NOP, to make alignment explicit *)
|
|
||||||
emitIns('.CPOOL'); (* header/prologue + 2 constants is 32 bytes *)
|
|
||||||
|
|
||||||
if useStdlib then
|
|
||||||
begin
|
|
||||||
writeln(outfile, '%include "stdlib.lsym"');
|
|
||||||
writeln(outfile, '%incbin "stdlib.lib"');
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function bytes2words(size:integer):integer;
|
function bytes2words(size:integer):integer;
|
||||||
|
|
@ -289,6 +274,12 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure emitInclude(s:string);
|
||||||
|
begin
|
||||||
|
writeln(outfile, '%include "',s,'"');
|
||||||
|
emitIns('.CPOOL');
|
||||||
|
end;
|
||||||
|
|
||||||
procedure emitUnitEpilogue;
|
procedure emitUnitEpilogue;
|
||||||
begin
|
begin
|
||||||
emitIns('.CPOOL');
|
emitIns('.CPOOL');
|
||||||
|
|
@ -316,6 +307,10 @@ begin
|
||||||
else
|
else
|
||||||
emitInclude('coreloader.lsym');
|
emitInclude('coreloader.lsym');
|
||||||
|
|
||||||
|
emitInclude('float32.lib');
|
||||||
|
emitInclude('runtime.lib');
|
||||||
|
emitInclude('stdlib.lib');
|
||||||
|
|
||||||
rewindStringList(usedUnits);
|
rewindStringList(usedUnits);
|
||||||
while nextStringListItem(usedUnits, unitName) do
|
while nextStringListItem(usedUnits, unitName) do
|
||||||
emitInclude(unitName + UnitSuffix2);
|
emitInclude(unitName + UnitSuffix2);
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,7 @@ var
|
||||||
outfile:TextFile;
|
outfile:TextFile;
|
||||||
infile:TextFile;
|
infile:TextFile;
|
||||||
lineno:integer;
|
lineno:integer;
|
||||||
infilePath,outfilePath:string;
|
|
||||||
|
|
||||||
procedure errorExit2(reason:string;arg:string); forward;
|
procedure errorExit2(reason:string;arg:string); forward;
|
||||||
|
|
||||||
{$I 'platfile+.pas'}
|
{$I 'platfile+.pas'}
|
||||||
|
|
@ -79,17 +78,6 @@ begin
|
||||||
clean := (not strcontains( name, '_')) and (name[1] <> '=');
|
clean := (not strcontains( name, '_')) and (name[1] <> '=');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure removeLeadingZeroes(var s:string);
|
|
||||||
begin
|
|
||||||
while length(s) > 1 do
|
|
||||||
begin
|
|
||||||
if s[1] = '0' then
|
|
||||||
delete(s,1,1)
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure processFile(inpath,outpath:string);
|
procedure processFile(inpath,outpath:string);
|
||||||
var line:string;
|
var line:string;
|
||||||
addr,name:string;
|
addr,name:string;
|
||||||
|
|
@ -106,8 +94,6 @@ begin
|
||||||
begin
|
begin
|
||||||
readln(infile, line);
|
readln(infile, line);
|
||||||
splitLine(line, addr, name, clean);
|
splitLine(line, addr, name, clean);
|
||||||
removeLeadingZeroes(addr);
|
|
||||||
|
|
||||||
if clean then
|
if clean then
|
||||||
writeln(outfile, #9, '.EQU ', name, ' $', addr);
|
writeln(outfile, #9, '.EQU ', name, ' $', addr);
|
||||||
end;
|
end;
|
||||||
|
|
@ -118,13 +104,7 @@ end;
|
||||||
begin
|
begin
|
||||||
if ParamCount > 0 then
|
if ParamCount > 0 then
|
||||||
begin
|
begin
|
||||||
infilePath := ParamStr(1);
|
processFile(ParamStr(1), getOutfileName(ParamStr(1)));
|
||||||
outfilePath := getOutfileName(infilePath);
|
|
||||||
|
|
||||||
if ParamCount > 1 then
|
|
||||||
outfilePath := ParamStr(2);
|
|
||||||
|
|
||||||
processFile(infilePath, outfilePath);
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
writeln('No file name given.');
|
writeln('No file name given.');
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,9 @@ fpc -gl lsymgen.pas
|
||||||
sasm ..\lib\coreloader.s
|
sasm ..\lib\coreloader.s
|
||||||
lsymgen ..\lib\coreloader.sym
|
lsymgen ..\lib\coreloader.sym
|
||||||
py pcomp.py -n ..\lib\stdlib.pas
|
py pcomp.py -n ..\lib\stdlib.pas
|
||||||
sasm ..\lib\stdlibwrap.s ..\lib\stdlib.lib
|
libgen ..\lib\stdlib.s
|
||||||
lsymgen ..\lib\stdlibwrap.sym ..\lib\stdlib.lsym
|
libgen ..\lib\runtime.s
|
||||||
|
libgen ..\lib\float32.s
|
||||||
rem exit /b
|
|
||||||
|
|
||||||
py pcomp.py sasm.pas
|
py pcomp.py sasm.pas
|
||||||
py pcomp.py pcomp.pas
|
py pcomp.py pcomp.pas
|
||||||
|
|
|
||||||
|
|
@ -372,17 +372,12 @@ procedure printPassNo;
|
||||||
begin
|
begin
|
||||||
write('P', pass, ' ');
|
write('P', pass, ' ');
|
||||||
end;
|
end;
|
||||||
procedure printFilename(var f:string);
|
|
||||||
begin
|
|
||||||
write(#13);
|
|
||||||
printPassNo;
|
|
||||||
write(f);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure printCurrentLineno;
|
procedure printCurrentLineno;
|
||||||
begin
|
begin
|
||||||
printFilename(filename);
|
write(#13);
|
||||||
write(' ', lineno);
|
printPassNo;
|
||||||
|
write(filename, ' ', lineno);
|
||||||
ClrEol;
|
ClrEol;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
@ -2046,23 +2041,17 @@ begin
|
||||||
errorExit2('Unrecognized directive', lastToken.tokenText);
|
errorExit2('Unrecognized directive', lastToken.tokenText);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure readImage(filename:string);
|
procedure readImage(filename:string;size:integer);
|
||||||
var f:InputFileType;
|
var f:InputFileType;
|
||||||
c:char;
|
c:char;
|
||||||
i:integer;
|
i:integer;
|
||||||
size:integer;
|
|
||||||
begin
|
begin
|
||||||
printFilename(filename);
|
|
||||||
ClrEol;
|
|
||||||
|
|
||||||
openFileWithDefault(f, filename);
|
|
||||||
size := filesize(f);
|
|
||||||
|
|
||||||
pc := pc + size;
|
pc := pc + size;
|
||||||
bytesCount := bytesCount + size;
|
bytesCount := bytesCount + size;
|
||||||
|
|
||||||
if pass = 2 then
|
if pass = 2 then
|
||||||
begin
|
begin
|
||||||
|
openFileWithDefault(f, filename);
|
||||||
|
|
||||||
for i := 1 to size do
|
for i := 1 to size do
|
||||||
begin
|
begin
|
||||||
|
|
@ -2070,16 +2059,14 @@ begin
|
||||||
write(outfile,c);
|
write(outfile,c);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
close(f);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
close(f);
|
|
||||||
|
|
||||||
printCurrentLineno;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure parseMetaDirective;
|
procedure parseMetaDirective;
|
||||||
var filename:string;
|
var filename:string;
|
||||||
sym:TreeDataRef;
|
sym:TreeDataRef;
|
||||||
|
size:integer;
|
||||||
begin
|
begin
|
||||||
readNextToken;
|
readNextToken;
|
||||||
if lastToken.tokenText = '%INCLUDE' then
|
if lastToken.tokenText = '%INCLUDE' then
|
||||||
|
|
@ -2112,7 +2099,8 @@ begin
|
||||||
begin
|
begin
|
||||||
filename := curToken.tokenText;
|
filename := curToken.tokenText;
|
||||||
readNextToken;
|
readNextToken;
|
||||||
readImage(filename);
|
size := parseExpression;
|
||||||
|
readImage(filename, size);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
errorExit2('Invalid meta directive', lastToken.tokenText);
|
errorExit2('Invalid meta directive', lastToken.tokenText);
|
||||||
|
|
|
||||||
|
|
@ -457,13 +457,15 @@ def create_image_with_stuff():
|
||||||
slotnr = putfile("../lib/coreloader.lsym", "coreloader.lsym", f, part, partstart, slotnr)
|
slotnr = putfile("../lib/coreloader.lsym", "coreloader.lsym", f, part, partstart, slotnr)
|
||||||
slotnr = putfile("../lib/coreloader.prog", "coreloader.prog", f, part, partstart, slotnr)
|
slotnr = putfile("../lib/coreloader.prog", "coreloader.prog", f, part, partstart, slotnr)
|
||||||
|
|
||||||
|
slotnr = putfile("../lib/float32.lib", "float32.lib", f, part, partstart, slotnr)
|
||||||
|
slotnr = putfile("../lib/runtime.lib", "runtime.lib", f, part, partstart, slotnr)
|
||||||
slotnr = putfile("../lib/stdlib.lib", None, f, part, partstart, slotnr)
|
slotnr = putfile("../lib/stdlib.lib", None, f, part, partstart, slotnr)
|
||||||
slotnr = putfile("../lib/stdlib.inc", None, f, part, partstart, slotnr)
|
slotnr = putfile("../lib/stdlib.inc", None, f, part, partstart, slotnr)
|
||||||
slotnr = putfile("../lib/stdlib.lsym", None, f, part, partstart, slotnr)
|
|
||||||
|
|
||||||
slotnr = putfile("../pcomp/sasm.prog", None , f, part, partstart, slotnr)
|
slotnr = putfile("../pcomp/sasm.prog", None , f, part, partstart, slotnr)
|
||||||
slotnr = putfile("../pcomp/pcomp.prog", None , f, part, partstart, slotnr)
|
slotnr = putfile("../pcomp/pcomp.prog", None , f, part, partstart, slotnr)
|
||||||
slotnr = putfile("../pcomp/lsymgen.prog", None , f, part, partstart, slotnr)
|
slotnr = putfile("../pcomp/lsymgen.prog", None , f, part, partstart, slotnr)
|
||||||
|
slotnr = putfile("../pcomp/libgen.prog", None , f, part, partstart, slotnr)
|
||||||
|
|
||||||
slotnr = putfile("../progs/reclaim.prog", None , f, part, partstart, slotnr)
|
slotnr = putfile("../progs/reclaim.prog", None , f, part, partstart, slotnr)
|
||||||
slotnr = putfile("../progs/dumpdir.prog", None , f, part, partstart, slotnr)
|
slotnr = putfile("../progs/dumpdir.prog", None , f, part, partstart, slotnr)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue