Skip to content

Commit 72f2549

Browse files
authored
Match all libu files (#52)
* Update makefile * Match libu/bwri.p * Delete SKIP_END_SPACES macro in libu * Update fold.p * Update bread.p and bwri.p * Match libu/uscan.p * PR review
1 parent 74aa0b4 commit 72f2549

File tree

6 files changed

+300
-14
lines changed

6 files changed

+300
-14
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ build/src/7.1/as0/%.o: OPTFLAGS := -O2
139139
build/src/7.1/as1/%.o: OPTFLAGS := -O2
140140
build/src/7.1/cfe/%.o: OPTFLAGS := -O2
141141
build/src/7.1/ugen/%.o: OPTFLAGS := -O2
142+
build/src/7.1/libu/%.o: OPTFLAGS := -O2
142143

143144
# Targets
144145

src/libu/bread.p

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var
3333

3434
procedure fix_infinity(var str: Stringtext; var len: integer); internal;
3535
begin
36-
if
36+
if
3737
((len = 8)
3838
and (str.ss[1] = 'I')
3939
and (str.ss[2] = 'n')
@@ -96,7 +96,7 @@ begin
9696
u.Intarray[2] := ugetint();
9797
urec := utab[u.Opc];
9898
instlength := urec.instlength;
99-
99+
100100
i := 3;
101101
while i <> instlength + 1 do begin
102102
u.Intarray[i] := ugetint();
@@ -109,7 +109,7 @@ begin
109109
u.Intarray[instlength + 2] := ugetint();
110110

111111
if ((u.Dtype in [Mdt, Qdt, Rdt, Sdt, Xdt]) or (u.Opc = Ucomm)) then begin
112-
112+
113113
strlength := (u.Intarray[instlength + 1] + 3) div 4;
114114

115115
if ((strlength & 1) <> 0) then begin
@@ -147,7 +147,7 @@ begin
147147
datachars := ['A', 'C', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'W', 'X', 'Z'];
148148
memorychars := ['A', 'M', 'P', 'R', 'S', 'Z'];
149149
setconstantchars := ['0'..'9', 'A'..'F'];
150-
150+
151151
dtytype['A'] := Adt;
152152
dtytype['C'] := Cdt;
153153
dtytype['F'] := Fdt;
@@ -181,7 +181,7 @@ begin
181181
u.Length := u.Length * 8;
182182
return;
183183
end;
184-
184+
185185
if (u.Opc in [Uildv, Uilod, Uistr, Uistv, Urldc]) then begin
186186
u.I1 := u.I1 * 8;
187187
u.Length := u.Length * 8;
@@ -199,7 +199,7 @@ begin
199199
u.I1 := u.I1 * 8;
200200
return;
201201
end;
202-
202+
203203
if (u.Opc in [Udef, Udif, Ufill, Uiequ, Uigeq, Uigrt, Uileq, Uiles, Uineq, Uinn, Uint, Ulca,
204204
Uldc, Umov, Usdef, Usgs, Uuni]) then begin
205205
u.Length := u.Length * 8;

src/libu/bwri.p

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
#include "cmplrs/usys.h"
2+
#include "cmplrs/ucode.h"
3+
4+
procedure uputinit(var ObjectName : Filename); external;
5+
procedure uputint(i: integer); external;
6+
procedure uputkill(); external;
7+
procedure uputclose(); external;
8+
9+
var
10+
dtyname: Array [first(Datatype)..last(Datatype)] of char;
11+
mtyname: Array [first(Memtype)..last(Memtype)] of char;
12+
noerrorsyet: boolean;
13+
u_indent: integer;
14+
Utab: extern array[first(Uopcode)..last(Uopcode)] of Utabrec;
15+
16+
procedure inituwrite(var arg0: Filename);
17+
begin
18+
noerrorsyet := true;
19+
uputinit(arg0);
20+
21+
dtyname[Cdt] := 'C';
22+
dtyname[Fdt] := 'F';
23+
dtyname[Gdt] := 'G';
24+
dtyname[Hdt] := 'H';
25+
dtyname[Zdt] := 'Z';
26+
dtyname[Adt] := 'A';
27+
dtyname[Jdt] := 'J';
28+
dtyname[Ldt] := 'L';
29+
dtyname[Mdt] := 'M';
30+
dtyname[Ndt] := 'N';
31+
dtyname[Pdt] := 'P';
32+
dtyname[Qdt] := 'Q';
33+
dtyname[Rdt] := 'R';
34+
dtyname[Sdt] := 'S';
35+
dtyname[Xdt] := 'X';
36+
dtyname[Idt] := 'I';
37+
dtyname[Kdt] := 'K';
38+
dtyname[Wdt] := 'W';
39+
40+
mtyname[Zmt] := 'Z';
41+
mtyname[Mmt] := 'M';
42+
mtyname[Rmt] := 'R';
43+
mtyname[Smt] := 'S';
44+
mtyname[Pmt] := 'P';
45+
mtyname[Amt] := 'A';
46+
47+
u_indent := 0;
48+
end;
49+
50+
function idlen(var id: Identname): integer;
51+
var
52+
len: integer;
53+
begin
54+
for len := Identlength downto 1 do begin
55+
if (id[len] <> ' ') then begin
56+
return len;
57+
end;
58+
end;
59+
return 0;
60+
end;
61+
62+
function fnamelen(fname: Filename): integer;
63+
var
64+
len: integer;
65+
begin
66+
len := 0;
67+
68+
while (len < Filenamelen) do begin
69+
if (fname[len + 1] = ' ') then begin
70+
return len;
71+
end;
72+
len := len + 1;
73+
end;
74+
75+
return Filenamelen;
76+
end;
77+
78+
procedure uwrite(var u: Bcrec);
79+
var
80+
i: integer;
81+
pad: integer;
82+
urec: UtabRec;
83+
strlength: integer;
84+
str: Stringtextptr;
85+
begin
86+
if noerrorsyet then begin
87+
urec := utab[u.Opc];
88+
i := 1;
89+
while (i <> (urec.instlength + 1)) do begin
90+
uputint(u.Intarray[i]);
91+
uputint(u.Intarray[i + 1]);
92+
i := i + 2;
93+
end;
94+
95+
if (urec.hasconst) then begin
96+
uputint(u.Intarray[urec.instlength + 1]);
97+
uputint(u.Intarray[urec.instlength + 2]);
98+
if ((u.Dtype in [Mdt, Qdt, Rdt, Sdt, Xdt]) or (u.Opc = Ucomm)) then begin
99+
if (u.Opc = Uinit) then begin
100+
strlength := (u.Initval.Ival + 3) div 4;
101+
end else begin
102+
strlength := (u.Constval.Ival + 3) div 4;
103+
end;
104+
105+
if (strlength & 1 <> 0) then begin
106+
strlength := strlength + 1;
107+
end;
108+
109+
if (u.Opc = Uinit) then begin
110+
str := u.Initval.Chars;
111+
end else begin
112+
str := u.Constval.Chars;
113+
end;
114+
115+
i := 1;
116+
while (i <> (strlength + 1)) do begin
117+
uputint(str^.ssarray[i]);
118+
uputint(str^.ssarray[i + 1]);
119+
i := i + 2;
120+
end;
121+
end;
122+
end;
123+
end;
124+
end;
125+
126+
function getdtyname(Dtyp: Datatype): char;
127+
begin
128+
getdtyname := dtyname[Dtyp];
129+
end;
130+
131+
function getmtyname(Mtyp: Memtype): char;
132+
begin
133+
getmtyname := mtyname[Mtyp];
134+
end;
135+
136+
procedure ucoid(Tag: Identname);
137+
var
138+
i: integer;
139+
u: Bcrec;
140+
begin
141+
for i := 1 to Maxinstlength do begin
142+
u.Intarray[i] := 0;
143+
end;
144+
145+
new(u.Constval.Chars);
146+
147+
{ Skip end spaces }
148+
while ((u.Constval.Ival > 0) and (Tag[u.Constval.Ival] = ' ')) do begin
149+
u.Constval.Ival := u.Constval.Ival - 1;
150+
end;
151+
152+
for i := 1 to u.Constval.Ival do begin
153+
u.Constval.Chars^.ss[i] := Tag[i];
154+
end;
155+
156+
u.Opc := Ucomm;
157+
u.Dtype := Mdt;
158+
uwrite(u);
159+
dispose(u.Constval.Chars);
160+
end;
161+
162+
procedure ucofname(fname: Filename);
163+
var
164+
i: integer;
165+
u: Bcrec;
166+
begin
167+
for i := 1 to Maxinstlength do begin
168+
u.Intarray[i] := 0;
169+
end;
170+
171+
new(u.Constval.Chars);
172+
u.Constval.Ival := fnamelen(fname);
173+
174+
if (u.Constval.Ival >= (Filenamelen + 1)) then begin
175+
u.Constval.Ival := Filenamelen;
176+
end;
177+
178+
for i := 1 to u.Constval.Ival do begin
179+
u.Constval.Chars^.ss[i] := fname[i];
180+
end;
181+
182+
u.Opc := Ucomm;
183+
u.Dtype := Mdt;
184+
uwrite(u);
185+
dispose(u.Constval.Chars);
186+
end;
187+
188+
procedure stopucode();
189+
begin
190+
uputkill();
191+
noerrorsyet := false;
192+
end;
193+
194+
procedure ubittobyte(var u: Bcrec);
195+
begin
196+
if (u.Opc in [Uadj, Uisld, Uisst, Ulod, Umpmv, Upar, Updef, Upmov, Uregs, Urlda, Urpar, Ustr, Uvreg]) then begin
197+
u.Offset := u.Offset div 8;
198+
u.Length := u.Length div 8;
199+
return;
200+
end;
201+
202+
if (u.Opc in [Uildv, Uilod, Uistr, Uistv, Urldc]) then begin
203+
u.I1 := u.I1 div 8;
204+
u.Length := u.Length div 8;
205+
return;
206+
end;
207+
208+
if (u.Opc in [Uilda, Ulda, Urlod, Urstr]) then begin
209+
u.Offset := u.Offset div 8;
210+
u.Length := u.Length div 8;
211+
u.Offset2 := u.Offset2 div 8;
212+
return;
213+
end;
214+
215+
if (u.Opc in [Uidx, Uixa]) then begin
216+
u.I1 := u.I1 div 8;
217+
return;
218+
end;
219+
220+
if (u.Opc in [Udef, Udif, Ufill, Uiequ, Uigeq, Uigrt, Uileq, Uiles, Uineq, Uinn, Uint, Ulca, Uldc, Umov, Umus, Usdef, Usgs, Uuni]) then begin
221+
u.Length := u.Length div 8;
222+
end else if (u.Opc = Uinit) then begin
223+
u.Offset := u.Offset div 8;
224+
u.Length := u.Length div 8;
225+
u.Offset2 := u.Offset2 div 8;
226+
u.Constval.dwval_l := u.Constval.dwval_l div 8;
227+
end else if (u.Opc = Uoptn) and (u.I1 = 1) then begin
228+
u.Length := u.Length div 8;
229+
end;
230+
end;
231+
232+
procedure set_u_indent(ident: integer);
233+
begin
234+
{u_ident := ident} (* Possible implementation of this 'useless' function *)
235+
end;

src/libu/uscan.p

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include "cmplrs/usys.h"
2+
#include "cmplrs/ucode.h"
3+
4+
procedure abort();
5+
begin
6+
halt(-1);
7+
end;
8+
9+
procedure openstdout(var f: Text);
10+
begin
11+
end;
12+
13+
procedure opnstdin(var f: Text);
14+
begin
15+
end;
16+
17+
procedure openinput(var f: Text; fname: Filename);
18+
begin
19+
reset(f, fname);
20+
end;
21+
22+
procedure openoutput(var f: Text; fname: Filename);
23+
begin
24+
rewrite(f, fname);
25+
end;
26+
27+
function getclock(): integer;
28+
begin
29+
getclock := clock(1);
30+
end;
31+
32+
function eopage(var f: text): boolean;
33+
begin
34+
eopage := f^ = chr(12);
35+
end;
36+
37+
procedure readpage(var f: Text);
38+
begin
39+
get(f);
40+
end;
41+
42+
procedure printdate(var fil: text);
43+
begin
44+
45+
end;
46+
47+
procedure printtime(var fil: text);
48+
begin
49+
50+
end;

src/ugen/fold.p

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ end;
2626

2727
function is_constant(arg0: Ptree): boolean;
2828
begin
29-
return (arg0^.u.Opc = Uldc) and (arg0^.u.Dtype in [Adt, Hdt, Idt, Jdt, Kdt, Ldt, Wdt]); {Maybe a special data type is missing...}
29+
return (arg0^.u.Opc = Uldc) and (arg0^.u.Dtype in [Adt, Hdt, Idt, Jdt, Kdt, Ldt, Wdt]);
3030
end;
3131

3232
function llconst(p_tree: Ptree; dtype: Datatype): integer64;

0 commit comments

Comments
 (0)