mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-06-11 13:29:36 +00:00
Compare commits
417 Commits
orcac-220b
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
69320cd4d8 | ||
|
8278f7865a | ||
|
6b7414384f | ||
|
77e0b8fc59 | ||
|
50636bd28b | ||
|
83537fd3c7 | ||
|
81934109fc | ||
|
72234a4f2b | ||
|
36f766a662 | ||
|
4c402fc883 | ||
|
ca0147507b | ||
|
24c6e72a83 | ||
|
0f18fa63b5 | ||
|
8f07ca5d6c | ||
|
60b472a99e | ||
|
995885540b | ||
|
34c5be5cab | ||
|
75a928e273 | ||
|
a545685ab4 | ||
|
ce94f4e2b6 | ||
|
84fdb5c975 | ||
|
d1847d40be | ||
|
c671bb71a5 | ||
|
a646a03b5e | ||
|
7ca30d7784 | ||
|
c9dc566c10 | ||
|
2ca4aba5c4 | ||
|
d7cc9b5909 | ||
|
586229e6eb | ||
|
0aee669746 | ||
|
25085f5b81 | ||
|
6905d8dced | ||
|
f815c1bda6 | ||
|
5316b438d5 | ||
|
4d8eaf93bc | ||
|
7e5023844a | ||
|
1aa654628a | ||
|
9a56a50f5f | ||
|
adcab004df | ||
|
7188b4f418 | ||
|
af3c8e1eea | ||
|
0021fd81bc | ||
|
966da239ee | ||
|
5b294721f2 | ||
|
914e5972bd | ||
|
79e83c3092 | ||
|
e5c69670cd | ||
|
509f09253f | ||
|
05c9ea16c8 | ||
|
661c9c440d | ||
|
c8517eff87 | ||
|
c2262929e9 | ||
|
9d5360e844 | ||
|
338bfdd908 | ||
|
118e326ac9 | ||
|
938fa96503 | ||
|
986fe9a65b | ||
|
ab975b611c | ||
|
e123339a45 | ||
|
0274b0ba83 | ||
|
84401b4e97 | ||
|
3a298ec341 | ||
|
2974c1b4bb | ||
|
9dad2b6186 | ||
|
5c96042423 | ||
|
e5c7aebb3f | ||
|
20f9170343 | ||
|
4c903a5331 | ||
|
0b3f48157e | ||
|
ba57d51500 | ||
|
74cec68dac | ||
|
4e5e622903 | ||
|
c678151bde | ||
|
a988ef60bc | ||
|
ae89e77bbe | ||
|
7e860e60df | ||
|
2412ae0661 | ||
|
3a64c5b977 | ||
|
be291b2423 | ||
|
cc36e9929f | ||
|
3b6f73c277 | ||
|
cbf32e5b71 | ||
|
a5eafe56af | ||
|
137188ff4f | ||
|
1b7b198039 | ||
|
ea056f1fbb | ||
|
344bf6999f | ||
|
49deff3c86 | ||
|
7c8ec41148 | ||
|
30a04d42c5 | ||
|
27c68b41d5 | ||
|
c6ba1e1c1c | ||
|
3ac55a64bf | ||
|
3406dbd3ae | ||
|
645b210e7f | ||
|
1f6bc44b48 | ||
|
85890e0b6b | ||
|
a985a9ca7a | ||
|
ea623d38fc | ||
|
bda54c0a79 | ||
|
cff8144c88 | ||
|
a6ef872513 | ||
|
a32ddedc0c | ||
|
6b39cea80d | ||
|
4b9824d5d6 | ||
|
40260bb8a0 | ||
|
03fc7a43b9 | ||
|
61a2cd1e5e | ||
|
2958619726 | ||
|
74b9885572 | ||
|
4d1a8caf8a | ||
|
cb6173557e | ||
|
34c1564dc4 | ||
|
245dd0a3f4 | ||
|
9f36e99194 | ||
|
5476118951 | ||
|
59664df9d9 | ||
|
f7a139b4b5 | ||
|
7d3f1c8dd7 | ||
|
a87aeef25b | ||
|
cf9f19c93d | ||
|
854a6779a9 | ||
|
e910eda623 | ||
|
030f3ff9e1 | ||
|
d68e0b268f | ||
|
265a16d2f5 | ||
|
53fcb84352 | ||
|
a7551d8c44 | ||
|
09fbfb1905 | ||
|
705c9d36a2 | ||
|
4bc486eade | ||
|
fe62f70d51 | ||
|
44499bdddb | ||
|
17936a14ed | ||
|
ecca7a7737 | ||
|
1754607908 | ||
|
32975b720f | ||
|
7364e2d2d3 | ||
|
e71fe5d785 | ||
|
f027286b6a | ||
|
6ba6ad549f | ||
|
fb5a2fcf33 | ||
|
bb1bd176f4 | ||
|
6857913daa | ||
|
389f60ed27 | ||
|
8aedd42294 | ||
|
a7d9d3039b | ||
|
0c4660d5fc | ||
|
8e1db102eb | ||
|
facd1bf992 | ||
|
c06d78bb5e | ||
|
2550081517 | ||
|
935bb6c04e | ||
|
f5f63563c6 | ||
|
736e7575cf | ||
|
36c70f9107 | ||
|
20770f388e | ||
|
7c0492cfa4 | ||
|
945d5ce855 | ||
|
d56cf7e666 | ||
|
28e119afb1 | ||
|
48efd462ef | ||
|
8ad58b0de7 | ||
|
c1a188aa95 | ||
|
51951721c5 | ||
|
94584b0f05 | ||
|
e7940db4c8 | ||
|
1f468c437f | ||
|
ac741e26ab | ||
|
c58d84689a | ||
|
4a8b5b25c7 | ||
|
50e3a8ea30 | ||
|
bde70e0885 | ||
|
dc305a86b2 | ||
|
39250629bd | ||
|
4621336c3b | ||
|
a3c4eeb8f6 | ||
|
adfa7c04c1 | ||
|
c261e14d56 | ||
|
250a6361c1 | ||
|
def9e56e8e | ||
|
6260a27b11 | ||
|
58d8edf1ee | ||
|
aa6b82a136 | ||
|
5df94c953e | ||
|
335e8be75e | ||
|
5f8a6baa94 | ||
|
968844fb38 | ||
|
d1edc8821d | ||
|
cd9931a60c | ||
|
8cfc14b50a | ||
|
b6d3dfb075 | ||
|
740468f75c | ||
|
2bf3862e5d | ||
|
92a3af1d5f | ||
|
5500833180 | ||
|
3f450bdb80 | ||
|
ab368d442a | ||
|
9cc72c8845 | ||
|
d96a5f86f9 | ||
|
202ed3b514 | ||
|
de57170ef8 | ||
|
fa166030fe | ||
|
e168a4d6cb | ||
|
82b2944eb8 | ||
|
83147655d2 | ||
|
d3ba8b5551 | ||
|
986a283540 | ||
|
7d6b732d23 | ||
|
9a7dc23c5d | ||
|
d4c4d18a55 | ||
|
f31b5ea1e6 | ||
|
f54d0e1854 | ||
|
913052fe7c | ||
|
e5428b21d2 | ||
|
4702df9aac | ||
|
e63d827049 | ||
|
e0b27db652 | ||
|
81353a9f8a | ||
|
e3a3548443 | ||
|
65ec29ee3e | ||
|
760c932fea | ||
|
859aa4a20a | ||
|
946c6c1d55 | ||
|
bdf212ec6b | ||
|
6d8ca42734 | ||
|
cb5db95476 | ||
|
91d33b586d | ||
|
b3c30b05d8 | ||
|
afe40c0f67 | ||
|
a864954353 | ||
|
99e268e3b9 | ||
|
44a1ba5205 | ||
|
83ac0ecebf | ||
|
6fadd52fc2 | ||
|
5be888a2bd | ||
|
072f8be6bc | ||
|
b8b7dc2c2b | ||
|
99a10590b1 | ||
|
19683706cc | ||
|
12a2e14b6d | ||
|
ca21e33ba7 | ||
|
4fe9c90942 | ||
|
f263066f61 | ||
|
995ded07a5 | ||
|
3cea478e5e | ||
|
53baef0fb3 | ||
|
1fa3ec8fdd | ||
|
05ecf5eef3 | ||
|
4e76f62b0e | ||
|
95ad02f0b9 | ||
|
711549392c | ||
|
2f75f47140 | ||
|
1177ddc172 | ||
|
6e3fca8b82 | ||
|
d576f19ede | ||
|
6d07043783 | ||
|
fd54fd70d0 | ||
|
60efb4d882 | ||
|
c36bf9bf0a | ||
|
2cbcdc736c | ||
|
bdf8ed4f29 | ||
|
6bfd491f2a | ||
|
6934c8890d | ||
|
63d33b47bf | ||
|
417fd1ad9c | ||
|
312a3a09b9 | ||
|
687a5eaa45 | ||
|
b5b76b624c | ||
|
607211d38e | ||
|
23b870908e | ||
|
753c9b9f20 | ||
|
c3567c81a4 | ||
|
9b31e7f72a | ||
|
7b0dda5a5e | ||
|
76e4b1f038 | ||
|
bf40e861aa | ||
|
2dff68e6ae | ||
|
4470626ade | ||
|
054719aab2 | ||
|
00e7fe7125 | ||
|
f0d827eade | ||
|
7898c619c8 | ||
|
393b7304a0 | ||
|
497e5c036b | ||
|
11a3195c49 | ||
|
f5d5b88002 | ||
|
f6fedea288 | ||
|
06bf0c5f46 | ||
|
c987f240c6 | ||
|
102d6873a3 | ||
|
15dc3a46c4 | ||
|
5e20e02d06 | ||
|
e5501dc902 | ||
|
58849607a1 | ||
|
a3104853fc | ||
|
802ba3b0ba | ||
|
91b63f94d3 | ||
|
67ffeac7d4 | ||
|
5e08ef01a9 | ||
|
8406921147 | ||
|
161bb952e3 | ||
|
3c2b492618 | ||
|
a85846cc80 | ||
|
0e8b485f8f | ||
|
0b6d150198 | ||
|
58771ec71c | ||
|
deca73d233 | ||
|
daff1754b2 | ||
|
21f266c5df | ||
|
a1d57c4db3 | ||
|
b2edeb4ad1 | ||
|
f531f38463 | ||
|
182cf66754 | ||
|
fec7b57ec2 | ||
|
6cfe8cc886 | ||
|
8f27b8abdb | ||
|
bf7a6fa5db | ||
|
26e1bfc253 | ||
|
2b062a8392 | ||
|
da978932bf | ||
|
2a9ec8fc43 | ||
|
aabbadb34b | ||
|
a73dce103b | ||
|
1e98a63bf4 | ||
|
f2d6625300 | ||
|
30fcc7227f | ||
|
3893db1346 | ||
|
8c0d65616c | ||
|
c96cf4f1dd | ||
|
b493dcb1da | ||
|
c169c2bf92 | ||
|
5d7c002819 | ||
|
b231782442 | ||
|
913a333f9f | ||
|
06e17cd8f5 | ||
|
bd811559d6 | ||
|
9cdf199c3a | ||
|
5f03dee66a | ||
|
efb363a04d | ||
|
7d4f923470 | ||
|
785a6997de | ||
|
5ac79ff36c | ||
|
7322428e1d | ||
|
4cb2106ee4 | ||
|
dce9d36edd | ||
|
e36503508a | ||
|
e8d90a1b69 | ||
|
02fbf97a1e | ||
|
5357e65859 | ||
|
f4b0993007 | ||
|
242bef1f6e | ||
|
8eda03436a | ||
|
6f0b94bb7c | ||
|
b1bc840ec8 | ||
|
3acf5844c2 | ||
|
3b35a65b1d | ||
|
61a382de0b | ||
|
b5b276d0f4 | ||
|
4e59f4569f | ||
|
8c5fba684c | ||
|
d0514c5dc4 | ||
|
3058ea6ad9 | ||
|
de5fa5bfac | ||
|
ed3035cb99 | ||
|
45fad90d6d | ||
|
1fb1762458 | ||
|
3997fc6dce | ||
|
bccbcb132b | ||
|
98529a9342 | ||
|
c767848ec9 | ||
|
033ff816aa | ||
|
b43036409e | ||
|
6fa294aa3b | ||
|
aaec648e69 | ||
|
6d8e019443 | ||
|
dda37cd17c | ||
|
3e08ba39aa | ||
|
b2874b8bf6 | ||
|
4ebdb4ad04 | ||
|
73a081bd55 | ||
|
7ac3fe6424 | ||
|
c1b2a88a84 | ||
|
8db7a62f49 | ||
|
a6359f67e0 | ||
|
906f9f6312 | ||
|
bd1d2101eb | ||
|
5b953e2db0 | ||
|
1010f9a906 | ||
|
73d194c12f | ||
|
26d0f2ad35 | ||
|
a20d69a211 | ||
|
6e32bfc091 | ||
|
772043241c | ||
|
7584f8185c | ||
|
daede21819 | ||
|
f567d60429 | ||
|
692ebaba85 | ||
|
ad5063a9a3 | ||
|
ba944e5675 | ||
|
a888206111 | ||
|
5871820e0c | ||
|
222c34a385 | ||
|
b076f85149 | ||
|
27be3e26ae | ||
|
020f5ca5b2 | ||
|
cc8e003860 | ||
|
bf2c1f2266 | ||
|
47478604af | ||
|
8ab065411f | ||
|
02790c11e3 | ||
|
38dc91892b | ||
|
1b9955bf8b | ||
|
650ff4697f | ||
|
7ae830ae7e | ||
|
3c3697535e | ||
|
851d7d0787 |
22
Asm.pas
22
Asm.pas
|
@ -166,10 +166,8 @@ var
|
||||||
{ An error was found: skip to the end & quit }
|
{ An error was found: skip to the end & quit }
|
||||||
|
|
||||||
begin {Skip}
|
begin {Skip}
|
||||||
charKinds[ord('#')] := ch_pound;
|
|
||||||
while not (token.kind in [rbracech,eofsy]) do
|
while not (token.kind in [rbracech,eofsy]) do
|
||||||
NextToken;
|
NextToken;
|
||||||
charKinds[ord('#')] := illegal;
|
|
||||||
goto 99;
|
goto 99;
|
||||||
end; {Skip}
|
end; {Skip}
|
||||||
|
|
||||||
|
@ -226,6 +224,7 @@ var
|
||||||
size := longAddress;
|
size := longAddress;
|
||||||
end {if}
|
end {if}
|
||||||
else begin
|
else begin
|
||||||
|
id^.used := true;
|
||||||
operand.symbolPtr := id;
|
operand.symbolPtr := id;
|
||||||
if id^.storage in [stackFrame,parameter] then begin
|
if id^.storage in [stackFrame,parameter] then begin
|
||||||
code^.slab := id^.lln;
|
code^.slab := id^.lln;
|
||||||
|
@ -329,7 +328,6 @@ while not (token.kind in [rbracech,eofsy]) do begin
|
||||||
|
|
||||||
{find the label and op-code}
|
{find the label and op-code}
|
||||||
CheckForComment;
|
CheckForComment;
|
||||||
charKinds[ord('#')] := ch_pound; {allow # as a token}
|
|
||||||
if token.kind <> ident then begin {error if not an identifier}
|
if token.kind <> ident then begin {error if not an identifier}
|
||||||
Error(9);
|
Error(9);
|
||||||
Skip;
|
Skip;
|
||||||
|
@ -345,7 +343,6 @@ while not (token.kind in [rbracech,eofsy]) do begin
|
||||||
opname := token;
|
opname := token;
|
||||||
NextToken;
|
NextToken;
|
||||||
end; {while}
|
end; {while}
|
||||||
charKinds[ord('#')] := illegal; {don't allow # as a token}
|
|
||||||
|
|
||||||
{identify the op-code}
|
{identify the op-code}
|
||||||
if length(opname.name^) = 3 then begin
|
if length(opname.name^) = 3 then begin
|
||||||
|
@ -568,13 +565,18 @@ while not (token.kind in [rbracech,eofsy]) do begin
|
||||||
{handle data declarations}
|
{handle data declarations}
|
||||||
else if opc <= o_dcl then begin
|
else if opc <= o_dcl then begin
|
||||||
Exp([semicolonch], true);
|
Exp([semicolonch], true);
|
||||||
code^.s := d_add;
|
if opc = o_dcb then begin
|
||||||
if opc = o_dcb then
|
code^.s := d_dcb;
|
||||||
code^.r := ord(direct)
|
code^.r := ord(direct);
|
||||||
else if opc = o_dcw then
|
end {if}
|
||||||
code^.r := ord(absolute)
|
else if opc = o_dcw then begin
|
||||||
else
|
code^.s := d_dcw;
|
||||||
|
code^.r := ord(absolute);
|
||||||
|
end {else if}
|
||||||
|
else begin
|
||||||
|
code^.s := d_dcl;
|
||||||
code^.r := ord(longabsolute);
|
code^.r := ord(longabsolute);
|
||||||
|
end; {else}
|
||||||
end {if opc <= o_dcl}
|
end {if opc <= o_dcl}
|
||||||
|
|
||||||
{handle the brk instruction}
|
{handle the brk instruction}
|
||||||
|
|
44
C.Read.Me
Normal file
44
C.Read.Me
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
Welcome to ORCA/C 2.2.1! This is a release containing updates from
|
||||||
|
community members (Stephen Heumann and Kelvin Sherlock).
|
||||||
|
|
||||||
|
ORCA/C 2.2 adds support for almost all of the new language and library
|
||||||
|
features required by the C17 standard. It also has several other new
|
||||||
|
features, such as additional lint checks to help identify bugs and
|
||||||
|
portability problems. In addition to these new features, ORCA/C 2.2
|
||||||
|
includes hundreds of bug fixes in the compiler and libraries.
|
||||||
|
|
||||||
|
ORCA/C 2.2.1 includes additional bug fixes to ORCA/C 2.2.0.
|
||||||
|
|
||||||
|
The ORCA/C manual has been fully updated to cover ORCA/C 2.2, so new
|
||||||
|
users should simply refer to that. Users familiar with older versions
|
||||||
|
of ORCA/C can refer to the cc.notes file in the Release.Notes directory
|
||||||
|
for a description of the changes between ORCA/C 2.0 and ORCA/C 2.2.1.
|
||||||
|
|
||||||
|
ORCA/C 2.2.1 requires a real or emulated Apple IIGS with at least the
|
||||||
|
following specifications:
|
||||||
|
|
||||||
|
* 2 MB of RAM (3 MB or more recommended)
|
||||||
|
* a hard drive or SSD
|
||||||
|
* System 6.0.1 or later
|
||||||
|
|
||||||
|
ORCA/C can also be run on modern Mac, Windows, or Linux systems as a
|
||||||
|
cross compiler by using Golden Gate, a specialized emulation tool by
|
||||||
|
Kelvin Sherlock. It is available separately from Juiced.GS:
|
||||||
|
https://juiced.gs/store/golden-gate/
|
||||||
|
|
||||||
|
If you have any questions, or if you want to get involved in ORCA/C
|
||||||
|
development, please get in touch. The ORCA/C development project is
|
||||||
|
hosted on GitHub, and bug reports or patches can be submitted there:
|
||||||
|
https://github.com/byteworksinc/ORCA-C
|
||||||
|
|
||||||
|
Thanks to:
|
||||||
|
* Mike Westerfield, for writing ORCA/C, releasing the source code,
|
||||||
|
and permitting it to be updated by the community.
|
||||||
|
* Kelvin Sherlock, for providing several patches and bug reports, and
|
||||||
|
for writing several useful tools for modern Apple II development.
|
||||||
|
* Soenke Behrens, for compiling a list of ORCA/C bug reports and test
|
||||||
|
cases, which has helped me to identify and fix a number of bugs.
|
||||||
|
* The developers of Csmith (http://embed.cs.utah.edu/csmith/), an
|
||||||
|
automated compiler testing tool that has helped to find several bugs.
|
||||||
|
|
||||||
|
--Stephen Heumann (stephenheumann@gmail.com)
|
46
C.Samples/Benchmarks/FIB.cc
Normal file
46
C.Samples/Benchmarks/FIB.cc
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* Fibonacci
|
||||||
|
*
|
||||||
|
* Recursively computes Fibonacci numbers to test the speed of
|
||||||
|
* function calls.
|
||||||
|
*
|
||||||
|
* To get the best performance from the desktop development
|
||||||
|
* environment, be sure and turn debugging off from the
|
||||||
|
* Compile Dialog. Use the Compile command from the Run menu
|
||||||
|
* to get the compile dialog.
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "FIB"
|
||||||
|
#pragma optimize -1
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define NTIMES 10 /* # iterations */
|
||||||
|
#define NUMBER 23 /* largest Fib # smaller than 32767 */
|
||||||
|
|
||||||
|
|
||||||
|
int Fibonacci(int x)
|
||||||
|
|
||||||
|
{
|
||||||
|
if (x > 2)
|
||||||
|
return Fibonacci(x-1)+Fibonacci(x-2);
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
int value;
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
printf("%d iterations:\n", NTIMES);
|
||||||
|
for (i = 0; i < NTIMES; ++i)
|
||||||
|
value = Fibonacci(NUMBER);
|
||||||
|
printf("Fibonacci(%d) = %d\n", NUMBER, value);
|
||||||
|
return 0;
|
||||||
|
}
|
51
C.Samples/Benchmarks/Float.cc
Normal file
51
C.Samples/Benchmarks/Float.cc
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* Float
|
||||||
|
*
|
||||||
|
* Test simple floating point operations.
|
||||||
|
*
|
||||||
|
* To get the best performance from the desktop development
|
||||||
|
* environment, be sure and turn debugging off from the
|
||||||
|
* Compile Dialog. Use the Compile command from the Run menu
|
||||||
|
* to get the compile dialog.
|
||||||
|
*
|
||||||
|
***************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Float"
|
||||||
|
#pragma optimize -1
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define const1 3.141597
|
||||||
|
#define const2 1.7839032e4
|
||||||
|
#define count 1000
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
|
||||||
|
{
|
||||||
|
double a,b,c;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
a = const1;
|
||||||
|
b = const2;
|
||||||
|
printf("%d iterations.\n", count);
|
||||||
|
for (i = 0; i < count; ++i) {
|
||||||
|
c = a*b;
|
||||||
|
c = c/a;
|
||||||
|
c = a*b;
|
||||||
|
c = c/a;
|
||||||
|
c = a*b;
|
||||||
|
c = c/a;
|
||||||
|
c = a*b;
|
||||||
|
c = c/a;
|
||||||
|
c = a*b;
|
||||||
|
c = c/a;
|
||||||
|
c = a*b;
|
||||||
|
c = c/a;
|
||||||
|
c = a*b;
|
||||||
|
c = c/a;
|
||||||
|
}
|
||||||
|
printf("Done. C is %e.\n", c);
|
||||||
|
return 0;
|
||||||
|
}
|
114
C.Samples/Benchmarks/Gamm.cc
Normal file
114
C.Samples/Benchmarks/Gamm.cc
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* Gamm
|
||||||
|
*
|
||||||
|
* Test the speed of floating point operations in a mix tha
|
||||||
|
* is typical of scientific and engineering applications.
|
||||||
|
*
|
||||||
|
* To get the best performance from the desktop development
|
||||||
|
* environment, be sure and turn debugging off from the
|
||||||
|
* Compile Dialog. Use the Compile command from the Run menu
|
||||||
|
* to get the compile dialog.
|
||||||
|
*
|
||||||
|
***************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Gamm"
|
||||||
|
#pragma optimize -1
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
int five,i,j,n,rep,ten,thirty;
|
||||||
|
float acc,acc1,divn,rn,root,x,y;
|
||||||
|
float a[30], b[30], c[30];
|
||||||
|
|
||||||
|
printf("Start timing 15000 Gamm units\n");
|
||||||
|
n = 50;
|
||||||
|
five = 5;
|
||||||
|
ten = 10;
|
||||||
|
thirty = 30;
|
||||||
|
rn = n;
|
||||||
|
divn = 1.0/rn;
|
||||||
|
x = 0.1;
|
||||||
|
acc = 0.0;
|
||||||
|
|
||||||
|
/* initialize a and b */
|
||||||
|
y = 1.0;
|
||||||
|
for (i = 0; i < thirty; ++i) {
|
||||||
|
a[i] = i+1;
|
||||||
|
b[i] = -y;
|
||||||
|
y = -y;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* one pass thru this loop corresponds to 300 gamm units */
|
||||||
|
for (rep = 0; rep < n; ++rep) {
|
||||||
|
/* first addition/subtraction loop */
|
||||||
|
i = 29;
|
||||||
|
for (j = 0; j < 30; ++j) {
|
||||||
|
c[i] = a[i]+b[i];
|
||||||
|
--i;
|
||||||
|
};
|
||||||
|
/* first polynomial loop */
|
||||||
|
y = 1.0;
|
||||||
|
for (i = 0; i < 10; ++i)
|
||||||
|
y = (y+c[i])*x;
|
||||||
|
acc1 = y*divn;
|
||||||
|
/* first maximum element loop */
|
||||||
|
y = c[10];
|
||||||
|
for (i = 10; i < 20; ++i)
|
||||||
|
if (c[i] > y)
|
||||||
|
y = c[i];
|
||||||
|
/* first square root loop */
|
||||||
|
root = 1.0;
|
||||||
|
for (i = 0; i < 5; ++i)
|
||||||
|
root = 0.5*(root+y/root);
|
||||||
|
acc1 = acc1+root*divn;
|
||||||
|
/* second addition/subtraction loop */
|
||||||
|
for (i = 0; i < 30; ++i)
|
||||||
|
a[i] = c[i]-b[i];
|
||||||
|
/* second polynomial loop */
|
||||||
|
y = 0.0;
|
||||||
|
for (i = 0; i < 10; ++i)
|
||||||
|
y = (y+a[i])*x;
|
||||||
|
/* second square root loop */
|
||||||
|
root = 1.0;
|
||||||
|
for (i = 1; i < 5; ++i)
|
||||||
|
root = 0.5*(root+y/root);
|
||||||
|
acc1 = acc1+root*divn;
|
||||||
|
/* first multiplication loop */
|
||||||
|
for (i = 0; i < thirty; ++i)
|
||||||
|
c[i] = c[i]*b[i];
|
||||||
|
/* second maximum element loop */
|
||||||
|
y = c[19];
|
||||||
|
for (i = 20; i < thirty; ++i)
|
||||||
|
if (c[i] > y)
|
||||||
|
y = c[i];
|
||||||
|
/* third square root loop */
|
||||||
|
root = 1.0;
|
||||||
|
for (i = 0; i < 5; ++i)
|
||||||
|
root = 0.5*(root+y/root);
|
||||||
|
acc1 = acc1+root*divn;
|
||||||
|
/* third polynomial loop */
|
||||||
|
y = 0.0;
|
||||||
|
for (i = 0; i < 10; ++i)
|
||||||
|
y = (y+c[i])*x;
|
||||||
|
acc1 = acc1+y*divn;
|
||||||
|
/* third maximum element loop */
|
||||||
|
y = c[0];
|
||||||
|
for (i = 1; i < 10; ++i);
|
||||||
|
if (c[i] > y)
|
||||||
|
y = c[i];
|
||||||
|
/* fourth square root loop */
|
||||||
|
root = 1.0;
|
||||||
|
for (i = 0; i < 5; ++i)
|
||||||
|
root = 0.5*(root+y/root);
|
||||||
|
acc1 = acc1+root*divn;
|
||||||
|
acc = acc+acc1;
|
||||||
|
}
|
||||||
|
printf("%12d %12.7e %12.7e\n", n, acc, acc1);
|
||||||
|
return 0;
|
||||||
|
}
|
56
C.Samples/Benchmarks/IMath.cc
Normal file
56
C.Samples/Benchmarks/IMath.cc
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* Integer Math
|
||||||
|
*
|
||||||
|
* Test the speed of the four basic integer math operations.
|
||||||
|
*
|
||||||
|
* To get the best performance from the desktop development
|
||||||
|
* environment, be sure and turn debugging off from the
|
||||||
|
* Compile Dialog. Use the Compile command from the Run menu
|
||||||
|
* to get the compile dialog.
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "IMath"
|
||||||
|
#pragma optimize -1
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define ITER 10000
|
||||||
|
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
int a,b,c,d,e,f;
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
printf("Start timing...\n");
|
||||||
|
b = 1000;
|
||||||
|
c = 10;
|
||||||
|
d = 100;
|
||||||
|
e = 5;
|
||||||
|
f = 10;
|
||||||
|
for (i = 0; i < ITER; ++i) {
|
||||||
|
a = b+c-d*e/f;
|
||||||
|
a = b+c-d*e/f;
|
||||||
|
a = b+c-d*e/f;
|
||||||
|
a = b+c-d*e/f;
|
||||||
|
a = b+c-d*e/f;
|
||||||
|
a = b+c-d*e/f;
|
||||||
|
a = b+c-d*e/f;
|
||||||
|
a = b+c-d*e/f;
|
||||||
|
a = b+c-d*e/f;
|
||||||
|
a = b+c-d*e/f;
|
||||||
|
a = b+c-d*e/f;
|
||||||
|
}
|
||||||
|
if (a == 960) {
|
||||||
|
printf("Stop timing - correct result.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("INCORRECT RESULT.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
50
C.Samples/Benchmarks/Prime.cc
Normal file
50
C.Samples/Benchmarks/Prime.cc
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* This is probably the most famous benchmark in use today.
|
||||||
|
* It tests the speed that a compiler can do logic and looping
|
||||||
|
* operations. While there are things that you can do to make
|
||||||
|
* this benchmark run faster under ORCA/C, we have not
|
||||||
|
* doctored it in any way - this is the original benchmark
|
||||||
|
* in its original form.
|
||||||
|
*
|
||||||
|
* To get the best performance from the desktop development
|
||||||
|
* environment, be sure and turn debugging off from the
|
||||||
|
* Compile Dialog. Use the Compile command from the Run menu
|
||||||
|
* to get the compile dialog.
|
||||||
|
*
|
||||||
|
***************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Prime"
|
||||||
|
#pragma optimize -1
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define true 1
|
||||||
|
#define false 0
|
||||||
|
#define size 8190
|
||||||
|
|
||||||
|
char flags[size+1];
|
||||||
|
|
||||||
|
void main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
int i,prime,k,count,iter;
|
||||||
|
|
||||||
|
printf("10 iterations\n");
|
||||||
|
for (iter = 1; iter <= 10; iter++) {
|
||||||
|
count = 0;
|
||||||
|
for (i = 0; i <= size; i++)
|
||||||
|
flags[i] = true;
|
||||||
|
for (i = 0; i <= size; i++) {
|
||||||
|
if (flags[i]) {
|
||||||
|
prime = i+i+3;
|
||||||
|
/* printf("\n%d", prime); */
|
||||||
|
for (k = i+prime; k <= size; k += prime)
|
||||||
|
flags[k] = false;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n%d primes.", count);
|
||||||
|
}
|
96
C.Samples/Benchmarks/Quick.cc
Normal file
96
C.Samples/Benchmarks/Quick.cc
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* QuickSort
|
||||||
|
*
|
||||||
|
* Creates an array of long integers, then sorts the array.
|
||||||
|
*
|
||||||
|
* To get the best performance from the desktop development
|
||||||
|
* environment, be sure and turn debugging off from the
|
||||||
|
* Compile Dialog. Use the Compile command from the Run menu
|
||||||
|
* to get the compile dialog.
|
||||||
|
*
|
||||||
|
***************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Quick"
|
||||||
|
#pragma optimize -1
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define maxNum 999 /* size of array to sort - 1 */
|
||||||
|
#define count 10 /* # of iterations */
|
||||||
|
#define modulus 0x00020000 /* for random number generator */
|
||||||
|
#define c 13849
|
||||||
|
#define a 25173
|
||||||
|
|
||||||
|
typedef long arrayType[maxNum];
|
||||||
|
|
||||||
|
arrayType buffer; /* array to sort */
|
||||||
|
long seed; /* seed for random number generator */
|
||||||
|
|
||||||
|
|
||||||
|
void Quick (int lo, int hi, arrayType base)
|
||||||
|
|
||||||
|
{
|
||||||
|
int i,j;
|
||||||
|
long pivot,temp;
|
||||||
|
|
||||||
|
if (hi > lo) {
|
||||||
|
pivot = base[hi];
|
||||||
|
i = lo-1;
|
||||||
|
j = hi;
|
||||||
|
do {
|
||||||
|
do ++i; while ((base[i] < pivot) && (j > i));
|
||||||
|
if (j > i)
|
||||||
|
do --j; while ((base[j] > pivot) && (j > i));
|
||||||
|
temp = base[i];
|
||||||
|
base[i] = base[j];
|
||||||
|
base[j] = temp;
|
||||||
|
}
|
||||||
|
while (j > i);
|
||||||
|
base[j] = base[i];
|
||||||
|
base[i] = base[hi];
|
||||||
|
base[hi] = temp;
|
||||||
|
Quick(lo, i-1, base);
|
||||||
|
Quick(i+1, hi, base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
long Random (long size)
|
||||||
|
|
||||||
|
{
|
||||||
|
seed = seed*a+c;
|
||||||
|
return seed % size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
int i,j; /* loop variables */
|
||||||
|
int pass; /* for checking the array */
|
||||||
|
|
||||||
|
seed = 7;
|
||||||
|
printf("Filling array and sorting %d times.\n", count);
|
||||||
|
for (i = 0; i < count; ++i) {
|
||||||
|
for (j = 0; j < maxNum; ++j)
|
||||||
|
buffer[j] = labs(Random(modulus));
|
||||||
|
Quick(0, maxNum-1, buffer);
|
||||||
|
}
|
||||||
|
printf("Done.\n");
|
||||||
|
|
||||||
|
pass = 1;
|
||||||
|
for (i = 0; i < maxNum-1; ++i)
|
||||||
|
if (buffer[i] > buffer[i+1])
|
||||||
|
pass = 0;
|
||||||
|
if (pass) {
|
||||||
|
printf("The last array is sorted properly.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("The last array is NOT sorted properly!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
35
C.Samples/Benchmarks/Savage.cc
Normal file
35
C.Samples/Benchmarks/Savage.cc
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* Savage
|
||||||
|
*
|
||||||
|
* Test the speed (and stability) of floating point functions.
|
||||||
|
*
|
||||||
|
* To get the best performance from the desktop development
|
||||||
|
* environment, be sure and turn debugging off from the
|
||||||
|
* Compile Dialog. Use the Compile command from the Run menu
|
||||||
|
* to get the compile dialog.
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Savage"
|
||||||
|
#pragma optimize -1
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#define loop 250
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
double sum;
|
||||||
|
|
||||||
|
printf("Start...\n");
|
||||||
|
sum = 1.0;
|
||||||
|
for (i = 1; i < loop; ++i)
|
||||||
|
sum = tan(atan(exp(log(sqrt(sum*sum)))))+1.0;
|
||||||
|
printf("sum = %e", sum);
|
||||||
|
return 0;
|
||||||
|
}
|
288
C.Samples/CDA.Samples/Calendar.cc
Normal file
288
C.Samples/CDA.Samples/Calendar.cc
Normal file
|
@ -0,0 +1,288 @@
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* Calendar
|
||||||
|
*
|
||||||
|
* This classic desk accessory shows the calendar for the
|
||||||
|
* current date. The arrow keys can be used to see calendars
|
||||||
|
* for previous or future months.
|
||||||
|
*
|
||||||
|
* Commands (each is a single keystroke)
|
||||||
|
*
|
||||||
|
* up-arrow Look at the same month in the previous
|
||||||
|
* year.
|
||||||
|
* down-arrow Look at the same month in the next
|
||||||
|
* year.
|
||||||
|
* left-arrow Look at the previous month.
|
||||||
|
* right-arrow Look at the next month.
|
||||||
|
* ? or / Display help screen.
|
||||||
|
* ESC Return to CDA main menu.
|
||||||
|
*
|
||||||
|
* Mike Westerfield
|
||||||
|
*
|
||||||
|
* Copyright 1987-1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
***************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Calendar"
|
||||||
|
#pragma cda "Calendar" Start ShutDown
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <misctool.h>
|
||||||
|
|
||||||
|
#define LEFT_ARROW 0x08 /* key codes for legal commands */
|
||||||
|
#define DOWN_ARROW 0x0A
|
||||||
|
#define UP_ARROW 0x0B
|
||||||
|
#define RIGHT_ARROW 0x15
|
||||||
|
#define ESC 0x1B
|
||||||
|
#define SLASH '/'
|
||||||
|
#define QUESTION '?'
|
||||||
|
|
||||||
|
int ch; /* ord of last character read */
|
||||||
|
int month, year; /* current month and year */
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* Factor: Computes the 'factor' for the first day of the
|
||||||
|
* month. The factor is the number of days since
|
||||||
|
* 31 Dec 0000.
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
long Factor (long year, long month)
|
||||||
|
|
||||||
|
{
|
||||||
|
if (month < 2)
|
||||||
|
return 365 * year + 1 + 31 * month + (year - 1) / 4 -
|
||||||
|
((year - 1) / 100 + 1) * 3 / 4;
|
||||||
|
return 365 * year + 1 + 31 * month - ((month + 1) * 4 + 23) / 10 +
|
||||||
|
year / 4 - (year / 100 + 1) * 3 / 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* GetKey: Returns the ordinal value of the next key typed
|
||||||
|
* by the user.
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
int GetKey (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
char ch, *cp;
|
||||||
|
|
||||||
|
cp = (char *) 0x00C000; /* wait for keypress */
|
||||||
|
while ((*cp & 0x80) == 0) ;
|
||||||
|
ch = *cp; /* save the key */
|
||||||
|
cp = (char *) 0x00C010; /* clear the strobe */
|
||||||
|
*cp = 0;
|
||||||
|
return ch & 0x7F; /* return the key read */
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* GetThisMonth: Reads the clock to obtain today's month
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void GetThisMonth (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
time_t lt; /* encoded time */
|
||||||
|
struct tm *ct; /* current time */
|
||||||
|
|
||||||
|
lt = time(NULL); /* get the coded time */
|
||||||
|
ct = gmtime(<); /* convert to a decoded time */
|
||||||
|
year = ct->tm_year + 1900; /* set the month/year */
|
||||||
|
month = ct->tm_mon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* GotoXY: Positions the cursor
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void GotoXY (int x, int y)
|
||||||
|
|
||||||
|
{
|
||||||
|
putchar(0x1E);
|
||||||
|
putchar(0x20 + x);
|
||||||
|
putchar(0x20 + y);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* PrintCalendar: Prints the calendar for the current
|
||||||
|
* and year.
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void PrintCalendar (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
#define TAB 26 /* disp of calendar from left edge */
|
||||||
|
#define VTAB 5 /* disp of calendar from top */
|
||||||
|
|
||||||
|
int startDay, /* day of week for 1st day in month */
|
||||||
|
numDays, /* # days in the month */
|
||||||
|
nextMonth, nextYear, /* work variables */
|
||||||
|
i, /* loop variable */
|
||||||
|
vt, /* line # for next line of days */
|
||||||
|
pos; /* day position for next date */
|
||||||
|
|
||||||
|
/* Compute day of week for 1st day in month */
|
||||||
|
startDay = (int) ((Factor (year, month) - 1) % 7);
|
||||||
|
nextMonth = month+1; /* compute # days in month */
|
||||||
|
if (nextMonth == 12) {
|
||||||
|
nextMonth = 0;
|
||||||
|
nextYear = year+1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nextYear = year;
|
||||||
|
numDays = (int) (Factor (nextYear, nextMonth) - Factor (year, month));
|
||||||
|
|
||||||
|
putchar(12); /* clear the screen */
|
||||||
|
GotoXY(TAB+7, VTAB); /* position cursor */
|
||||||
|
switch (month) { /* write the month */
|
||||||
|
case 0: printf(" January "); break;
|
||||||
|
case 1: printf("February "); break;
|
||||||
|
case 2: printf(" March "); break;
|
||||||
|
case 3: printf(" April "); break;
|
||||||
|
case 4: printf(" May "); break;
|
||||||
|
case 5: printf(" June "); break;
|
||||||
|
case 6: printf(" July "); break;
|
||||||
|
case 7: printf(" August "); break;
|
||||||
|
case 8: printf("September "); break;
|
||||||
|
case 9: printf(" October "); break;
|
||||||
|
case 10: printf("November "); break;
|
||||||
|
case 11: printf("December ");
|
||||||
|
}
|
||||||
|
printf("%d", year); /* write the year */
|
||||||
|
GotoXY(TAB, VTAB+2); /* write the day header line */
|
||||||
|
printf("Sun Mon Tue Wed Thu Fri Sat");
|
||||||
|
vt = VTAB+4; /* set current date line */
|
||||||
|
pos = 0; /* set day position */
|
||||||
|
GotoXY(TAB-1, vt); /* position cursor for 1st line */
|
||||||
|
for (i = 1; i <= startDay; i++) { /* skip over blank days */
|
||||||
|
pos++;
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write the dates */
|
||||||
|
for (i = 1; i <= numDays; i++) {
|
||||||
|
printf("%4d", i);
|
||||||
|
pos++;
|
||||||
|
if (pos == 7) {
|
||||||
|
pos = 0;
|
||||||
|
vt += 2;
|
||||||
|
GotoXY(TAB-1, vt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GotoXY(25, 23); /* write instructions */
|
||||||
|
printf("Hit ? for help, or ESC to quit");
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* PrintHelp: Print the help screen.
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void PrintHelp (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
int ch; /* dummy variable for reading keyboard */
|
||||||
|
|
||||||
|
putchar(0x0C); /* clear screen */
|
||||||
|
printf( "This program recognizes the following single-keystroke commands:"
|
||||||
|
"\n\n"
|
||||||
|
" key action\n"
|
||||||
|
" --- ------\n"
|
||||||
|
" up-arrow Show the current month in the previous year.\n"
|
||||||
|
" down-arrow Show the current month in the next year.\n"
|
||||||
|
" left-arrow Show the previous month.\n"
|
||||||
|
" right-arrow Show the next month.\n"
|
||||||
|
" ESC exit the program.");
|
||||||
|
|
||||||
|
GotoXY(0, 23);
|
||||||
|
printf("Hit any key to return to the program.");
|
||||||
|
ch = GetKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************
|
||||||
|
*
|
||||||
|
* Start: Body of calendar program
|
||||||
|
*
|
||||||
|
**************************************************************/
|
||||||
|
|
||||||
|
void Start(void)
|
||||||
|
|
||||||
|
{
|
||||||
|
putchar('\006'); /* turn the cursor off */
|
||||||
|
GetThisMonth(); /* find out what month it is */
|
||||||
|
PrintCalendar(); /* print the calendar for this month */
|
||||||
|
do {
|
||||||
|
ch = GetKey(); /* get a command */
|
||||||
|
switch (ch) {
|
||||||
|
case LEFT_ARROW: {
|
||||||
|
month--;
|
||||||
|
if (month < 0) {
|
||||||
|
month = 11;
|
||||||
|
year--;
|
||||||
|
}
|
||||||
|
PrintCalendar();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case RIGHT_ARROW: {
|
||||||
|
month++;
|
||||||
|
if (month > 11) {
|
||||||
|
month = 0;
|
||||||
|
year++;
|
||||||
|
}
|
||||||
|
PrintCalendar();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case UP_ARROW: {
|
||||||
|
year--;
|
||||||
|
PrintCalendar();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case DOWN_ARROW: {
|
||||||
|
year++;
|
||||||
|
PrintCalendar();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case QUESTION:
|
||||||
|
case SLASH: {
|
||||||
|
PrintHelp();
|
||||||
|
PrintCalendar();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ESC: return;
|
||||||
|
|
||||||
|
default:
|
||||||
|
SysBeep();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************
|
||||||
|
*
|
||||||
|
* ShutDown: Does nothing
|
||||||
|
*
|
||||||
|
*************************************************************/
|
||||||
|
|
||||||
|
void ShutDown(void)
|
||||||
|
|
||||||
|
{
|
||||||
|
}
|
44
C.Samples/CDA.Samples/Echo.cc
Normal file
44
C.Samples/CDA.Samples/Echo.cc
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* Echo
|
||||||
|
*
|
||||||
|
* This is about the simplest a classic desk accessory can be,
|
||||||
|
* providing a quick framework for developing your own. It
|
||||||
|
* simply reads strings typed from the keyboard and echos
|
||||||
|
* them back to the screen.
|
||||||
|
*
|
||||||
|
* Mike Westerfield
|
||||||
|
*
|
||||||
|
* Copyright 1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Echo"
|
||||||
|
#pragma cda "Echo from C" Start ShutDown
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
char str[256];
|
||||||
|
|
||||||
|
|
||||||
|
void Start(void)
|
||||||
|
|
||||||
|
{
|
||||||
|
printf("This program echoes the strings you type from the keyboard. To\n");
|
||||||
|
printf("quit, hit the RETURN key at the beginning of a line.\n\n");
|
||||||
|
|
||||||
|
do {
|
||||||
|
fgets(str, 256, stdin); /* read a string */
|
||||||
|
printf("%s\n", str); /* write the same string */
|
||||||
|
}
|
||||||
|
while (strlen(str) > 1); /* quit if the string is empty */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ShutDown(void)
|
||||||
|
|
||||||
|
{
|
||||||
|
}
|
71
C.Samples/CDev.Samples/WorldCDev.cc
Normal file
71
C.Samples/CDev.Samples/WorldCDev.cc
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/****************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Hello World CDev */
|
||||||
|
/* */
|
||||||
|
/* Mike Westerfield */
|
||||||
|
/* October 1991 */
|
||||||
|
/* */
|
||||||
|
/* Copyright 1991 */
|
||||||
|
/* Byte Works, Inc. */
|
||||||
|
/* All Rights Reserved. */
|
||||||
|
/* */
|
||||||
|
/****************************************************************/
|
||||||
|
/* */
|
||||||
|
/* This CDev displays a text message. It can be used as a */
|
||||||
|
/* framework for developing your own CDevs. */
|
||||||
|
/* */
|
||||||
|
/* For detailed information about CDevs, see Apple II File */
|
||||||
|
/* Type Notes for file type $D8. Apple II File Type Notes */
|
||||||
|
/* are available from major online services, large users */
|
||||||
|
/* groups, or from APDA. */
|
||||||
|
/* */
|
||||||
|
/****************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "worldobj"
|
||||||
|
#pragma cdev Driver
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <types.h>
|
||||||
|
#include <control.h>
|
||||||
|
#include <quickdraw.h>
|
||||||
|
|
||||||
|
|
||||||
|
GrafPortPtr wPtr; /* our window pointer */
|
||||||
|
|
||||||
|
|
||||||
|
/* DoAbout - Show the help info */
|
||||||
|
|
||||||
|
void DoAbout (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
NewControl2(wPtr, 0x0009, 257L); /* draw the text (it's a stattext control) */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* DoCreate - Create the controls */
|
||||||
|
|
||||||
|
void DoCreate (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
NewControl2(wPtr, 0x0009, 256L); /* create the controls */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Driver - main entry point */
|
||||||
|
|
||||||
|
long Driver (long data2, long data1, int message)
|
||||||
|
|
||||||
|
#define createCDev 7 /* message numbers */
|
||||||
|
#define aboutCDev 8
|
||||||
|
|
||||||
|
{
|
||||||
|
wPtr = (void *) data1; /* get our window pointer (most calls) */
|
||||||
|
switch (message) {
|
||||||
|
case createCDev: DoCreate();
|
||||||
|
break;
|
||||||
|
case aboutCDev: DoAbout();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
3
C.Samples/CDev.Samples/WorldCDev.make
Normal file
3
C.Samples/CDev.Samples/WorldCDev.make
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
cmpl +t +e -x worldcdev.cc
|
||||||
|
compile +t +e worldcdev.rez keep=WorldCDev
|
||||||
|
filetype WorldCDev $C7
|
110
C.Samples/CDev.Samples/WorldCDev.rez
Normal file
110
C.Samples/CDev.Samples/WorldCDev.rez
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
#include "types.rez"
|
||||||
|
|
||||||
|
/* This is the required resource to tell the control panel about the CDev */
|
||||||
|
resource rCDEVFlags (0x1) {
|
||||||
|
0x00C0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
{0, 0, 110, 200},
|
||||||
|
"Hello World",
|
||||||
|
"Mike Westerfield",
|
||||||
|
"1.0"
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Code resource; the executable part of the CDev */
|
||||||
|
read rCDevCode (0x1,convert) "worldobj";
|
||||||
|
|
||||||
|
/* This is the icon displayed by the control panel */
|
||||||
|
resource rIcon (0x1) {
|
||||||
|
0x8000, /* color icon */
|
||||||
|
20, /* height in pixels */
|
||||||
|
28, /* width in pixels */
|
||||||
|
$"FFFFFFFFFFF1111111FFFFFFFFFF"
|
||||||
|
$"FFFFFFFF111111111111FFFFFFFF"
|
||||||
|
$"FFFFFF1111118881111881FFFFFF"
|
||||||
|
$"FFFFF111888888888818811FFFFF"
|
||||||
|
$"FFFF11118888888888118111FFFF"
|
||||||
|
$"FFF1111111888888811111111FFF"
|
||||||
|
$"FFF1111111888888111111111FFF"
|
||||||
|
$"FF111111111881181111111111FF"
|
||||||
|
$"FF111111111181111111111111FF"
|
||||||
|
$"FF111111111181111111111111FF"
|
||||||
|
$"FF111111118888881111111111FF"
|
||||||
|
$"FF111111118888888111111111FF"
|
||||||
|
$"FFF1111111888888811111111FFF"
|
||||||
|
$"FFF1111111188888111111111FFF"
|
||||||
|
$"FFFF11111111888811111111FFFF"
|
||||||
|
$"FFFFF111111118811111111FFFFF"
|
||||||
|
$"FFFFFF1111111181111111FFFFFF"
|
||||||
|
$"FFFFFFFF111111111111FFFFFFFF"
|
||||||
|
$"FFFFFFFFFF11111111FFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||||
|
|
||||||
|
$"00000000000FFFFFFF0000000000"
|
||||||
|
$"00000000FFFFFFFFFFFF00000000"
|
||||||
|
$"000000FFFFFFFFFFFFFFFF000000"
|
||||||
|
$"00000FFFFFFFFFFFFFFFFFF00000"
|
||||||
|
$"0000FFFFFFFFFFFFFFFFFFFF0000"
|
||||||
|
$"000FFFFFFFFFFFFFFFFFFFFFF000"
|
||||||
|
$"000FFFFFFFFFFFFFFFFFFFFFF000"
|
||||||
|
$"00FFFFFFFFFFFFFFFFFFFFFFFF00"
|
||||||
|
$"00FFFFFFFFFFFFFFFFFFFFFFFF00"
|
||||||
|
$"00FFFFFFFFFFFFFFFFFFFFFFFF00"
|
||||||
|
$"00FFFFFFFFFFFFFFFFFFFFFFFF00"
|
||||||
|
$"00FFFFFFFFFFFFFFFFFFFFFFFF00"
|
||||||
|
$"000FFFFFFFFFFFFFFFFFFFFFF000"
|
||||||
|
$"000FFFFFFFFFFFFFFFFFFFFFF000"
|
||||||
|
$"0000FFFFFFFFFFFFFFFFFFFF0000"
|
||||||
|
$"00000FFFFFFFFFFFFFFFFFF00000"
|
||||||
|
$"000000FFFFFFFFFFFFFFFF000000"
|
||||||
|
$"00000000FFFFFFFFFFFF00000000"
|
||||||
|
$"0000000000FFFFFFFF0000000000"
|
||||||
|
$"0000000000000000000000000000"
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The following resources define the various controls in the main display */
|
||||||
|
resource rControlList (256) {
|
||||||
|
{
|
||||||
|
256,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
resource rControlTemplate (256) {
|
||||||
|
0x00000001, /* control id */
|
||||||
|
{38,5,49,205}, /* control rectangle */
|
||||||
|
statTextControl {{ /* control type */
|
||||||
|
0x0000, /* flags */
|
||||||
|
0x1002, /* more flags */
|
||||||
|
0, /* ref con */
|
||||||
|
256, /* text reference */
|
||||||
|
13 /* text length */
|
||||||
|
}};
|
||||||
|
};
|
||||||
|
resource rTextForLETextBox2 (256) {
|
||||||
|
"Hello, world."
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The following resources define the controls for the help screen */
|
||||||
|
resource rControlList (257) {
|
||||||
|
{
|
||||||
|
257,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
resource rControlTemplate (257) {
|
||||||
|
0x00000002, /* control id */
|
||||||
|
{38,5,49,205}, /* control rectangle */
|
||||||
|
statTextControl {{ /* control type */
|
||||||
|
0x0000, /* flags */
|
||||||
|
0x1002, /* more flags */
|
||||||
|
0, /* ref con */
|
||||||
|
257, /* text reference */
|
||||||
|
19 /* text length */
|
||||||
|
}};
|
||||||
|
};
|
||||||
|
resource rTextForLETextBox2 (257) {
|
||||||
|
"Put help info here."
|
||||||
|
};
|
||||||
|
|
163
C.Samples/Desktop.Samples/Clock.cc
Normal file
163
C.Samples/Desktop.Samples/Clock.cc
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
/**************************************************************
|
||||||
|
*
|
||||||
|
* This desk accessory brings up a simple clock. It can be
|
||||||
|
* used as an outline when creating more complex desk accessories.
|
||||||
|
*
|
||||||
|
* Original Pascal version by Phil Montoya
|
||||||
|
* C Translation by Mike Westerfield
|
||||||
|
*
|
||||||
|
* Copyright 1987,1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
**************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Clock"
|
||||||
|
#pragma nda Open Close Action Init 60 0xFFFF "--Clock\\H**"
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include <quickdraw.h>
|
||||||
|
#include <misctool.h>
|
||||||
|
#include <event.h>
|
||||||
|
#include <desk.h>
|
||||||
|
#include <window.h>
|
||||||
|
|
||||||
|
#define TRUE 1 /* boolean constants */
|
||||||
|
#define FALSE 0
|
||||||
|
|
||||||
|
int clockActive = 0; /* are we already active flag */
|
||||||
|
GrafPortPtr clockWinPtr; /* window pointer */
|
||||||
|
|
||||||
|
char title[] = "\pClock"; /* window title */
|
||||||
|
ParamList clockWin = { /* new window record */
|
||||||
|
78, /* paramLength */
|
||||||
|
0xC0A0, /* wFrameBits */
|
||||||
|
title, /* wTitle */
|
||||||
|
0L, /* wRefCon */
|
||||||
|
{0,0,0,0}, /* wZoom */
|
||||||
|
NULL, /* wColor */
|
||||||
|
0,0, /* wYOrigin,wXOrigin */
|
||||||
|
0,0, /* wDataH,wDataW */
|
||||||
|
0,0, /* wMaxH,wMaxW */
|
||||||
|
0,0, /* wScrollVer,wScrollHor */
|
||||||
|
0,0, /* wPageVer,wPageHor */
|
||||||
|
0, /* wInfoRefCon */
|
||||||
|
0, /* wInfoHeight */
|
||||||
|
NULL, /* wFrameDefProc */
|
||||||
|
NULL, /* wInfoDefProc */
|
||||||
|
NULL, /* wContDefProc */
|
||||||
|
{50,50,62,200}, /* wPosition */
|
||||||
|
(void *) -1L, /* wPlane */
|
||||||
|
NULL /* wStorage */
|
||||||
|
};
|
||||||
|
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* DrawTime - Reads the time and draws it in the window
|
||||||
|
*
|
||||||
|
***************************************************************/
|
||||||
|
|
||||||
|
void DrawTime (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
int i; /* index variable */
|
||||||
|
char timeString[21]; /* string to hold time */
|
||||||
|
|
||||||
|
ReadAsciiTime(timeString);
|
||||||
|
timeString[20] = 0;
|
||||||
|
for (i = 0; i < 20; i++)
|
||||||
|
timeString[i] &= 0x7F;
|
||||||
|
MoveTo(7, 10);
|
||||||
|
DrawCString(timeString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* Open - opens the desk accessory if it is not already active
|
||||||
|
*
|
||||||
|
* Outputs:
|
||||||
|
* GrafPortPtr - pointer to desk accessory window
|
||||||
|
*
|
||||||
|
***************************************************************/
|
||||||
|
|
||||||
|
GrafPortPtr Open (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
if (!clockActive) {
|
||||||
|
clockWinPtr = NewWindow(&clockWin); /* open a window */
|
||||||
|
SetSysWindow(clockWinPtr); /* set it to the system window */
|
||||||
|
clockActive = TRUE; /* we are now active */
|
||||||
|
return clockWinPtr; /* return our window pointer */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* Close - closes the desk accessory if it is active
|
||||||
|
*
|
||||||
|
***************************************************************/
|
||||||
|
|
||||||
|
void Close(void)
|
||||||
|
|
||||||
|
{
|
||||||
|
if (clockActive) {
|
||||||
|
CloseWindow(clockWinPtr);
|
||||||
|
clockActive = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* Action - Handle an action call
|
||||||
|
*
|
||||||
|
***************************************************************/
|
||||||
|
|
||||||
|
void Action (long param, int code)
|
||||||
|
|
||||||
|
{
|
||||||
|
EventRecordPtr evPtr;
|
||||||
|
GrafPortPtr currPort;
|
||||||
|
|
||||||
|
switch (code) {
|
||||||
|
|
||||||
|
case eventAction: {
|
||||||
|
evPtr = (EventRecordPtr) param;
|
||||||
|
if (evPtr->what == updateEvt) {
|
||||||
|
BeginUpdate(clockWinPtr);
|
||||||
|
DrawTime();
|
||||||
|
EndUpdate(clockWinPtr);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
case runAction: {
|
||||||
|
currPort = GetPort();
|
||||||
|
SetPort(clockWinPtr);
|
||||||
|
DrawTime();
|
||||||
|
SetPort(currPort);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* Initialization
|
||||||
|
*
|
||||||
|
***************************************************************/
|
||||||
|
|
||||||
|
void Init(int code)
|
||||||
|
|
||||||
|
{
|
||||||
|
if (code == 0) {
|
||||||
|
if (clockActive)
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
clockActive = FALSE;
|
||||||
|
}
|
199
C.Samples/Desktop.Samples/Frame.cc
Normal file
199
C.Samples/Desktop.Samples/Frame.cc
Normal file
|
@ -0,0 +1,199 @@
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* Frame
|
||||||
|
*
|
||||||
|
* This desktop program is about as simple as they get. It
|
||||||
|
* brings up the Apple menu, a file menu with Quit and Close,
|
||||||
|
* and an edit menu with Undo, Cut, Copy, Paste and Clear.
|
||||||
|
* This is the minimum configuration for supporting desk
|
||||||
|
* accessories. (All of these menus have pre-assigned numbers,
|
||||||
|
* assigned by Apple.)
|
||||||
|
*
|
||||||
|
* The purpose of this rather simple program is to show how
|
||||||
|
* easy a desktop program can be to write, and to give you a
|
||||||
|
* framework to use in developing your own programs.
|
||||||
|
*
|
||||||
|
* Mike Westerfield
|
||||||
|
*
|
||||||
|
* Copyright 1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Frame"
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <orca.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <types.h>
|
||||||
|
#include <quickdraw.h>
|
||||||
|
#include <misctool.h>
|
||||||
|
#include <event.h>
|
||||||
|
#include <control.h>
|
||||||
|
#include <window.h>
|
||||||
|
#include <menu.h>
|
||||||
|
#include <desk.h>
|
||||||
|
#include <lineedit.h>
|
||||||
|
#include <dialog.h>
|
||||||
|
|
||||||
|
#define apple_About 257 /* Menu ID numbers */
|
||||||
|
#define file_Quit 256
|
||||||
|
|
||||||
|
enum alertKind {norml, stop, note, caution}; /* kinds of alerts */
|
||||||
|
|
||||||
|
typedef int BOOL; /* simulate boolean types */
|
||||||
|
BOOL done; /* tells if the program should stop */
|
||||||
|
WmTaskRec lastEvent; /* last event returned in event loop */
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* DoAlert - Create an alert box
|
||||||
|
*
|
||||||
|
* Input:
|
||||||
|
* kind - kind of alert
|
||||||
|
* msg - alert message
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void DoAlert (enum alertKind kind, char *msg)
|
||||||
|
|
||||||
|
{
|
||||||
|
static ItemTemplate button = /* button item */
|
||||||
|
{ 1, 36, 15, 0, 0, buttonItem, "\pOK", 0, 0, NULL };
|
||||||
|
|
||||||
|
static ItemTemplate message = /* message item */
|
||||||
|
{ 100, 5, 100, 90, 280, itemDisable+statText, NULL, 0, 0, NULL };
|
||||||
|
|
||||||
|
static AlertTemplate alertRec = /* alert box */
|
||||||
|
{ 50, 180, 107, 460, 2, 0x80, 0x80, 0x80, 0x80, NULL, NULL, NULL };
|
||||||
|
|
||||||
|
|
||||||
|
SetForeColor (0); /* set text colors */
|
||||||
|
SetBackColor (15);
|
||||||
|
|
||||||
|
message.itemDescr = msg; /* init. non-constant */
|
||||||
|
alertRec.atItemList [0] = (ItemTempPtr) &button; /* template fields */
|
||||||
|
alertRec.atItemList [1] = (ItemTempPtr) &message;
|
||||||
|
|
||||||
|
switch (kind) {
|
||||||
|
case norml: Alert (&alertRec, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case stop: StopAlert (&alertRec, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case note: NoteAlert (&alertRec, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case caution: CautionAlert (&alertRec, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: printf ("Error in DoAlert\n");
|
||||||
|
exit (-1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* MenuAbout - Create the About menu
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void MenuAbout (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
DoAlert (note, "\pFrame 1.0\r"
|
||||||
|
"Copyright 1989\r"
|
||||||
|
"Byte Works, Inc.\r\r"
|
||||||
|
"By Mike Westerfield");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* HandleMenu - Handle a menu selection
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void HandleMenu (int menuNum)
|
||||||
|
|
||||||
|
{
|
||||||
|
switch (menuNum) {
|
||||||
|
case apple_About: MenuAbout ();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case file_Quit: done = TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
HiliteMenu (FALSE, (int) (lastEvent.wmTaskData >> 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* InitMenus - Initialize the menu bar
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void InitMenus (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
InsertMenu (NewMenu (">> Edit \\N3\r" /* create the edit menu */
|
||||||
|
"--Undo\\N250V*Zz\r"
|
||||||
|
"--Cut\\N251*Xx\r"
|
||||||
|
"--Copy\\N252*Cc\r"
|
||||||
|
"--Paste\\N253*Vv\r"
|
||||||
|
"--Clear\\N254\r"
|
||||||
|
".\r"), 0);
|
||||||
|
|
||||||
|
InsertMenu (NewMenu (">> File \\N2\r" /* create the file menu */
|
||||||
|
"--Close\\N255V\r"
|
||||||
|
"--Quit\\N256*Qq\r"
|
||||||
|
".\r"), 0);
|
||||||
|
|
||||||
|
InsertMenu (NewMenu (">>@\\XN1\r" /* create the Apple menu */
|
||||||
|
"--About Frame\\N257V\r"
|
||||||
|
".\r"), 0);
|
||||||
|
|
||||||
|
FixAppleMenu (1); /* add desk accessories */
|
||||||
|
FixMenuBar (); /* draw the completed menu bar */
|
||||||
|
DrawMenuBar ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* Main Program
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
int event; /* event # returned by TaskMaster */
|
||||||
|
|
||||||
|
startdesk (640);
|
||||||
|
InitMenus (); /* set up the menu bar */
|
||||||
|
lastEvent.wmTaskMask = 0x1FFFL; /* let Task Master do most stuff */
|
||||||
|
ShowCursor (); /* show the cursor */
|
||||||
|
|
||||||
|
done = FALSE; /* main event loop */
|
||||||
|
do {
|
||||||
|
event = TaskMaster (0x076E, &lastEvent);
|
||||||
|
switch (event) { /* handle the events we need to */
|
||||||
|
case wInSpecial:
|
||||||
|
case wInMenuBar: HandleMenu ((int) lastEvent.wmTaskData);
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (!done);
|
||||||
|
enddesk ();
|
||||||
|
}
|
374
C.Samples/Desktop.Samples/MiniCAD.cc
Normal file
374
C.Samples/Desktop.Samples/MiniCAD.cc
Normal file
|
@ -0,0 +1,374 @@
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* MiniCAD
|
||||||
|
*
|
||||||
|
* MiniCAD is a (very) simple CAD program based on the Frame
|
||||||
|
* program. With MiniCAD, you can open new windows, close
|
||||||
|
* windows that are on the desktop, and draw lines using the
|
||||||
|
* mouse. Multiple windows are supported.
|
||||||
|
*
|
||||||
|
* Mike Westerfield
|
||||||
|
*
|
||||||
|
* Copyright 1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "MiniCAD"
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <orca.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <types.h>
|
||||||
|
#include <quickdraw.h>
|
||||||
|
#include <misctool.h>
|
||||||
|
#include <event.h>
|
||||||
|
#include <control.h>
|
||||||
|
#include <window.h>
|
||||||
|
#include <menu.h>
|
||||||
|
#include <desk.h>
|
||||||
|
#include <lineedit.h>
|
||||||
|
#include <dialog.h>
|
||||||
|
|
||||||
|
#define apple_About 257 /* Menu ID #s */
|
||||||
|
#define file_Quit 256
|
||||||
|
#define file_New 258
|
||||||
|
#define file_Close 255
|
||||||
|
|
||||||
|
#define maxWindows 4 /* max # of drawing windows */
|
||||||
|
#define maxLines 50 /* max # of lines in a window */
|
||||||
|
|
||||||
|
typedef int BOOL; /* simulate boolean types */
|
||||||
|
typedef struct { Point p1, p2; } lineRecord; /* line defined by its endpts */
|
||||||
|
|
||||||
|
/* holds info about 1 window */
|
||||||
|
struct windowRecord { GrafPortPtr wPtr; /* ptr to the window's port */
|
||||||
|
char *name; /* name of the window */
|
||||||
|
int numLines; /* # lines in this window */
|
||||||
|
lineRecord lines [maxLines]; /* lines in drawing */
|
||||||
|
};
|
||||||
|
|
||||||
|
enum alertKind {norml, stop, note, caution}; /* kinds of alerts */
|
||||||
|
|
||||||
|
BOOL done; /* tells if the program should stop */
|
||||||
|
WmTaskRec lastEvent; /* last event returned in event loop */
|
||||||
|
|
||||||
|
static struct windowRecord windows [maxWindows] = /* drawing windows */
|
||||||
|
{ { NULL, "\pPaint 1" }, { NULL, "\pPaint 2" },
|
||||||
|
{ NULL, "\pPaint 3" }, { NULL, "\pPaint 4" } };
|
||||||
|
|
||||||
|
static ParamList wParms = /* parameters for NewWindow */
|
||||||
|
{ 78, 0xDDA7, NULL, 0, 0, 615, 25, 188, NULL, 0, 0, 0, 0, 0, 0, 10, 10,
|
||||||
|
0, 0, 0, 0, NULL, NULL, NULL, 25, 0, 188, 615, NULL, NULL };
|
||||||
|
|
||||||
|
static ItemTemplate button = /* button item */
|
||||||
|
{ 1, 36, 15, 0, 0, buttonItem, "\pOK", 0, 0, NULL };
|
||||||
|
|
||||||
|
static ItemTemplate message = /* message item */
|
||||||
|
{ 100, 5, 100, 90, 280, itemDisable+statText, NULL, 0, 0, NULL };
|
||||||
|
|
||||||
|
static AlertTemplate alertRec = /* alert box */
|
||||||
|
{ 50, 180, 107, 460, 2, 0x80, 0x80, 0x80, 0x80, NULL, NULL, NULL };
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* DoAlert - Create an alert box
|
||||||
|
*
|
||||||
|
* Input:
|
||||||
|
* kind - kind of alert
|
||||||
|
* msg - alert message
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void DoAlert (enum alertKind kind, char *msg)
|
||||||
|
|
||||||
|
{
|
||||||
|
SetForeColor (0); /* set text colors */
|
||||||
|
SetBackColor (15);
|
||||||
|
|
||||||
|
message.itemDescr = msg; /* init. non-constant */
|
||||||
|
alertRec.atItemList [0] = (ItemTempPtr) &button; /* template fields */
|
||||||
|
alertRec.atItemList [1] = (ItemTempPtr) &message;
|
||||||
|
|
||||||
|
switch (kind) {
|
||||||
|
case norml: Alert (&alertRec, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case stop: StopAlert (&alertRec, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case note: NoteAlert (&alertRec, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case caution: CautionAlert (&alertRec, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: printf ("Error in DoAlert\n");
|
||||||
|
exit (-1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma databank 1
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* DrawWindow - Draw the contents of the current window
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void DrawWindow (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
int i; /* window's index */
|
||||||
|
int j; /* loop variable */
|
||||||
|
|
||||||
|
struct windowRecord *wp; /* work pointers */
|
||||||
|
lineRecord *lp;
|
||||||
|
|
||||||
|
i = GetWRefCon (GetPort());
|
||||||
|
if (windows [i].numLines) { /* skip the work if there */
|
||||||
|
/* aren't any lines */
|
||||||
|
SetPenMode (modeCopy); /* set up to draw */
|
||||||
|
SetSolidPenPat (0);
|
||||||
|
SetPenSize (2, 1);
|
||||||
|
wp = &windows [i]; /* draw each of the lines */
|
||||||
|
for (j = 0; j < wp->numLines; ++j) {
|
||||||
|
lp = &(wp->lines [j]);
|
||||||
|
MoveTo (lp->p1.h, lp->p1.v);
|
||||||
|
LineTo (lp->p2.h, lp->p2.v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma databank 0
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* DoClose - Close the front drawing window, if there is one
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void DoClose (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (FrontWindow () != NULL) {
|
||||||
|
i = GetWRefCon (FrontWindow ());
|
||||||
|
CloseWindow (windows [i].wPtr);
|
||||||
|
windows [i].wPtr = NULL;
|
||||||
|
EnableMItem (file_New);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* MenuAbout - Create the About alert box
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void MenuAbout (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
DoAlert (note, "\pMini-CAD 1.0\r"
|
||||||
|
"Copyright 1989\r"
|
||||||
|
"Byte Works, Inc.\r\r"
|
||||||
|
"By Mike Westerfield");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* DoNew - Open a new drawing window
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void DoNew (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
int i; /* index variable */
|
||||||
|
|
||||||
|
i = 0; /* find an empty record */
|
||||||
|
while (windows[i].wPtr != NULL)
|
||||||
|
++i;
|
||||||
|
windows[i].numLines = 0; /* no lines drawn yet */
|
||||||
|
|
||||||
|
wParms.wTitle = (Pointer) windows[i].name; /* init. non-constant */
|
||||||
|
wParms.wRefCon = i; /* wParms fields */
|
||||||
|
wParms.wContDefProc = (VoidProcPtr) DrawWindow;
|
||||||
|
wParms.wPlane = (GrafPortPtr) topMost;
|
||||||
|
|
||||||
|
windows[i].wPtr = NewWindow (&wParms); /* open the window */
|
||||||
|
if (toolerror()) {
|
||||||
|
DoAlert (stop, "\pError opening the window.");
|
||||||
|
windows [i].wPtr = NULL;
|
||||||
|
}
|
||||||
|
else if (i == 3) /* don't allow more than 4 open windows */
|
||||||
|
DisableMItem (file_New);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* HandleMenu - Handle a menu selection
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void HandleMenu (int menuNum)
|
||||||
|
|
||||||
|
{
|
||||||
|
switch (menuNum) {
|
||||||
|
case apple_About: MenuAbout();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case file_Quit: done = TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case file_New: DoNew ();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case file_Close: DoClose ();
|
||||||
|
}
|
||||||
|
HiliteMenu (FALSE, (int) (lastEvent.wmTaskData >> 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* InitMenus - Initialize the menu bar
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void InitMenus (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
InsertMenu (NewMenu (">> Edit \\N3\r" /* create the edit menu */
|
||||||
|
"--Undo\\N250V*Zz\r"
|
||||||
|
"--Cut\\N251*Xx\r"
|
||||||
|
"--Copy\\N252*Cc\r"
|
||||||
|
"--Paste\\N253*Vv\r"
|
||||||
|
"--Clear\\N254\r"
|
||||||
|
".\r"), 0);
|
||||||
|
|
||||||
|
InsertMenu (NewMenu (">> File \\N2\r" /* create the file menu */
|
||||||
|
"--New\\N258*Nn\r"
|
||||||
|
"--Close\\N255V\r"
|
||||||
|
"--Quit\\N256*Qq\r"
|
||||||
|
".\r"), 0);
|
||||||
|
|
||||||
|
InsertMenu (NewMenu (">>@\\XN1\r" /* create the Apple menu */
|
||||||
|
"--About...\\N257V\r"
|
||||||
|
".\r"), 0);
|
||||||
|
|
||||||
|
FixAppleMenu (1); /* add desk accessories */
|
||||||
|
FixMenuBar (); /* draw the completed menu bar */
|
||||||
|
DrawMenuBar ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* Sketch - Track the mouse, drawing lines to connect the points
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void Sketch (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
Point endPoint; /* the end point of the line */
|
||||||
|
Point firstPoint; /* the initial point */
|
||||||
|
int i; /* window index */
|
||||||
|
int numLines; /* copy of windows [i].numLines */
|
||||||
|
EventRecord sEvent; /* last event returned in event loop */
|
||||||
|
|
||||||
|
/* get the window's index */
|
||||||
|
i = GetWRefCon (FrontWindow());
|
||||||
|
|
||||||
|
/* check for too many lines */
|
||||||
|
if (windows [i].numLines == maxLines)
|
||||||
|
DoAlert (stop, "\pThe window is full -\rmore lines cannot be\radded.");
|
||||||
|
else {
|
||||||
|
/* initialize the pen */
|
||||||
|
StartDrawing (FrontWindow());
|
||||||
|
SetSolidPenPat (15);
|
||||||
|
SetPenSize (2, 1);
|
||||||
|
SetPenMode (modeXOR);
|
||||||
|
|
||||||
|
/* record the initial pen location */
|
||||||
|
firstPoint = lastEvent.where;
|
||||||
|
GlobalToLocal (&firstPoint);
|
||||||
|
MoveTo (firstPoint.h, firstPoint.v);
|
||||||
|
LineTo (firstPoint.h, firstPoint.v);
|
||||||
|
endPoint = firstPoint;
|
||||||
|
|
||||||
|
/* follow the pen, rubber-banding the line */
|
||||||
|
while (!GetNextEvent (mUpMask, &sEvent)) {
|
||||||
|
GlobalToLocal (&sEvent.where);
|
||||||
|
if ((endPoint.h != sEvent.where.h) || (endPoint.v != sEvent.where.v)) {
|
||||||
|
MoveTo (firstPoint.h, firstPoint.v);
|
||||||
|
LineTo (endPoint.h, endPoint.v);
|
||||||
|
MoveTo (firstPoint.h, firstPoint.v);
|
||||||
|
LineTo (sEvent.where.h, sEvent.where.v);
|
||||||
|
endPoint.h = sEvent.where.h;
|
||||||
|
endPoint.v = sEvent.where.v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* erase the last XORed line */
|
||||||
|
MoveTo (firstPoint.h, firstPoint.v);
|
||||||
|
LineTo (endPoint.h, endPoint.v);
|
||||||
|
|
||||||
|
/* if we have a line (not a point), record it in window's line list */
|
||||||
|
if ((firstPoint.h != endPoint.h) || (firstPoint.v != endPoint.v)) {
|
||||||
|
numLines = windows[i].numLines++;
|
||||||
|
windows [i].lines [numLines].p1 = firstPoint;
|
||||||
|
windows [i].lines [numLines].p2 = endPoint;
|
||||||
|
SetPenMode (modeCopy);
|
||||||
|
SetSolidPenPat (0);
|
||||||
|
MoveTo (firstPoint.h, firstPoint.v);
|
||||||
|
LineTo (endPoint.h, endPoint.v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* Program begins here
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
int event; /* event #; returned by TaskMaster */
|
||||||
|
|
||||||
|
startdesk (640);
|
||||||
|
InitMenus (); /* set up the menu bar */
|
||||||
|
lastEvent.wmTaskMask = 0x1FFFL; /* let task master do most stuff */
|
||||||
|
ShowCursor (); /* show the cursor */
|
||||||
|
|
||||||
|
done = FALSE; /* main event loop */
|
||||||
|
do {
|
||||||
|
event = TaskMaster (0x076E, &lastEvent);
|
||||||
|
switch (event) { /* handle the events we need to */
|
||||||
|
case wInSpecial:
|
||||||
|
case wInMenuBar: HandleMenu ((int) lastEvent.wmTaskData);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wInGoAway : DoClose ();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wInContent: Sketch ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (!done);
|
||||||
|
enddesk ();
|
||||||
|
return 0;
|
||||||
|
}
|
1626
C.Samples/Desktop.Samples/Reversi.cc
Normal file
1626
C.Samples/Desktop.Samples/Reversi.cc
Normal file
File diff suppressed because it is too large
Load Diff
167
C.Samples/Graphic.Samples/Bounce.cc
Normal file
167
C.Samples/Graphic.Samples/Bounce.cc
Normal file
|
@ -0,0 +1,167 @@
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* A simple graphics demo.
|
||||||
|
*
|
||||||
|
* By Phil Montoya and Barbara Allred
|
||||||
|
*
|
||||||
|
* Copyright 1987-1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Bounce"
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <quickdraw.h>
|
||||||
|
#include <orca.h>
|
||||||
|
|
||||||
|
#define screenMode 640 /* 640x200 graphics Super HiRes display mode */
|
||||||
|
#define copyMode 0 /* pen copy mode */
|
||||||
|
#define size 6 /* number of points */
|
||||||
|
|
||||||
|
/* Global variables */
|
||||||
|
|
||||||
|
static int curColor = white; /* pen color */
|
||||||
|
static int curSize = 1; /* no. points-1 */
|
||||||
|
static int x[size]; /* initial points */
|
||||||
|
static int y[size];
|
||||||
|
static int xv[size], yv[size]; /* move and velocity arrays */
|
||||||
|
static int maxX, maxY; /* max X, Y coordinates */
|
||||||
|
static int minX, minY; /* min X, Y coordinates */
|
||||||
|
static Rect r; /* drawing rectangle */
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* UpDate - Updates x and y by velocity factors and changes
|
||||||
|
* direction if necessary
|
||||||
|
*
|
||||||
|
* Inputs:
|
||||||
|
* px - X location
|
||||||
|
* pxv - X velocity
|
||||||
|
* py - Y location
|
||||||
|
* pyv - Y velocity
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void UpDate (int *px, int *pxv, int *py, int *pyv)
|
||||||
|
|
||||||
|
{
|
||||||
|
*px += *pxv; /* move x by velocity factor */
|
||||||
|
if ((*px < minX) || (*px > maxX)) { /* if x is beyond border... */
|
||||||
|
*px -= *pxv; /* ...move back */
|
||||||
|
*pxv = -(*pxv); /* ...change directions */
|
||||||
|
}
|
||||||
|
*py += *pyv; /* move y by velocity factor */
|
||||||
|
if ((*py < minY) || (*py > maxY)) { /* if y is beyond border... */
|
||||||
|
*py -= *pyv; /* ...move back */
|
||||||
|
*pyv = -(*pyv); /* ...change directions */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* NextPenColor - Changes the pen color
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void NextPenColor (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
curColor++; /* get next color */
|
||||||
|
if (curColor > white) /* if out of colors then start over */
|
||||||
|
curColor = black;
|
||||||
|
SetSolidPenPat(curColor); /* set the pen to this color */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* Initialize - initialization for program
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void Initialize (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
SetPenSize(4, 2); /* use a fatter pen */
|
||||||
|
SetPenMode(copyMode); /* use the copy pen mode */
|
||||||
|
GetPortRect(&r);
|
||||||
|
maxX = r.h2; maxY = r.v2; /* don't go beyond screen edges */
|
||||||
|
minX = r.h1; minY = r.v1;
|
||||||
|
|
||||||
|
i = maxX - minX; /* set initial points */
|
||||||
|
j = maxX >> 1;
|
||||||
|
x[0] = minX + j + 20; x[1] = minX + j - 20;
|
||||||
|
x[2] = x[3] = x[4] = x[5] = minX + j;
|
||||||
|
|
||||||
|
i = maxY - minY;
|
||||||
|
j = maxY >> 1;
|
||||||
|
y[3] = minY + j + 10; y[4] = minY + j - 10;
|
||||||
|
y[0] = y[1] = y[2] = y[5] = minY + j;
|
||||||
|
|
||||||
|
for (i = 0, j = 6; i < size; i++) { /* set velocity factors */
|
||||||
|
if (i & 0x0001) /* if i is odd... */
|
||||||
|
j = -j;
|
||||||
|
yv [i] = j;
|
||||||
|
xv [i] = -j;
|
||||||
|
j -= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* DrawShapes - This is the engine of the demo.
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
void DrawShapes (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
int i, j, k;
|
||||||
|
|
||||||
|
for (k = white; k >= black; k--) { /* cycle thru 16 screens */
|
||||||
|
SetSolidPenPat(k); /* set the background color */
|
||||||
|
PaintRect(&r);
|
||||||
|
|
||||||
|
/* The number of shapes per screen depends on the size of the shape. */
|
||||||
|
/* The more points a shape has the less times it will be drawn and */
|
||||||
|
/* vice-versa. This keeps the time and density per screen approximately */
|
||||||
|
/* the same. */
|
||||||
|
|
||||||
|
for (i = 0; i < (((size-curSize) * 38) + 75); i++) {
|
||||||
|
/* draw this series of shapes */
|
||||||
|
NextPenColor (); /* change pen colors */
|
||||||
|
MoveTo (x[curSize], y[curSize]); /* initial from position */
|
||||||
|
UpDate (x+curSize, xv+curSize, y+curSize, yv+curSize);
|
||||||
|
for (j = 0; j < curSize; j++) { /* draw this shape */
|
||||||
|
LineTo (x[j], y[j]);
|
||||||
|
UpDate (x+j, xv+j, y+j, yv+j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
curSize++; /* next shape size */
|
||||||
|
if (curSize == size)
|
||||||
|
curSize = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* Program Begins Here
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
startgraph(screenMode); /* set up graphics screen */
|
||||||
|
Initialize(); /* initialize global data */
|
||||||
|
DrawShapes(); /* draw the shapes */
|
||||||
|
endgraph(); /* shut down the graphics screen */
|
||||||
|
return 0;
|
||||||
|
}
|
94
C.Samples/Graphic.Samples/CallGSOS.cc
Normal file
94
C.Samples/Graphic.Samples/CallGSOS.cc
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
/*****************************************************************
|
||||||
|
*
|
||||||
|
* Call GS/OS
|
||||||
|
*
|
||||||
|
* This program shows how to call GS/OS directly. You should
|
||||||
|
* compare it with callp16.cc, which shows how to call ProDOS 16
|
||||||
|
* (an older operating system that is now a subset of GS/OS).
|
||||||
|
*
|
||||||
|
* This program dumps the contents of a screen image file to the
|
||||||
|
* graphics screen. It is assumed that the program callp16 was
|
||||||
|
* executed prior to running this program, and that you have
|
||||||
|
* made a note of the filename containing the screen dump that
|
||||||
|
* was created by callp16.
|
||||||
|
*
|
||||||
|
* DO NOT EXECUTE THIS PROGRAM FROM THE DESKTOP. It uses non-
|
||||||
|
* standard mechanisms for accessing the graphics screen.
|
||||||
|
*
|
||||||
|
* By Barbara Allred and Mike Westerfield
|
||||||
|
*
|
||||||
|
* Copyright 1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
*******************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "CallGSOS"
|
||||||
|
#pragma debug 1 /* check stack overflows */
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <types.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <orca.h>
|
||||||
|
#include <quickdraw.h>
|
||||||
|
#include <gsos.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define SCREENWIDTH 320 /* screen width in pixels */
|
||||||
|
|
||||||
|
static GSString255 filename; /* name of file having screen contents */
|
||||||
|
|
||||||
|
/* Data Control Blocks for GS/OS calls */
|
||||||
|
OpenRecGS openDCB = { 15, 0, NULL, 1, 0};
|
||||||
|
IORecGS readDCB = { 5, 0, (void *) 0x00E12000, 32768L, 0L, 0 };
|
||||||
|
RefNumRecGS closeDCB = { 1, 0 };
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Prompt user for the name of the file to load. */
|
||||||
|
printf ("Please enter the name of the file containing the screen image:\n");
|
||||||
|
scanf ("%s", filename.text);
|
||||||
|
filename.length = strlen(filename.text);
|
||||||
|
|
||||||
|
/* Initialize the pen and graphics screen. */
|
||||||
|
startgraph(SCREENWIDTH); /* start QuickDraw II */
|
||||||
|
SetPenSize(4, 2); /* use fatter pen */
|
||||||
|
|
||||||
|
/* Open the file and then write its contents to the graphics screen. */
|
||||||
|
openDCB.pathname = &filename; /* open the file */
|
||||||
|
OpenGS(&openDCB);
|
||||||
|
if (i = toolerror()) {
|
||||||
|
MoveTo(50, 100);
|
||||||
|
SetSolidPenPat(black);
|
||||||
|
sprintf(str, "Unable to open file for screen dump: err = %d\n", i);
|
||||||
|
DrawCString(str);
|
||||||
|
goto Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
readDCB.refNum = openDCB.refNum; /* read the file, sending */
|
||||||
|
ReadGS(&readDCB); /* contents to screen */
|
||||||
|
if (i = toolerror()) {
|
||||||
|
MoveTo(50, 100);
|
||||||
|
SetSolidPenPat(black);
|
||||||
|
sprintf(str, "Unable to read file for screen dump: err = %d\n", i);
|
||||||
|
DrawCString(str);
|
||||||
|
goto Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
closeDCB.refNum = openDCB.refNum; /* close the file */
|
||||||
|
CloseGS (&closeDCB);
|
||||||
|
|
||||||
|
/* Wrap up: Wait for user to signal end, then shut down tools started. */
|
||||||
|
Fail:
|
||||||
|
SetSolidPenPat(black); /* wait for user to signal end */
|
||||||
|
str = "Press RETURN when ready to quit program";
|
||||||
|
MoveTo(SCREENWIDTH-CStringWidth(str), 40);
|
||||||
|
DrawCString(str);
|
||||||
|
getchar(); getchar();
|
||||||
|
endgraph();
|
||||||
|
return 0;
|
||||||
|
}
|
121
C.Samples/Graphic.Samples/CallP16.cc
Normal file
121
C.Samples/Graphic.Samples/CallP16.cc
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
/*****************************************************************
|
||||||
|
*
|
||||||
|
* Call ProDOS 16
|
||||||
|
*
|
||||||
|
* This program draws ovals on the 16 color screen. It then
|
||||||
|
* dumps the contents of the graphics screen to a file. If the
|
||||||
|
* file is loaded and then stored to the graphics screen, the
|
||||||
|
* image dumped is displayed.
|
||||||
|
*
|
||||||
|
* DO NOT EXECUTE THIS PROGRAM FROM THE DESKTOP. It uses non-
|
||||||
|
* standard mechanisms for accessing the graphics screen.
|
||||||
|
*
|
||||||
|
* By Barbara Allred and Mike Westerfield
|
||||||
|
*
|
||||||
|
* Copyright 1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
*******************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "CallP16"
|
||||||
|
#pragma debug 1 /* check stack overflows */
|
||||||
|
|
||||||
|
#include <prodos.h>
|
||||||
|
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <quickdraw.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <orca.h>
|
||||||
|
|
||||||
|
Rect ovalRect, *ovalPtr = &ovalRect; /* bounds rectangle for ovals */
|
||||||
|
|
||||||
|
/* Data Control Blocks for ProDOS 16 calls */
|
||||||
|
FileRec createDCB = { NULL, 0x00E3, 0x06, 0, 0x01, 0, 0 };
|
||||||
|
OpenRec openDCB;
|
||||||
|
FileIORec writeDCB;
|
||||||
|
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
#define SCREENWIDTH 320 /* screen width in pixels */
|
||||||
|
|
||||||
|
int x = 40; /* horizontal location in global coords */
|
||||||
|
int y = 20; /* vertical location in global coords */
|
||||||
|
int color; /* initial pen color */
|
||||||
|
char *str; /* work pointer */
|
||||||
|
|
||||||
|
char filename [L_tmpnam+1] = ""; /* name of file receiving screen dump */
|
||||||
|
char *fn;
|
||||||
|
|
||||||
|
/* Start Quick Draw II */
|
||||||
|
startgraph(SCREENWIDTH);
|
||||||
|
SetPenSize(4, 2); /* use fatter pen */
|
||||||
|
|
||||||
|
/* Draw ovals in different colors on the screen. */
|
||||||
|
for (color = 0; color < 15; color++) {
|
||||||
|
ovalRect.v1 = x; ovalRect.h1 = y;
|
||||||
|
ovalRect.v2 = x + 15; ovalRect.h2 = y + 15;
|
||||||
|
SetSolidPenPat(color+1);
|
||||||
|
MoveTo(y, x);
|
||||||
|
PaintOval(ovalPtr);
|
||||||
|
SetSolidPenPat(color);
|
||||||
|
MoveTo(y, x);
|
||||||
|
FrameOval(ovalPtr);
|
||||||
|
if (toolerror()) {
|
||||||
|
DrawCString("Failure in drawing routine\n");
|
||||||
|
goto Fail;
|
||||||
|
}
|
||||||
|
y += 10; x += 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dump contents of screen to a file. */
|
||||||
|
fn = tmpnam(&filename[1]); /* get unique filename for dump */
|
||||||
|
if (fn == NULL) {
|
||||||
|
MoveTo (100, 50);
|
||||||
|
SetSolidPenPat(black);
|
||||||
|
DrawCString("Unable to obtain unique filename for screen dump");
|
||||||
|
goto Fail;
|
||||||
|
}
|
||||||
|
filename[0] = strlen(&filename[1]); /* convert C-string to P-string */
|
||||||
|
|
||||||
|
createDCB.pathname = filename; /* create screen dump file */
|
||||||
|
CREATE(&createDCB);
|
||||||
|
if (toolerror()) {
|
||||||
|
MoveTo(50, 100);
|
||||||
|
SetSolidPenPat(black);
|
||||||
|
DrawCString("Unable to create file for screen dump");
|
||||||
|
goto Fail;
|
||||||
|
}
|
||||||
|
openDCB.openPathname = filename; /* open the screen dump file */
|
||||||
|
OPEN(&openDCB);
|
||||||
|
if (toolerror()) {
|
||||||
|
MoveTo(50, 100);
|
||||||
|
SetSolidPenPat(black);
|
||||||
|
DrawCString("Unable to open file for screen dump");
|
||||||
|
goto Fail;
|
||||||
|
}
|
||||||
|
writeDCB.fileRefNum = openDCB.openRefNum; /* write screen contents to file */
|
||||||
|
writeDCB.dataBuffer = (void *) 0x00E12000;
|
||||||
|
writeDCB.requestCount = 32768L;
|
||||||
|
WRITE(&writeDCB);
|
||||||
|
if (toolerror()) {
|
||||||
|
MoveTo(50, 100);
|
||||||
|
SetSolidPenPat(black);
|
||||||
|
DrawCString("Unable to write screen contents to file");
|
||||||
|
goto Fail;
|
||||||
|
}
|
||||||
|
CLOSE(&openDCB); /* close the screen dump file */
|
||||||
|
|
||||||
|
/* Wrap up: Wait for key press and then shut down QuickDraw II. */
|
||||||
|
Fail:
|
||||||
|
SetSolidPenPat(black); /* wait for user to signal end */
|
||||||
|
str = "Press return when ready to quit program";
|
||||||
|
MoveTo(SCREENWIDTH-CStringWidth(str), 40);
|
||||||
|
DrawCString(str);
|
||||||
|
getchar();
|
||||||
|
endgraph();
|
||||||
|
printf("The name of the file containing the screen dump is:\n%b", filename);
|
||||||
|
}
|
73
C.Samples/Graphic.Samples/Pipe.cc
Normal file
73
C.Samples/Graphic.Samples/Pipe.cc
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* Pipe
|
||||||
|
*
|
||||||
|
* A simple graphics demo.
|
||||||
|
*
|
||||||
|
* by Mike Westerfield
|
||||||
|
*
|
||||||
|
* Copyright 1987-1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Pipe"
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <quickdraw.h>
|
||||||
|
|
||||||
|
#define xWidth 20
|
||||||
|
#define yWidth 10
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
Rect r; /* drawing rectangle */
|
||||||
|
int x = xWidth; /* horizontal width of pipe */
|
||||||
|
int y = yWidth; /* vertical width of pipe */
|
||||||
|
int color = 1; /* pen color */
|
||||||
|
int maxX; /* maximum horizontal pixel */
|
||||||
|
int maxY; /* maximum vertical pixel */
|
||||||
|
int minX; /* minimum horizontal pixel */
|
||||||
|
int minY; /* minimum vertical pixel */
|
||||||
|
int deltaX = 6; /* pipe width increment */
|
||||||
|
int deltaY = 3; /* pipe depth increment */
|
||||||
|
int i;
|
||||||
|
|
||||||
|
GetPortRect(&r); /* initialize drawing rectangle */
|
||||||
|
maxX = r.h2 - xWidth; /* don't go beyond rect edges */
|
||||||
|
maxY = r.v2 - yWidth;
|
||||||
|
minX = r.v1;
|
||||||
|
minY = r.h1;
|
||||||
|
|
||||||
|
for (i = 0; i < 150; ++i) { /* main loop: draw pipe, a series of ovals */
|
||||||
|
r.h1 = x - xWidth;
|
||||||
|
r.h2 = x + xWidth;
|
||||||
|
r.v1 = y - yWidth;
|
||||||
|
r.v2 = y + yWidth;
|
||||||
|
color ^= 3;
|
||||||
|
SetSolidPenPat(color);
|
||||||
|
PaintOval(&r);
|
||||||
|
SetSolidPenPat(0);
|
||||||
|
FrameOval(&r);
|
||||||
|
|
||||||
|
x += deltaX; /* bend pipe as needed to fit within rectangle */
|
||||||
|
if (x < xWidth) {
|
||||||
|
x = xWidth;
|
||||||
|
deltaX = -deltaX;
|
||||||
|
}
|
||||||
|
else if (x > maxX) {
|
||||||
|
x = maxX;
|
||||||
|
deltaX = -deltaX;
|
||||||
|
}
|
||||||
|
y += deltaY;
|
||||||
|
if (y < yWidth) {
|
||||||
|
y = yWidth;
|
||||||
|
deltaY = -deltaY;
|
||||||
|
}
|
||||||
|
else if (y > maxY) {
|
||||||
|
y = maxY;
|
||||||
|
deltaY = -deltaY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
45
C.Samples/Graphic.Samples/Spiral.cc
Normal file
45
C.Samples/Graphic.Samples/Spiral.cc
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* Spiral
|
||||||
|
*
|
||||||
|
* A simple graphics demo. Uses the shell STOP command from the
|
||||||
|
* debug menu to stop the program early.
|
||||||
|
*
|
||||||
|
* by Mike Westerfield
|
||||||
|
*
|
||||||
|
* Copyright 1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Spiral"
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <quickdraw.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
float r, theta, rot;
|
||||||
|
int color = 1;
|
||||||
|
Rect rect;
|
||||||
|
|
||||||
|
GetPortRect(&rect);
|
||||||
|
SetPenSize(3, 1);
|
||||||
|
for (rot = 0.0002; rot < 0.0005; rot += 0.0001) {
|
||||||
|
theta = 0.0;
|
||||||
|
r = 40.0;
|
||||||
|
MoveTo ((int) (cos (theta) * r * 3) + 160,
|
||||||
|
(int) (sin (theta) * r) + 40);
|
||||||
|
while (r > 0.0) {
|
||||||
|
SetSolidPenPat (color);
|
||||||
|
color ^= 3;
|
||||||
|
theta += 3.1415926535 / 21.0 + rot;
|
||||||
|
LineTo ((int) (cos (theta) * r * 3) + 160,
|
||||||
|
(int) (sin (theta) * r) + 40);
|
||||||
|
r -= 0.02;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Out: ;
|
||||||
|
}
|
34
C.Samples/HyperCard/xcmd.cc
Normal file
34
C.Samples/HyperCard/xcmd.cc
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/*****************************************************************
|
||||||
|
*
|
||||||
|
* HyperCard XCMD
|
||||||
|
*
|
||||||
|
* This sample is a framework program, showing the essential parts
|
||||||
|
* of a HyperCard XCMD.
|
||||||
|
*
|
||||||
|
* For complete details on the requirements for HyperCard XCMDs,
|
||||||
|
* see the HyperCard technical documentation on the System 6.0
|
||||||
|
* CD ROM.
|
||||||
|
*
|
||||||
|
* Build this program using the script xcmd.make. This script has
|
||||||
|
* quite a few comments about the build process, so it's worth
|
||||||
|
* loading the scrept and reading the comments.
|
||||||
|
*
|
||||||
|
* By Mike Westerfield
|
||||||
|
*
|
||||||
|
* Copyright 1993
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
*****************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "xcmd"
|
||||||
|
#pragma lint -1
|
||||||
|
#pragma xcmd main
|
||||||
|
|
||||||
|
#include <HyperXCMD.h>
|
||||||
|
#include <misctool.h>
|
||||||
|
|
||||||
|
void main (XCMDPtr parm)
|
||||||
|
|
||||||
|
{
|
||||||
|
SysBeep();
|
||||||
|
}
|
26
C.Samples/HyperCard/xcmd.make
Normal file
26
C.Samples/HyperCard/xcmd.make
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
*
|
||||||
|
* This file builds the sample xcmd.cc.
|
||||||
|
*
|
||||||
|
|
||||||
|
*
|
||||||
|
* There's nothing special about the compile -- just be sure the program
|
||||||
|
* itself uses the xcmd pragma, the small memory model, and does not use the
|
||||||
|
* segment directive.
|
||||||
|
*
|
||||||
|
|
||||||
|
compile xcmd.cc
|
||||||
|
|
||||||
|
*
|
||||||
|
* The -x flag is crutial! XCMDs must consist of a single segment, and
|
||||||
|
* without the -x flag on the link, the linker creates an expressload
|
||||||
|
* segment.
|
||||||
|
*
|
||||||
|
|
||||||
|
link -x xcmd keep=xcmd
|
||||||
|
|
||||||
|
*
|
||||||
|
* The Rez compiler packs the executable code and a name into a file for
|
||||||
|
* HyperCard.
|
||||||
|
*
|
||||||
|
|
||||||
|
compile xcmd.rez keep=Beep
|
23
C.Samples/HyperCard/xcmd.rez
Normal file
23
C.Samples/HyperCard/xcmd.rez
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*****************************************************************
|
||||||
|
*
|
||||||
|
* HyperCard XCMD
|
||||||
|
*
|
||||||
|
* This is the resource file for xcmd.cc.
|
||||||
|
*
|
||||||
|
* By Mike Westerfield
|
||||||
|
*
|
||||||
|
* Copyright 1993
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
*****************************************************************/
|
||||||
|
|
||||||
|
#include "types.rez"
|
||||||
|
|
||||||
|
read $801E(1, convert) "xcmd";
|
||||||
|
|
||||||
|
resource rResName ($0001801E) {
|
||||||
|
1,
|
||||||
|
{
|
||||||
|
1, "Beep";
|
||||||
|
}
|
||||||
|
};
|
35
C.Samples/HyperStudio/nba.cc
Normal file
35
C.Samples/HyperStudio/nba.cc
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*****************************************************************
|
||||||
|
*
|
||||||
|
* HyperStudio New Button Action (NBA)
|
||||||
|
*
|
||||||
|
* This sample is a framework program, showing the essential parts
|
||||||
|
* of a HyperStudio NBA.
|
||||||
|
*
|
||||||
|
* For complete details on the requirements for HyperStudio NBAs,
|
||||||
|
* contact Roger Wagner Publishing. When this sample was written,
|
||||||
|
* details for writing HyperStudio NDAs were available in disk form
|
||||||
|
* for $10.
|
||||||
|
*
|
||||||
|
* Build this program using the script xcmd.make. This script has
|
||||||
|
* quite a few comments about the build process, so it's worth
|
||||||
|
* loading the scrept and reading the comments.
|
||||||
|
*
|
||||||
|
* By Mike Westerfield
|
||||||
|
*
|
||||||
|
* Copyright 1993
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
*****************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "nba"
|
||||||
|
#pragma lint -1
|
||||||
|
#pragma nba main
|
||||||
|
|
||||||
|
#include "HyperStudio.h"
|
||||||
|
#include <misctool.h>
|
||||||
|
|
||||||
|
void main (HSParamPtr parm)
|
||||||
|
|
||||||
|
{
|
||||||
|
SysBeep();
|
||||||
|
}
|
27
C.Samples/HyperStudio/nba.make
Normal file
27
C.Samples/HyperStudio/nba.make
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
*
|
||||||
|
* This file builds the sample nba.cc.
|
||||||
|
*
|
||||||
|
|
||||||
|
*
|
||||||
|
* There's nothing special about the compile -- just be sure the program
|
||||||
|
* itself uses the nba pragma, the small memory model, and does not use the
|
||||||
|
* segment directive.
|
||||||
|
*
|
||||||
|
|
||||||
|
compile nba.cc
|
||||||
|
|
||||||
|
*
|
||||||
|
* The -x flag is crutial! NBAs must consist of a single segment, and
|
||||||
|
* without the -x flag on the link, the linker creates an expressload
|
||||||
|
* segment.
|
||||||
|
*
|
||||||
|
|
||||||
|
link -x nba keep=nba
|
||||||
|
|
||||||
|
*
|
||||||
|
* The Rez compiler packs the executable code and a name into a file for
|
||||||
|
* HyperStudio.
|
||||||
|
*
|
||||||
|
|
||||||
|
compile nba.rez keep=Beep
|
||||||
|
filetype Beep $BC $4007
|
23
C.Samples/HyperStudio/nba.rez
Normal file
23
C.Samples/HyperStudio/nba.rez
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*****************************************************************
|
||||||
|
*
|
||||||
|
* HyperStudio NBA
|
||||||
|
*
|
||||||
|
* This is the resource file for nba.cc.
|
||||||
|
*
|
||||||
|
* By Mike Westerfield
|
||||||
|
*
|
||||||
|
* Copyright 1993
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
*****************************************************************/
|
||||||
|
|
||||||
|
#include "types.rez"
|
||||||
|
|
||||||
|
read $8017($7FF0, convert) "nba";
|
||||||
|
|
||||||
|
resource rResName ($00018017) {
|
||||||
|
1,
|
||||||
|
{
|
||||||
|
$7FF0, "Beep";
|
||||||
|
}
|
||||||
|
};
|
67
C.Samples/Text.Samples/Ackermann.cc
Normal file
67
C.Samples/Text.Samples/Ackermann.cc
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
/*****************************************************************
|
||||||
|
*
|
||||||
|
* Ackermann
|
||||||
|
*
|
||||||
|
* This program implements a famous mathematical function that
|
||||||
|
* is often used to examine recursion. It is deceptively
|
||||||
|
* simple, but can take enormous amounts of time and stack
|
||||||
|
* space for relatively small arguments. For that reason,
|
||||||
|
* rangechecking has been enabled to ensure the integrity of the
|
||||||
|
* stack.
|
||||||
|
*
|
||||||
|
* By Mike Westerfield
|
||||||
|
*
|
||||||
|
* Copyright 1987-1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
*****************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Ackermann"
|
||||||
|
#pragma debug 0x0001
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* Constants */
|
||||||
|
#define maxm 2 /* max value of 1st argument */
|
||||||
|
#define maxn 3 /* max value of 2nd argument */
|
||||||
|
|
||||||
|
/* Global variables */
|
||||||
|
int a, m, n, depth, maxdepth;
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* Ackermann - Demonstrates recursion in ORCA/C
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
int Ackermann (int m, int n)
|
||||||
|
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
depth++;
|
||||||
|
if (depth > maxdepth)
|
||||||
|
maxdepth = depth;
|
||||||
|
if (m == 0)
|
||||||
|
return (n + 1);
|
||||||
|
if (n == 0)
|
||||||
|
return (Ackermann (m-1, 1));
|
||||||
|
result = Ackermann (m-1, Ackermann (m, n-1));
|
||||||
|
depth--;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
for (m = 0; m <= maxm; m++)
|
||||||
|
for (n = 0; n <= maxn; n++) {
|
||||||
|
depth = 0;
|
||||||
|
maxdepth = 0;
|
||||||
|
a = Ackermann (m, n);
|
||||||
|
printf ("Ackermann(%d, %d) = %-4d ", m, n, a);
|
||||||
|
printf ("Max recursion depth was %d\n", maxdepth);
|
||||||
|
}
|
||||||
|
}
|
101
C.Samples/Text.Samples/Artillery.cc
Normal file
101
C.Samples/Text.Samples/Artillery.cc
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
/************************************************
|
||||||
|
*
|
||||||
|
* Artillery
|
||||||
|
*
|
||||||
|
* This classic interactive text game lets you
|
||||||
|
* pick the angle of your artillery gun in
|
||||||
|
* an attempt to knock out the enemy position.
|
||||||
|
* The computer picks a secret distance. When
|
||||||
|
* you fire, you will be told how much you
|
||||||
|
* missed by, and must fire again. The object
|
||||||
|
* is to hit the target with the fewest shells.
|
||||||
|
*
|
||||||
|
************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Artillery"
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <misctool.h>
|
||||||
|
|
||||||
|
#define FALSE 0 /* boolean constants */
|
||||||
|
#define TRUE 1
|
||||||
|
|
||||||
|
#define BLASTRADIUS 50.0 /* max distance from target for a hit */
|
||||||
|
#define DTR 0.01745329 /* convert from degrees to radians */
|
||||||
|
#define VELOCITY 434.6 /* muzzle velocity */
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
|
||||||
|
{
|
||||||
|
float angle, /* angle */
|
||||||
|
distance, /* distance to the target */
|
||||||
|
flightTime, /* time of flight */
|
||||||
|
x, /* distance to impact */
|
||||||
|
vx,vy; /* x, y velocities */
|
||||||
|
int done, /* is there a hit, yet? */
|
||||||
|
tries, /* number of shots */
|
||||||
|
i; /* loop variable */
|
||||||
|
|
||||||
|
/* choose a distance to the target */
|
||||||
|
srand((int) time(NULL));
|
||||||
|
for (i = 0; i < 100; ++i)
|
||||||
|
rand();
|
||||||
|
distance = rand()/5.55373;
|
||||||
|
|
||||||
|
/* not done yet... */
|
||||||
|
done = FALSE;
|
||||||
|
tries = 1;
|
||||||
|
|
||||||
|
/* shoot 'til we hit it */
|
||||||
|
do {
|
||||||
|
/* get the firing angle */
|
||||||
|
printf("Firing angle: ");
|
||||||
|
scanf("%f", &angle);
|
||||||
|
|
||||||
|
/* compute the muzzle velocity in x, y */
|
||||||
|
angle *= DTR;
|
||||||
|
vx = cos(angle)*VELOCITY;
|
||||||
|
vy = sin(angle)*VELOCITY;
|
||||||
|
|
||||||
|
/* find the time of flight */
|
||||||
|
/* (velocity = acceleration*flightTime, two trips) */
|
||||||
|
flightTime = 2.0*vy/32.0;
|
||||||
|
|
||||||
|
/* find the distance */
|
||||||
|
/* (distance = velocity*flightTime) */
|
||||||
|
x = vx*flightTime;
|
||||||
|
|
||||||
|
/* see what happened... */
|
||||||
|
if (fabs(distance-x) < BLASTRADIUS) {
|
||||||
|
done = TRUE;
|
||||||
|
printf("A hit, after %d", tries);
|
||||||
|
if (tries == 1)
|
||||||
|
printf(" try!\n");
|
||||||
|
else
|
||||||
|
printf(" tries!\n");
|
||||||
|
switch (tries) {
|
||||||
|
case 1:
|
||||||
|
printf("(A lucky shot...)\n");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
printf("Phenomenal shooting!\n");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
printf("Good shooting.\n");
|
||||||
|
break;
|
||||||
|
otherwise:
|
||||||
|
printf("Practice makes perfect - try again.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (distance > x)
|
||||||
|
printf("You were short by %d feet.\n", (int)(distance-x));
|
||||||
|
else
|
||||||
|
printf("You were over by %d feet.\n", (int)(x-distance));
|
||||||
|
++tries;
|
||||||
|
}
|
||||||
|
while (!done);
|
||||||
|
}
|
45
C.Samples/Text.Samples/CLine.cc
Normal file
45
C.Samples/Text.Samples/CLine.cc
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* Command Line
|
||||||
|
*
|
||||||
|
* On the Apple IIgs, all EXE programs can expect three things
|
||||||
|
* to be passed to them by the shell: a user ID number for use
|
||||||
|
* with tool kits, an eight character shell ID which
|
||||||
|
* identifies the shell that executed the program, and the
|
||||||
|
* text from the command line itself. This program shows how
|
||||||
|
* to access these values from C, printing them to the
|
||||||
|
* screen. Be sure and execute the program with some text
|
||||||
|
* after the name - for example,
|
||||||
|
*
|
||||||
|
* CLINE Hello, world.
|
||||||
|
*
|
||||||
|
* When any EXE program returns to the shell, it passes an
|
||||||
|
* error code in the A register. You can set this value from
|
||||||
|
* C by returning an integer value as the result of main, as
|
||||||
|
* shown in this program.
|
||||||
|
*
|
||||||
|
* If you compile this program from the desktop, turn debug
|
||||||
|
* code off before executing the program from the shell window.
|
||||||
|
*
|
||||||
|
***************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "CLine"
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <orca.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
|
||||||
|
{
|
||||||
|
char *shellName, *line;
|
||||||
|
int userNumber;
|
||||||
|
|
||||||
|
userNumber = userid();
|
||||||
|
shellName = shellid();
|
||||||
|
line = commandline();
|
||||||
|
printf("User ID: %d\n", userNumber);
|
||||||
|
printf("Shell ID: %s\n", shellName);
|
||||||
|
printf("Command line: %s\n", line);
|
||||||
|
return 0;
|
||||||
|
}
|
52
C.Samples/Text.Samples/ErrorExit.cc
Normal file
52
C.Samples/Text.Samples/ErrorExit.cc
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/*******************************************************************
|
||||||
|
*
|
||||||
|
* Error Exit
|
||||||
|
*
|
||||||
|
* You can call the library routines that handle run-time errors
|
||||||
|
* from your own program. One of these, called strerror, will
|
||||||
|
* print a text run-time error message to standard output. You
|
||||||
|
* pass a single integer parameter, which is the run-time error
|
||||||
|
* number. This procedure is generally called from an error trap
|
||||||
|
* subroutine - see the sample program ERRORTRAP.CC for an example
|
||||||
|
* of how to trap errors. In this program strerror is used to
|
||||||
|
* list the current run-time error messages.
|
||||||
|
*
|
||||||
|
* The two built-in macros __FILE__ and __LINE__ are used to print
|
||||||
|
* the current line number and the name of the current source file.
|
||||||
|
*
|
||||||
|
* The library subroutine SystemErrorLocation provides trace-back
|
||||||
|
* information; it is further covered in the text sample program
|
||||||
|
* ERRORTRAP.CC.
|
||||||
|
*
|
||||||
|
* By Mike Westerfield and Barbara Allred
|
||||||
|
*
|
||||||
|
* Copyright 1987-1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "ErrorExit"
|
||||||
|
#pragma debug 8 /* enable trace-back of code */
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
extern pascal void SystemErrorLocation (void);
|
||||||
|
/* A library procedure that prints the current location and a traceback. */
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
printf ("Run-time error messages are:\n\n");
|
||||||
|
for (i = 1; i <= sys_nerr; i++)
|
||||||
|
printf ("%3d: %s\n", i, strerror (i));
|
||||||
|
|
||||||
|
printf ("\nCurrent line: %d\nCurrent file: %s\n", __LINE__, __FILE__);
|
||||||
|
|
||||||
|
printf ("Exiting with a traceback.\n");
|
||||||
|
SystemErrorLocation ();
|
||||||
|
}
|
97
C.Samples/Text.Samples/ErrorTrap.cc
Normal file
97
C.Samples/Text.Samples/ErrorTrap.cc
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
/******************************************************************
|
||||||
|
*
|
||||||
|
* Error Trap
|
||||||
|
*
|
||||||
|
* You can trap run-time errors with ORCA/C. There are several
|
||||||
|
* reasons to do this, including:
|
||||||
|
*
|
||||||
|
* 1. Error messages take up space. By replacing the
|
||||||
|
* system error handler with your own, you can cut
|
||||||
|
* out the space needed to store the run-time error
|
||||||
|
* messages.
|
||||||
|
* 2. You may want to trap some kinds of run-time
|
||||||
|
* errors, like file not found or out of memory,
|
||||||
|
* and handle them yourself. If you do not, the
|
||||||
|
* error will cause the program to stop executing,
|
||||||
|
* which may not be the desired result.
|
||||||
|
*
|
||||||
|
* This program shows how to intercept and handle run-time
|
||||||
|
* errors. This is done by placing a function in your program
|
||||||
|
* called SYSTEMERROR. The function has a single parameter,
|
||||||
|
* which is an integer error number. SYSTEMERROR replaces a
|
||||||
|
* function by the same name that is normally linked in from
|
||||||
|
* the libraries. Another library function, SystemErrorLocation,
|
||||||
|
* provides the name of the function and the line number where
|
||||||
|
* the run-time error occurred.
|
||||||
|
*
|
||||||
|
* Note that if you do not want to handle a particular error,
|
||||||
|
* you can call the system error handlers from your program.
|
||||||
|
* See the sample program ERROREXIT.CC for an example.
|
||||||
|
*
|
||||||
|
* By Mike Westerfield and Barbara Allred
|
||||||
|
*
|
||||||
|
* Copyright 1987-1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
*******************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "ErrorTrap"
|
||||||
|
#pragma debug 9 /* enable range checking + trace-back */
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
extern pascal void SystemErrorLocation (void);
|
||||||
|
/* A library procedure that prints the current location and a traceback. */
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* BadFunction - Subroutine that will generate a run-time error
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
static void BadFunction (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
char ch [8000]; /* this array is too large for */
|
||||||
|
/* the default run-time stack */
|
||||||
|
(void)ch; /* dummy use of ch to avoid lint msg */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* DoIt - Calls function that will generate a run-time error
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
static void DoIt (void)
|
||||||
|
{
|
||||||
|
BadFunction(); /* call function with large array */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* SystemError - Replaces SYSTEMERROR function in the ORCA library
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
static void SYSTEMERROR (int errorNumber)
|
||||||
|
|
||||||
|
{
|
||||||
|
printf ("Run-time error detected. error number = %d\n", errorNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* Main program starts here
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
DoIt();
|
||||||
|
SystemErrorLocation();
|
||||||
|
}
|
61
C.Samples/Text.Samples/Finance.cc
Normal file
61
C.Samples/Text.Samples/Finance.cc
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
/************************************************
|
||||||
|
*
|
||||||
|
* Finance
|
||||||
|
*
|
||||||
|
* This program prints the balance on an
|
||||||
|
* account for monthly payments, along with the
|
||||||
|
* total amount paid so far.
|
||||||
|
*
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Finance"
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define LOANAMOUNT 10000.0 /* amount of the loan */
|
||||||
|
#define PAYMENT 600.0 /* monthly payment */
|
||||||
|
#define INTEREST 15 /* yearly interest (as %) */
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
|
||||||
|
{
|
||||||
|
float balance, /* amount left to pay */
|
||||||
|
monthlyInterest, /* multiplier for interest */
|
||||||
|
paid ; /* total amount paid */
|
||||||
|
int month; /* month number */
|
||||||
|
|
||||||
|
/* set up the initial values */
|
||||||
|
balance = LOANAMOUNT;
|
||||||
|
paid = month = 0;
|
||||||
|
monthlyInterest = 1.0 + INTEREST/1200.0;
|
||||||
|
|
||||||
|
/* write out the conditions */
|
||||||
|
printf("Payment schedule for a loan of %10.2f\n", LOANAMOUNT);
|
||||||
|
printf("with monthly payments of %5.2f at an\n", PAYMENT);
|
||||||
|
printf("interest rate of %d%%.\n\n", INTEREST);
|
||||||
|
printf(" month balance amount paid\n");
|
||||||
|
printf(" ----- ------- -----------\n");
|
||||||
|
|
||||||
|
/* check for payments that are too small */
|
||||||
|
if (balance*monthlyInterest - balance >= PAYMENT)
|
||||||
|
printf("The payment is too small!");
|
||||||
|
else
|
||||||
|
while (balance > 0) {
|
||||||
|
/* add in the interest */
|
||||||
|
balance *= monthlyInterest;
|
||||||
|
/* make a payment */
|
||||||
|
if (balance > PAYMENT) {
|
||||||
|
balance -= PAYMENT;
|
||||||
|
paid += PAYMENT;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
paid += balance;
|
||||||
|
balance = 0;
|
||||||
|
}
|
||||||
|
/* update the month number */
|
||||||
|
++month;
|
||||||
|
/* write the new statistics */
|
||||||
|
printf("%15d %14.2f %14.2f\n", month, balance, paid);
|
||||||
|
}
|
||||||
|
}
|
107
C.Samples/Text.Samples/Key.cc
Normal file
107
C.Samples/Text.Samples/Key.cc
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
/*****************************************************************
|
||||||
|
*
|
||||||
|
* Keyboard Handling
|
||||||
|
*
|
||||||
|
* This program shows one way to access the keyboard directly
|
||||||
|
* from ORCA/C. Keep in mind that the standard file input
|
||||||
|
* collects an entire line of characters before reporting the
|
||||||
|
* first character. This is necessary to allow editing of the
|
||||||
|
* input line. When using the desktop environment, you can get
|
||||||
|
* keypress events from the event manager. This program shows
|
||||||
|
* how to detect a keypress as soon as it is hit. It echoes
|
||||||
|
* keys until you type CONTROL-@ (ASCII 0).
|
||||||
|
*
|
||||||
|
* The program works by reading the keyboard (at $C000) until
|
||||||
|
* the value is negative, indicating that a key has been
|
||||||
|
* pressed. It then stores a value (any value will do) in
|
||||||
|
* $C010 to indicate that the key has been read. This makes
|
||||||
|
* the value at $C010 positive (bit 7 is clear). The value of
|
||||||
|
* the key is then ANDed with $7F to clear the high bit.
|
||||||
|
*
|
||||||
|
* THIS METHOD OF READING THE KEYBOARD ONLY WORKS IN THE TEXT
|
||||||
|
* ENVIRONMENT. When the event manager is active, as it always
|
||||||
|
* is in a desktop program, you should call the event manager
|
||||||
|
* to read keystrokes.
|
||||||
|
*
|
||||||
|
* Checking to see when a key has been pressed is bundled into
|
||||||
|
* the function KeyPress. Returning the key and clearing the
|
||||||
|
* strobe is done in ReadChar.
|
||||||
|
*
|
||||||
|
* See key2 for a version that splits the keyboard routines off
|
||||||
|
* into a separately compilable module.
|
||||||
|
*
|
||||||
|
* See key3 for a version that uses assembly language to do the
|
||||||
|
* same thing.
|
||||||
|
*
|
||||||
|
* By Mike Westerfield and Barbara Allred
|
||||||
|
*
|
||||||
|
* Copyright 1987-1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
*******************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Key"
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
static char ch; /* character read from keyboard */
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* KeyPress - Check if a key has been pressed
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
int KeyPress(void)
|
||||||
|
|
||||||
|
{
|
||||||
|
char *keyboard;
|
||||||
|
|
||||||
|
keyboard = (char *) 0x00C000;
|
||||||
|
return ((*keyboard) & 0x80) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* ReadChar - Return the last character typed on the keyboard.
|
||||||
|
* Note: Returns a character whether or not one has
|
||||||
|
* been typed!
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
char ReadChar (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
char *keyboard, *strobe;
|
||||||
|
|
||||||
|
keyboard = (char *) 0x00C000;
|
||||||
|
strobe = (char *) 0x00C010;
|
||||||
|
*strobe = 0;
|
||||||
|
return *keyboard & 0x7F;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* Main program starts here
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
|
||||||
|
{
|
||||||
|
printf ("Press any key(s) and then RETURN. Enter CTRL-@ to quit.\n");
|
||||||
|
do {
|
||||||
|
while (! KeyPress()) /* wait for a keypress */
|
||||||
|
;
|
||||||
|
ch = ReadChar(); /* get character typed from keybrd */
|
||||||
|
if (ch == 0x0D) /* write character to the screen */
|
||||||
|
printf ("\n");
|
||||||
|
else
|
||||||
|
printf ("%c", ch);
|
||||||
|
}
|
||||||
|
while (ch != 0);
|
||||||
|
return 0;
|
||||||
|
}
|
20
C.Samples/Text.Samples/Key2.Build
Normal file
20
C.Samples/Text.Samples/Key2.Build
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
unset exit
|
||||||
|
echo compile key2.cc
|
||||||
|
compile key2.cc
|
||||||
|
if {status} == 0
|
||||||
|
echo compile key2.funcs
|
||||||
|
compile key2.funcs
|
||||||
|
if {status} == 0
|
||||||
|
echo link key2.cc key2.funcs
|
||||||
|
link key2 funcs keep=Key2
|
||||||
|
if {status} == 0
|
||||||
|
key2
|
||||||
|
else
|
||||||
|
echo Unable to link key2.cc key2.funcs
|
||||||
|
end
|
||||||
|
else
|
||||||
|
echo Unable to compile key2.funcs
|
||||||
|
end
|
||||||
|
else
|
||||||
|
echo Unable to compile key2.cc
|
||||||
|
end
|
43
C.Samples/Text.Samples/Key2.Funcs
Normal file
43
C.Samples/Text.Samples/Key2.Funcs
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*****************************************************************
|
||||||
|
*
|
||||||
|
* This file contains the functions for KEY2.CC. See that file
|
||||||
|
* for detailed comments.
|
||||||
|
*
|
||||||
|
*******************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Funcs"
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* KeyPress - Check if a key has been pressed
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
int KeyPress(void)
|
||||||
|
|
||||||
|
{
|
||||||
|
char *keyboard;
|
||||||
|
|
||||||
|
keyboard = (char *) 0x00C000;
|
||||||
|
return ((*keyboard) & 0x80) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* ReadChar - Returns the last character typed on the keyboard.
|
||||||
|
* Note: Returns a character whether or not one has
|
||||||
|
* been typed!
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
char ReadChar(void)
|
||||||
|
|
||||||
|
{
|
||||||
|
char *keyboard, *strobe;
|
||||||
|
|
||||||
|
keyboard = (char *) 0x00C000;
|
||||||
|
strobe = (char *) 0x00C010;
|
||||||
|
*strobe = 0;
|
||||||
|
return *keyboard & 0x7F;
|
||||||
|
}
|
61
C.Samples/Text.Samples/Key2.cc
Normal file
61
C.Samples/Text.Samples/Key2.cc
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
/*****************************************************************
|
||||||
|
*
|
||||||
|
* Keyboard Handling
|
||||||
|
*
|
||||||
|
* This program demonstrates separate compilation by splitting
|
||||||
|
* the program KEY into two parts: the main program, and a
|
||||||
|
* separately compiled file with the keyboard subroutines that
|
||||||
|
* can then be called from many different programs without the
|
||||||
|
* need for recompiling. See KEY.CC for a full description of
|
||||||
|
* what this program does.
|
||||||
|
*
|
||||||
|
* The program now consists of four files:
|
||||||
|
*
|
||||||
|
* Key2.Build - EXEC file which separately compiles the two
|
||||||
|
* source files, then links their object
|
||||||
|
* modules to create the final program. To
|
||||||
|
* use the EXEC file, simply type KEY2.BUILD
|
||||||
|
* from the command line.
|
||||||
|
*
|
||||||
|
* Key2.cc - File containing main program.
|
||||||
|
*
|
||||||
|
* Key2.h - Header file accessed by the main program;
|
||||||
|
* Contains declarations of external functions.
|
||||||
|
*
|
||||||
|
* Key2.Funcs - File containing keyboard functions called
|
||||||
|
* by main program.
|
||||||
|
*
|
||||||
|
* See Key3 for a version that uses assembly language to read
|
||||||
|
* the keyboard.
|
||||||
|
*
|
||||||
|
* By Mike Westerfield and Barbara Allred
|
||||||
|
*
|
||||||
|
* Copyright 1987-1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
*******************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Key2"
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include "Key2.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
|
||||||
|
{
|
||||||
|
char ch;
|
||||||
|
|
||||||
|
printf ("Press any key(s) and then RETURN. Enter CTRL-@ to quit.\n");
|
||||||
|
do {
|
||||||
|
while (! KeyPress()) /* wait for a keypress */
|
||||||
|
;
|
||||||
|
ch = ReadChar(); /* get character typed from keybrd */
|
||||||
|
if (ch == 0x0D) /* write character to the screen */
|
||||||
|
printf ("\n");
|
||||||
|
else
|
||||||
|
printf ("%c", ch);
|
||||||
|
}
|
||||||
|
while (ch != 0);
|
||||||
|
return 0;
|
||||||
|
}
|
4
C.Samples/Text.Samples/Key2.h
Normal file
4
C.Samples/Text.Samples/Key2.h
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
/* Header file for program Key2.CC */
|
||||||
|
|
||||||
|
extern int KeyPress(void);
|
||||||
|
extern char ReadChar(void);
|
41
C.Samples/Text.Samples/Key3.asm
Normal file
41
C.Samples/Text.Samples/Key3.asm
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
* KeyPress - Check to see if a key has been pressed
|
||||||
|
*
|
||||||
|
* Outputs:
|
||||||
|
* A - 1 (true) if pressed, else 0
|
||||||
|
*
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
KeyPress start
|
||||||
|
keyBoard equ $C000 keyboard location
|
||||||
|
|
||||||
|
sep #$30 use short regs for load
|
||||||
|
lda >keyBoard load keyboard value
|
||||||
|
asl A shift sign bit into bit 0
|
||||||
|
rol A
|
||||||
|
rep #$30 back to long regs
|
||||||
|
and #1 and out all but the bit we want
|
||||||
|
rtl
|
||||||
|
end
|
||||||
|
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
* ReadChar - return the last character typed on the keyboard
|
||||||
|
*
|
||||||
|
* Outputs:
|
||||||
|
* A - character typed
|
||||||
|
*
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
ReadChar start
|
||||||
|
keyBoard equ $C000 keyboard location
|
||||||
|
strobe equ $C010 strobe location
|
||||||
|
|
||||||
|
sep #$30 use short regs
|
||||||
|
sta >strobe clear strobe
|
||||||
|
lda >keyBoard load character
|
||||||
|
rep #$30 back to long regs
|
||||||
|
and #$007F and out high bits
|
||||||
|
rtl
|
||||||
|
end
|
64
C.Samples/Text.Samples/Key3.cc
Normal file
64
C.Samples/Text.Samples/Key3.cc
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
/*****************************************************************
|
||||||
|
*
|
||||||
|
* Keyboard Handling
|
||||||
|
*
|
||||||
|
* This is the final incarnation of the keyboard polling sample.
|
||||||
|
* See KEY.CC for complete comments on what the program does and
|
||||||
|
* how it works.
|
||||||
|
*
|
||||||
|
* In this version, we will write the two subroutines in
|
||||||
|
* assembly language. While you could use separate compilation
|
||||||
|
* to compile and assemble the two pieces separately, then
|
||||||
|
* link them, as in the last example, we will use chaining
|
||||||
|
* to avoid all of that. Chaining is a feature of all
|
||||||
|
* languages fully installed in ORCA or APW that allows a
|
||||||
|
* single program to be written in more than one language
|
||||||
|
* without resorting to separate compilation. Which method
|
||||||
|
* you prefer - chaining or separate compilation - depends
|
||||||
|
* on your own taste.
|
||||||
|
*
|
||||||
|
* To chain the two files together, we just place an append
|
||||||
|
* command after the end of the program. The rest is automatic
|
||||||
|
* To compile, assemble, link, and execute, we can now use the
|
||||||
|
* familiar RUN command:
|
||||||
|
*
|
||||||
|
* run key3.cc
|
||||||
|
*
|
||||||
|
* Note: both the assembler and compiler must be properly
|
||||||
|
* installed for this to work. The assembler is sold
|
||||||
|
* separately as ORCA/M 2.0 for the Apple IIGS.
|
||||||
|
*
|
||||||
|
* By Mike Westerfield and Barbara Allred
|
||||||
|
*
|
||||||
|
* Copyright 1987-1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
*******************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Key3"
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
extern int KEYPRESS (void); /* declare assembly-language */
|
||||||
|
extern int READCHAR (void); /* routines to be called */
|
||||||
|
char ch; /* character read from keyboard */
|
||||||
|
|
||||||
|
printf("Press any key(s) and then RETURN. Enter CTRL-@ to quit.\n");
|
||||||
|
do {
|
||||||
|
while (! KEYPRESS()) /* wait for a keypress */
|
||||||
|
;
|
||||||
|
ch = READCHAR(); /* get character typed from keybrd */
|
||||||
|
if (ch == 0x0D) /* write character to the screen */
|
||||||
|
printf ("\n");
|
||||||
|
else
|
||||||
|
printf ("%c", ch);
|
||||||
|
}
|
||||||
|
while (ch != 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#append "Key3.asm"
|
34
C.Samples/Text.Samples/Print.cc
Normal file
34
C.Samples/Text.Samples/Print.cc
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/*****************************************************************
|
||||||
|
*
|
||||||
|
* Text Printer Demo
|
||||||
|
*
|
||||||
|
* This example shows how to access the .PRINTER text printer
|
||||||
|
* driver from a C program. The .PRINTER driver must be installed
|
||||||
|
* before this sample is executed.
|
||||||
|
*
|
||||||
|
* There really isn't much to this sample, which may seem bad at
|
||||||
|
* first, but it's really good: accessing the text printer driver
|
||||||
|
* really is as simple as opening the printer and writing to it!
|
||||||
|
*
|
||||||
|
* By Mike Westerfield
|
||||||
|
*
|
||||||
|
* Copyright 1993
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
*****************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Print"
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
|
f = fopen(".printer", "w+");
|
||||||
|
fprintf(f, "Hello, printer!\n");
|
||||||
|
fputc('\f', f); /* on most printers, this will eject a page */
|
||||||
|
fclose(f);
|
||||||
|
}
|
64
C.Samples/Text.Samples/Trace.cc
Normal file
64
C.Samples/Text.Samples/Trace.cc
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* Trace
|
||||||
|
*
|
||||||
|
* ORCA/C can give you a traceback when a run-time error occurs.
|
||||||
|
* A traceback shows the function and line number where the
|
||||||
|
* error occurred, then gives a list of functions and line
|
||||||
|
* numbers that show what subroutine calls were made to get to
|
||||||
|
* the point where the error occurred. This program illustrates
|
||||||
|
* this by deliberately failing in the function named Fail.
|
||||||
|
*
|
||||||
|
* By Mike Westerfield and Barbara Allred
|
||||||
|
*
|
||||||
|
* Copyright 1987-1989
|
||||||
|
* Byte Works, Inc.
|
||||||
|
*
|
||||||
|
******************************************************************/
|
||||||
|
|
||||||
|
#pragma keep "Trace"
|
||||||
|
#pragma debug 9
|
||||||
|
#pragma lint -1
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* Fail - Subroutine that will generate a run-time error
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
static void Fail (void)
|
||||||
|
{
|
||||||
|
char ch [8000]; /* this array is too large for */
|
||||||
|
/* the default run-time stack */
|
||||||
|
(void)ch; /* dummy use of ch to avoid lint msg */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* DoIt - Calls subroutine that will generate a run-time error
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
static void DoIt (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
Fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* Main program starts here
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
|
||||||
|
{
|
||||||
|
printf ("This program fails. Generating a traceback:\n");
|
||||||
|
DoIt();
|
||||||
|
}
|
|
@ -1,15 +1,25 @@
|
||||||
Welcome to ORCA/C 2.2.0 B5! This is an update release containing
|
This is an update package that can be used to update ORCA/C 2.1.0 or
|
||||||
patches from community members (Stephen Heumann and Kelvin Sherlock),
|
2.2.0 to ORCA/C 2.2.1. You must have an existing copy of ORCA/C 2.1.0
|
||||||
which fix bugs and also add several new features. For details on
|
or 2.2.0 in order to use this update. If you do not already have a
|
||||||
these changes, see the cc.notes file in the Release.Notes directory.
|
copy, you can get it as part of Opus ][: The Software, a collection of
|
||||||
|
Byte Works software which is sold by Juiced.GS:
|
||||||
|
https://juiced.gs/store/opus-ii-software/
|
||||||
|
|
||||||
This package is designed to be applied as an update to an existing
|
This update must be applied to an existing ORCA installation containing
|
||||||
ORCA installation containing ORCA/C 2.1.0 or later (including the one
|
ORCA/C 2.1.0 or ORCA/C 2.2.0 (including the one provided on Opus ][:
|
||||||
provided on Opus ][: The Software). To apply the update, simply copy
|
The Software). To apply the update, you just need to copy the files
|
||||||
the files from this distribution into the corresponding locations in
|
from this distribution into the corresponding locations in your ORCA
|
||||||
your ORCA installation, replacing any older versions. (One easy way
|
installation, replacing any older versions.
|
||||||
to do this is to extract the archive containing this update directly
|
|
||||||
on top of your ORCA installation, overwriting all modified files.)
|
If you received this update as a SHK file, you can simply extract the
|
||||||
|
files from it directly on top of your ORCA installation.
|
||||||
|
|
||||||
|
If you received this update as a disk image, you can apply the update
|
||||||
|
by copying the files into place using the Finder, or by running the
|
||||||
|
following command within the root directory of your ORCA installation
|
||||||
|
using the text-based ORCA shell:
|
||||||
|
|
||||||
|
COPY -C :ORCAC.221:=
|
||||||
|
|
||||||
In addition to the ORCA shell environment, this update can also be
|
In addition to the ORCA shell environment, this update can also be
|
||||||
used under other environments that are compatible with ORCA/C, such as
|
used under other environments that are compatible with ORCA/C, such as
|
||||||
|
@ -18,20 +28,3 @@ into the directory containing files from a standard ORCA installation
|
||||||
(normally /lang/orca for GNO). An updated version of ORCALib suitable
|
(normally /lang/orca for GNO). An updated version of ORCALib suitable
|
||||||
for use under GNO is available as a separate download at:
|
for use under GNO is available as a separate download at:
|
||||||
https://github.com/byteworksinc/ORCALib/releases
|
https://github.com/byteworksinc/ORCALib/releases
|
||||||
|
|
||||||
If you have any questions, or if you want to get involved in ORCA/C
|
|
||||||
development, please get in touch. The ORCA/C development project is
|
|
||||||
hosted on GitHub, and bug reports or patches can be submitted there:
|
|
||||||
https://github.com/byteworksinc/ORCA-C
|
|
||||||
|
|
||||||
Thanks to:
|
|
||||||
* Mike Westerfield, for writing ORCA/C, releasing the source code,
|
|
||||||
and permitting it to be updated by the community.
|
|
||||||
* Kelvin Sherlock, for providing several patches and bug reports, and
|
|
||||||
for writing several useful tools for modern Apple II development.
|
|
||||||
* Soenke Behrens, for compiling a list of ORCA/C bug reports and test
|
|
||||||
cases, which has helped me to identify and fix a number of bugs.
|
|
||||||
* The developers of Csmith (http://embed.cs.utah.edu/csmith/), an
|
|
||||||
automated compiler testing tool that has helped to find several bugs.
|
|
||||||
|
|
||||||
--Stephen Heumann (stephenheumann@gmail.com)
|
|
||||||
|
|
27
CC.pas
27
CC.pas
|
@ -36,7 +36,7 @@ begin {cc}
|
||||||
{make sure we quit with restart set}
|
{make sure we quit with restart set}
|
||||||
SystemQuitFlags($4000);
|
SystemQuitFlags($4000);
|
||||||
|
|
||||||
{get the command line info}
|
{initialize file names and parameter strings}
|
||||||
includeFileGS.maxSize := maxPath+4;
|
includeFileGS.maxSize := maxPath+4;
|
||||||
includeFileGS.theString.size := 0;
|
includeFileGS.theString.size := 0;
|
||||||
for i := 1 to maxPath do
|
for i := 1 to maxPath do
|
||||||
|
@ -44,6 +44,14 @@ for i := 1 to maxPath do
|
||||||
outFileGS := includeFileGS;
|
outFileGS := includeFileGS;
|
||||||
partialFileGS := includeFileGS;
|
partialFileGS := includeFileGS;
|
||||||
infoStringGS := includeFileGS;
|
infoStringGS := includeFileGS;
|
||||||
|
|
||||||
|
{check the version number}
|
||||||
|
vDCBGS.pCount := 1;
|
||||||
|
VersionGS(vDCBGS);
|
||||||
|
if (ToolError <> 0) or (vDCBGS.version[1] < '2') then
|
||||||
|
TermError(10);
|
||||||
|
|
||||||
|
{get the command line info}
|
||||||
with liDCBGS do begin
|
with liDCBGS do begin
|
||||||
pCount := 11;
|
pCount := 11;
|
||||||
sFile := @includeFileGS;
|
sFile := @includeFileGS;
|
||||||
|
@ -52,10 +60,19 @@ with liDCBGS do begin
|
||||||
iString := @infoStringGS;
|
iString := @infoStringGS;
|
||||||
end; {with}
|
end; {with}
|
||||||
GetLInfoGS(liDCBGS);
|
GetLInfoGS(liDCBGS);
|
||||||
|
if ToolError <> 0 then begin {check for buffTooSmall errors}
|
||||||
|
includeFileGS.theString.size := 0;
|
||||||
|
outFileGS.theString.size := 0;
|
||||||
|
partialFileGS.theString.size := 0;
|
||||||
|
infoStringGS.theString.size := 0;
|
||||||
|
enterEditor := false;
|
||||||
|
TermError(13);
|
||||||
|
end; {if}
|
||||||
sourceFileGS := includeFileGS;
|
sourceFileGS := includeFileGS;
|
||||||
doingPartial := partialFileGS.theString.size <> 0;
|
doingPartial := partialFileGS.theString.size <> 0;
|
||||||
with liDCBGS do begin
|
with liDCBGS do begin
|
||||||
enterEditor := pFlags & flag_e <> 0; {enter editor on terminal errors?}
|
enterEditor := pFlags & flag_e <> 0; {enter editor on terminal errors?}
|
||||||
|
filenamesInErrors := pFlags & flag_f <> 0; {filenames in error messages?}
|
||||||
ignoreSymbols := mFlags & flag_i <> 0; {ignore symbol file?}
|
ignoreSymbols := mFlags & flag_i <> 0; {ignore symbol file?}
|
||||||
list := pFlags & flag_l <> 0; {list the source file?}
|
list := pFlags & flag_l <> 0; {list the source file?}
|
||||||
memoryCompile := pflags & flag_m <> 0; {memory based compile?}
|
memoryCompile := pflags & flag_m <> 0; {memory based compile?}
|
||||||
|
@ -69,12 +86,6 @@ with liDCBGS do begin
|
||||||
if list then {we don't need both...}
|
if list then {we don't need both...}
|
||||||
progress := false;
|
progress := false;
|
||||||
|
|
||||||
{check the version number}
|
|
||||||
vDCBGS.pCount := 1;
|
|
||||||
VersionGS(vDCBGS);
|
|
||||||
if vDCBGS.version[1] < '2' then
|
|
||||||
TermError(10);
|
|
||||||
|
|
||||||
{write the header}
|
{write the header}
|
||||||
if list or progress then begin
|
if list or progress then begin
|
||||||
writeln('ORCA/C ', versionStr);
|
writeln('ORCA/C ', versionStr);
|
||||||
|
@ -129,6 +140,8 @@ DoGlobals; {create the ~GLOBALS and ~ARRAYS segment
|
||||||
{shut down the compiler}
|
{shut down the compiler}
|
||||||
TermHeader; {make sure the compiled header file is closed}
|
TermHeader; {make sure the compiled header file is closed}
|
||||||
CheckStaticFunctions; {check for undefined functions}
|
CheckStaticFunctions; {check for undefined functions}
|
||||||
|
if (lint & lintUnused) <> 0 then {check for unused static vars}
|
||||||
|
CheckUnused(globalTable);
|
||||||
ffDCBGS.action := 7; {purge the source file}
|
ffDCBGS.action := 7; {purge the source file}
|
||||||
ffDCBGS.pcount := 14;
|
ffDCBGS.pcount := 14;
|
||||||
ffDCBGS.pathName := @includeFileGS.theString;
|
ffDCBGS.pathName := @includeFileGS.theString;
|
||||||
|
|
8
CC.rez
8
CC.rez
|
@ -4,12 +4,12 @@ resource rVersion(1) {
|
||||||
{
|
{
|
||||||
2, /* Major revision */
|
2, /* Major revision */
|
||||||
2, /* Minor revision */
|
2, /* Minor revision */
|
||||||
0, /* Bug version */
|
1, /* Bug version */
|
||||||
beta, /* Release stage */
|
development, /* Release stage */
|
||||||
5, /* Non-final release # */
|
1, /* Non-final release # */
|
||||||
},
|
},
|
||||||
verUS, /* Region code */
|
verUS, /* Region code */
|
||||||
"ORCA/C", /* Short version number */
|
"ORCA/C", /* Short version number */
|
||||||
"Copyright 1997, Byte Works, Inc.\n" /* Long version number */
|
"Copyright 1997, Byte Works, Inc.\n" /* Long version number */
|
||||||
"Updated 2021"
|
"Updated 2024"
|
||||||
};
|
};
|
||||||
|
|
44
CCommon.asm
44
CCommon.asm
|
@ -44,37 +44,43 @@ lb1 lda [fromPtr],Y
|
||||||
Hash start cc
|
Hash start cc
|
||||||
hashSize equ 876 # hash buckets - 1
|
hashSize equ 876 # hash buckets - 1
|
||||||
|
|
||||||
sum equ 0 hash
|
disp equ 0 disp into hash table
|
||||||
length equ 2 length of string
|
length equ 2 length of string
|
||||||
|
|
||||||
subroutine (4:sPtr),4
|
subroutine (4:sPtr),4
|
||||||
|
|
||||||
stz sum default to bucket 0
|
|
||||||
lda [sPtr] set the length of the string
|
lda [sPtr] set the length of the string
|
||||||
|
tax
|
||||||
and #$00FF
|
and #$00FF
|
||||||
sta length
|
sta length
|
||||||
ldy #1 start with char 1
|
ldy #1 start with char 1
|
||||||
lda [sPtr] if 1st char is '~', start with char 6
|
txa if 1st char is '~', start with char 6
|
||||||
and #$FF00
|
and #$FF00
|
||||||
cmp #'~'*256
|
cmp #'~'*256
|
||||||
bne lb1
|
bne lb0
|
||||||
ldy #6
|
ldy #6
|
||||||
|
|
||||||
lb1 lda [sPtr],Y get the value to add in
|
lb0 lda #0 initial value is 0
|
||||||
and #$3F3F
|
bra lb2 while there are at least 2 chars left
|
||||||
cpy length if there is only 1 char left then
|
lb1 asl a rotate sum left one bit
|
||||||
bne lb2
|
adc [sPtr],Y add in next two bytes
|
||||||
and #$00FF and out the high byte
|
iny advance two chars
|
||||||
lb2 clc add it to the sum
|
|
||||||
adc sum
|
|
||||||
sta sum
|
|
||||||
iny next char
|
|
||||||
iny
|
iny
|
||||||
cpy length
|
lb2 cpy length
|
||||||
ble lb1
|
blt lb1
|
||||||
mod2 sum,#hashSize+1 return disp
|
bne lb3 if there is 1 char left then
|
||||||
asl sum
|
asl a rotate sum left one bit
|
||||||
asl sum
|
sta disp
|
||||||
|
lda [sPtr],Y
|
||||||
|
and #$00FF and out the high byte
|
||||||
|
adc disp add last byte to the sum
|
||||||
|
sec
|
||||||
|
lb3 sbc #hashSize+1 disp := (sum mod (hashSize+1)) << 2
|
||||||
|
bcs lb3
|
||||||
|
adc #hashSize+1
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
sta disp
|
||||||
|
|
||||||
return 2:sum
|
return 2:disp return disp
|
||||||
end
|
end
|
||||||
|
|
88
CCommon.pas
88
CCommon.pas
|
@ -74,11 +74,12 @@ interface
|
||||||
const
|
const
|
||||||
{hashsize appears in CCOMMON.ASM}
|
{hashsize appears in CCOMMON.ASM}
|
||||||
hashSize = 876; {# hash buckets - 1}
|
hashSize = 876; {# hash buckets - 1}
|
||||||
|
{NOTE: hashsize2 is used in Symbol.asm}
|
||||||
hashSize2 = 1753; {# hash buckets * 2 - 1}
|
hashSize2 = 1753; {# hash buckets * 2 - 1}
|
||||||
maxLine = 255; {max length of a line}
|
maxLine = 255; {max length of a line}
|
||||||
maxPath = 255; {max length of a path name}
|
maxPath = 255; {max length of a path name}
|
||||||
{NOTE: maxPath is used in Scanner.asm}
|
{NOTE: maxPath is used in Scanner.asm}
|
||||||
longstringlen = 4000; {max length of a string constant}
|
longstringlen = 32760; {max length of a string constant}
|
||||||
|
|
||||||
minChar = 0; {min ordinal value of source character}
|
minChar = 0; {min ordinal value of source character}
|
||||||
maxChar = 255; {max ordinal value of source character}
|
maxChar = 255; {max ordinal value of source character}
|
||||||
|
@ -93,11 +94,14 @@ const
|
||||||
lintOverflow = $0020; {check for overflows}
|
lintOverflow = $0020; {check for overflows}
|
||||||
lintC99Syntax = $0040; {check for syntax that C99 disallows}
|
lintC99Syntax = $0040; {check for syntax that C99 disallows}
|
||||||
lintReturn = $0080; {flag issues with how functions return}
|
lintReturn = $0080; {flag issues with how functions return}
|
||||||
|
lintUnused = $0100; {check for unused variables}
|
||||||
|
lintConstantRange = $0200; {check for out-of-range constants}
|
||||||
|
|
||||||
{bit masks for GetLInfo flags}
|
{bit masks for GetLInfo flags}
|
||||||
{----------------------------}
|
{----------------------------}
|
||||||
flag_d = $10000000; {generate debug code?}
|
flag_d = $10000000; {generate debug code?}
|
||||||
flag_e = $08000000; {abort to editor on terminal error?}
|
flag_e = $08000000; {abort to editor on terminal error?}
|
||||||
|
flag_f = $04000000; {print filenames in error messages?}
|
||||||
flag_i = $00800000; {ignore symbol files?}
|
flag_i = $00800000; {ignore symbol files?}
|
||||||
flag_l = $00100000; {list source lines?}
|
flag_l = $00100000; {list source lines?}
|
||||||
flag_m = $00080000; {memory based compile?}
|
flag_m = $00080000; {memory based compile?}
|
||||||
|
@ -108,7 +112,7 @@ const
|
||||||
flag_t = $00001000; {treat all errors as terminal?}
|
flag_t = $00001000; {treat all errors as terminal?}
|
||||||
flag_w = $00000200; {wait when an error is found?}
|
flag_w = $00000200; {wait when an error is found?}
|
||||||
|
|
||||||
versionStr = '2.2.0 B5'; {compiler version}
|
versionStr = '2.2.1 dev'; {compiler version}
|
||||||
|
|
||||||
type
|
type
|
||||||
{Misc.}
|
{Misc.}
|
||||||
|
@ -141,6 +145,9 @@ type
|
||||||
end;
|
end;
|
||||||
gsosOutStringPtr = ^gsosOutString;
|
gsosOutStringPtr = ^gsosOutString;
|
||||||
|
|
||||||
|
{ C language standards }
|
||||||
|
cStandardEnum = (c89,c95,c99,c11,c17,c23);
|
||||||
|
|
||||||
{ The base types include two main categories. The values starting }
|
{ The base types include two main categories. The values starting }
|
||||||
{ with cg are defined in the code generator, and may be passed to the }
|
{ with cg are defined in the code generator, and may be passed to the }
|
||||||
{ code generator for resolution. The cc types are used internally in }
|
{ code generator for resolution. The cc types are used internally in }
|
||||||
|
@ -172,7 +179,7 @@ type
|
||||||
{ They are created only by casts. }
|
{ They are created only by casts. }
|
||||||
intconst,uintconst,longconst,ulongconst,longlongconst,
|
intconst,uintconst,longconst,ulongconst,longlongconst,
|
||||||
ulonglongconst,floatconst,doubleconst,extendedconst,compconst,
|
ulonglongconst,floatconst,doubleconst,extendedconst,compconst,
|
||||||
charconst,scharconst,ucharconst,stringconst,
|
charconst,scharconst,ucharconst,ushortconst,stringconst,
|
||||||
{reserved words}
|
{reserved words}
|
||||||
_Alignassy,_Alignofsy,_Atomicsy,_Boolsy,_Complexsy,
|
_Alignassy,_Alignofsy,_Atomicsy,_Boolsy,_Complexsy,
|
||||||
_Genericsy,_Imaginarysy,_Noreturnsy,_Static_assertsy,_Thread_localsy,
|
_Genericsy,_Imaginarysy,_Noreturnsy,_Static_assertsy,_Thread_localsy,
|
||||||
|
@ -194,11 +201,14 @@ type
|
||||||
lteqop,gteqop,eqeqop,exceqop,andandop,
|
lteqop,gteqop,eqeqop,exceqop,andandop,
|
||||||
barbarop,pluseqop,minuseqop,asteriskeqop,slasheqop,
|
barbarop,pluseqop,minuseqop,asteriskeqop,slasheqop,
|
||||||
percenteqop,ltlteqop,gtgteqop,andeqop,caroteqop,
|
percenteqop,ltlteqop,gtgteqop,andeqop,caroteqop,
|
||||||
bareqop,poundpoundop,
|
bareqop,poundpoundop,dotdotdotsy,
|
||||||
|
ppnumber, {preprocessing number (pp-token)}
|
||||||
|
otherch, {other non-whitespace char (pp-token)}
|
||||||
eolsy,eofsy, {control characters}
|
eolsy,eofsy, {control characters}
|
||||||
typedef, {user types}
|
typedef, {user types}
|
||||||
uminus,uand,uasterisk, {converted operations}
|
{converted operations}
|
||||||
parameteroper,castoper,opplusplus,opminusminus,
|
uminus,uplus,uand,uasterisk,
|
||||||
|
parameteroper,castoper,opplusplus,opminusminus,compoundliteral,
|
||||||
macroParm); {macro language}
|
macroParm); {macro language}
|
||||||
|
|
||||||
{Note: this enumeration also }
|
{Note: this enumeration also }
|
||||||
|
@ -208,11 +218,15 @@ type
|
||||||
(illegal,ch_special,ch_dash,ch_plus,ch_lt,ch_gt,ch_eq,ch_exc,
|
(illegal,ch_special,ch_dash,ch_plus,ch_lt,ch_gt,ch_eq,ch_exc,
|
||||||
ch_and,ch_bar,ch_dot,ch_white,ch_eol,ch_eof,ch_char,ch_string,
|
ch_and,ch_bar,ch_dot,ch_white,ch_eol,ch_eof,ch_char,ch_string,
|
||||||
ch_asterisk,ch_slash,ch_percent,ch_carot,ch_pound,ch_colon,
|
ch_asterisk,ch_slash,ch_percent,ch_carot,ch_pound,ch_colon,
|
||||||
ch_backslash,letter,digit);
|
ch_backslash,ch_other,letter,digit);
|
||||||
|
|
||||||
|
{prefixes of a character/string literal}
|
||||||
|
charStrPrefixEnum = (prefix_none,prefix_L,prefix_u16,prefix_U32,prefix_u8);
|
||||||
|
|
||||||
tokenSet = set of tokenEnum;
|
tokenSet = set of tokenEnum;
|
||||||
tokenClass = (reservedWord,reservedSymbol,identifier,intConstant,longConstant,
|
tokenClass = (reservedWord,reservedSymbol,identifier,intConstant,longConstant,
|
||||||
longlongConstant,realConstant,stringConstant,macroParameter);
|
longlongConstant,realConstant,stringConstant,otherCharacter,
|
||||||
|
preprocessingNumber,macroParameter);
|
||||||
identPtr = ^identRecord; {^ to a symbol table entry}
|
identPtr = ^identRecord; {^ to a symbol table entry}
|
||||||
tokenType = record {a token}
|
tokenType = record {a token}
|
||||||
kind: tokenEnum; {kind of token}
|
kind: tokenEnum; {kind of token}
|
||||||
|
@ -227,7 +241,10 @@ type
|
||||||
longlongConstant: (qval: longlong);
|
longlongConstant: (qval: longlong);
|
||||||
realConstant : (rval: extended);
|
realConstant : (rval: extended);
|
||||||
stringConstant: (sval: longstringPtr;
|
stringConstant: (sval: longstringPtr;
|
||||||
ispstring: boolean);
|
ispstring: boolean;
|
||||||
|
prefix: charStrPrefixEnum);
|
||||||
|
otherCharacter: (ch: char); {used for preprocessing tokens only}
|
||||||
|
preprocessingNumber: (errCode: integer); {used for pp tokens only}
|
||||||
macroParameter: (pnum: integer);
|
macroParameter: (pnum: integer);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -306,20 +323,24 @@ type
|
||||||
unionType : (fieldList: identPtr; {field list}
|
unionType : (fieldList: identPtr; {field list}
|
||||||
sName: stringPtr; {struct name; for forward refs}
|
sName: stringPtr; {struct name; for forward refs}
|
||||||
constMember: boolean; {does it have a const member?}
|
constMember: boolean; {does it have a const member?}
|
||||||
|
flexibleArrayMember: boolean; {does it have a FAM?}
|
||||||
);
|
);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initializerPtr = ^initializerRecord; {initializers}
|
initializerPtr = ^initializerRecord; {initializers}
|
||||||
initializerRecord = record
|
initializerRecord = record
|
||||||
next: initializerPtr; {next record in the chain}
|
next: initializerPtr; {next record in the chain}
|
||||||
count: integer; {# of duplicate records}
|
disp: longint; {disp within overall object being initialized}
|
||||||
|
count: integer; {# of duplicate records (>1 for bytes only)}
|
||||||
bitdisp: integer; {disp in byte (field lists only)}
|
bitdisp: integer; {disp in byte (field lists only)}
|
||||||
bitsize: integer; {width in bits; 0 for byte sizes}
|
bitsize: integer; {width in bits; 0 for byte sizes}
|
||||||
isStructOrUnion: boolean; {is this a struct or union initializer?}
|
|
||||||
case isConstant: boolean of {is this a constant initializer?}
|
case isConstant: boolean of {is this a constant initializer?}
|
||||||
false: (iTree: tokenPtr);
|
false: (
|
||||||
|
iType: typePtr; {type being initialized}
|
||||||
|
iTree: tokenPtr; {initializer expression}
|
||||||
|
);
|
||||||
true : ( {Note: qVal.lo must overlap iVal}
|
true : ( {Note: qVal.lo must overlap iVal}
|
||||||
case itype: baseTypeEnum of
|
case basetype: baseTypeEnum of
|
||||||
cgByte,
|
cgByte,
|
||||||
cgUByte,
|
cgUByte,
|
||||||
cgWord,
|
cgWord,
|
||||||
|
@ -359,14 +380,20 @@ type
|
||||||
iPtr: initializerPtr; {pointer to the first initializer}
|
iPtr: initializerPtr; {pointer to the first initializer}
|
||||||
isForwardDeclared: boolean; {does this var use a forward declared type?}
|
isForwardDeclared: boolean; {does this var use a forward declared type?}
|
||||||
class: tokenEnum; {storage class}
|
class: tokenEnum; {storage class}
|
||||||
|
used: boolean; {is this identifier used?}
|
||||||
case storage: storageType of
|
case storage: storageType of
|
||||||
stackFrame: (lln: integer); {local label #}
|
stackFrame: (lln: integer; {local label #}
|
||||||
parameter: (pln: integer; {paramater label #}
|
clnext: identPtr); {next compound literal}
|
||||||
pdisp: integer; {disp of parameter}
|
parameter: (pln: integer; {paramater label #}
|
||||||
pnext: identPtr); {next parameter}
|
pdisp: integer; {disp of parameter}
|
||||||
external: ();
|
pnext: identPtr); {next parameter}
|
||||||
|
external: (inlineDefinition: boolean); {(potential) inline definition of function?}
|
||||||
global,private: ();
|
global,private: ();
|
||||||
none: ();
|
none: (
|
||||||
|
case anonMemberField: boolean of {field from an anonymous struct/union member?}
|
||||||
|
true : (anonMember: identPtr); {containing anonymous struct/union}
|
||||||
|
false: ();
|
||||||
|
);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{mini-assembler}
|
{mini-assembler}
|
||||||
|
@ -468,6 +495,9 @@ var
|
||||||
{----}
|
{----}
|
||||||
bofPtr: ptr; {pointer to the start of sourceFile}
|
bofPtr: ptr; {pointer to the start of sourceFile}
|
||||||
chPtr: ptr; {pointer to the next character in the file}
|
chPtr: ptr; {pointer to the next character in the file}
|
||||||
|
changedSourceFile: boolean; {source file changed in function?}
|
||||||
|
cStd: cStandardEnum; {selected C standard}
|
||||||
|
debugSourceFileGS: gsosOutString; {debug source file name}
|
||||||
{debugType is also in SCANNER.ASM}
|
{debugType is also in SCANNER.ASM}
|
||||||
debugType: (stop,break,autogo); {line number debug types}
|
debugType: (stop,break,autogo); {line number debug types}
|
||||||
doingParameters: boolean; {are we processing parm definitions?}
|
doingParameters: boolean; {are we processing parm definitions?}
|
||||||
|
@ -479,9 +509,9 @@ var
|
||||||
infoStringGS: gsosOutString; {language specific command line info}
|
infoStringGS: gsosOutString; {language specific command line info}
|
||||||
intLabel: integer; {last used label number}
|
intLabel: integer; {last used label number}
|
||||||
languageNumber: integer; {our language number}
|
languageNumber: integer; {our language number}
|
||||||
lastLine: 0..maxint; {last line number used by pc_nam}
|
lastLine: 0..maxint4; {last line number used by pc_nam}
|
||||||
liDCBGS: getLInfoDCBGS; {get/set LInfo DCB}
|
liDCBGS: getLInfoDCBGS; {get/set LInfo DCB}
|
||||||
lineNumber: 0..maxint; {source line number}
|
lineNumber: 0..maxint4; {source line number}
|
||||||
nameFound: boolean; {has a pc_nam been generated?}
|
nameFound: boolean; {has a pc_nam been generated?}
|
||||||
nextLocalLabel: integer; {next available local data label number}
|
nextLocalLabel: integer; {next available local data label number}
|
||||||
numErrors: integer; {number of errors in the program}
|
numErrors: integer; {number of errors in the program}
|
||||||
|
@ -489,7 +519,9 @@ var
|
||||||
oldincludeFileGS: gsosOutString; {previous includeFile value}
|
oldincludeFileGS: gsosOutString; {previous includeFile value}
|
||||||
outFileGS: gsosOutString; {keep file name}
|
outFileGS: gsosOutString; {keep file name}
|
||||||
partialFileGS: gsosOutString; {partial compile list}
|
partialFileGS: gsosOutString; {partial compile list}
|
||||||
sourceFileGS: gsosOutString; {debug source file name}
|
pragmaKeepFile: gsosOutStringPtr; {filename specified in #pragma keep}
|
||||||
|
sourceFileGS: gsosOutString; {presumed source file name}
|
||||||
|
strictMode: boolean; {strictly follow standard, without extensions?}
|
||||||
tempList: tempPtr; {list of temp work variables}
|
tempList: tempPtr; {list of temp work variables}
|
||||||
longlong0: longlong; {the value 0 as a longlong}
|
longlong0: longlong; {the value 0 as a longlong}
|
||||||
longlong1: longlong; {the value 1 as a longlong}
|
longlong1: longlong; {the value 1 as a longlong}
|
||||||
|
@ -505,16 +537,13 @@ var
|
||||||
isConstant: boolean; {is the initializer expression constant?}
|
isConstant: boolean; {is the initializer expression constant?}
|
||||||
expressionIsLongLong: boolean; {is the last constant expression long long?}
|
expressionIsLongLong: boolean; {is the last constant expression long long?}
|
||||||
|
|
||||||
{type specifier results}
|
|
||||||
{----------------------}
|
|
||||||
typeSpec: typePtr; {type specifier}
|
|
||||||
|
|
||||||
{flags}
|
{flags}
|
||||||
{-----}
|
{-----}
|
||||||
codegenStarted: boolean; {have we started the code generator?}
|
codegenStarted: boolean; {have we started the code generator?}
|
||||||
doingFunction: boolean; {are we processing a function?}
|
doingFunction: boolean; {are we processing a function?}
|
||||||
doingPartial: boolean; {are we doing a partial compile?}
|
doingPartial: boolean; {are we doing a partial compile?}
|
||||||
enterEditor: boolean; {enter editor on terminal errors?}
|
enterEditor: boolean; {enter editor on terminal errors?}
|
||||||
|
filenamesInErrors: boolean; {print filenames in error messages?}
|
||||||
foundFunction: boolean; {has a function been found?}
|
foundFunction: boolean; {has a function been found?}
|
||||||
lint: integer; {lint flags}
|
lint: integer; {lint flags}
|
||||||
list: boolean; {generate source listing?}
|
list: boolean; {generate source listing?}
|
||||||
|
@ -668,7 +697,7 @@ implementation
|
||||||
const
|
const
|
||||||
{Note: maxLabel is also defined in cgi.pas}
|
{Note: maxLabel is also defined in cgi.pas}
|
||||||
{Note: maxlabel is also defined in CGC.asm}
|
{Note: maxlabel is also defined in CGC.asm}
|
||||||
maxLabel = 3200; {max # compiler generated labels}
|
maxLabel = 3275; {max # compiler generated labels}
|
||||||
|
|
||||||
{spinner}
|
{spinner}
|
||||||
{-------}
|
{-------}
|
||||||
|
@ -809,6 +838,8 @@ var
|
||||||
msgGS: gsosInString; {message}
|
msgGS: gsosInString; {message}
|
||||||
|
|
||||||
begin {ExitToEditor}
|
begin {ExitToEditor}
|
||||||
|
if disp < 0 then {sanity check disp}
|
||||||
|
disp := 0;
|
||||||
msgGS.size := length(msg^); {set up the error message}
|
msgGS.size := length(msg^); {set up the error message}
|
||||||
msgGS.theString := msg^;
|
msgGS.theString := msg^;
|
||||||
liDCBGS.org := disp; {mark the error}
|
liDCBGS.org := disp; {mark the error}
|
||||||
|
@ -986,8 +1017,9 @@ case errnum of {print the error}
|
||||||
8 : msg := 'you cannot change languages from an included file';
|
8 : msg := 'you cannot change languages from an included file';
|
||||||
9 : msg := concat('Error writing ', objFile.theString.theString);
|
9 : msg := concat('Error writing ', objFile.theString.theString);
|
||||||
10: msg := 'ORCA/C requires version 2.0 or later of the shell';
|
10: msg := 'ORCA/C requires version 2.0 or later of the shell';
|
||||||
11: msg := 'The program is too large to compile to memory -- use Compile to Disk';
|
{11: msg := 'The program is too large to compile to memory -- use Compile to Disk';}
|
||||||
12: msg := 'Invalid sym file detected. Re-run ORCA/C to proceed.';
|
12: msg := 'Invalid sym file detected. Re-run ORCA/C to proceed.';
|
||||||
|
13: msg := 'file name or command-line parameter is too long';
|
||||||
otherwise: begin
|
otherwise: begin
|
||||||
msg := '';
|
msg := '';
|
||||||
Error(57);
|
Error(57);
|
||||||
|
|
95
CGC.asm
95
CGC.asm
|
@ -1,56 +1,29 @@
|
||||||
mcopy cgc.macros
|
mcopy cgc.macros
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
* CnvSX - Convert floating point to SANE extended
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* rec - pointer to a record
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
CnvSX start cg
|
|
||||||
rec equ 4 record containing values
|
|
||||||
rec_real equ 0 disp to real (extended) value
|
|
||||||
rec_ext equ 10 disp to extended (SANE) value
|
|
||||||
|
|
||||||
tsc set up DP
|
|
||||||
phd
|
|
||||||
tcd
|
|
||||||
ph4 rec push addr of real number
|
|
||||||
clc push addr of SANE number
|
|
||||||
lda rec
|
|
||||||
adc #rec_ext
|
|
||||||
tax
|
|
||||||
lda rec+2
|
|
||||||
adc #0
|
|
||||||
pha
|
|
||||||
phx
|
|
||||||
fx2x convert TOS to extended
|
|
||||||
move4 0,4 return
|
|
||||||
pld
|
|
||||||
pla
|
|
||||||
pla
|
|
||||||
rtl
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* CnvSC - Convert floating point to SANE comp
|
* CnvSC - Convert floating point to SANE comp
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* rec - pointer to a record
|
* rec - pointer to a record
|
||||||
*
|
*
|
||||||
|
* Note: This avoids calling FX2C on negative numbers,
|
||||||
|
* because it is buggy for certain values.
|
||||||
|
*
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
CnvSC start cg
|
CnvSC start cg
|
||||||
rec equ 4 record containing values
|
rec equ 4 record containing values
|
||||||
rec_real equ 0 disp to real (extended) value
|
rec_real equ 0 disp to real (extended) value
|
||||||
rec_ext equ 10 disp to extended (SANE) value
|
rec_cmp equ 10 disp to comp (SANE) value
|
||||||
rec_cmp equ 20 disp to comp (SANE) value
|
|
||||||
|
|
||||||
tsc set up DP
|
tsc set up DP
|
||||||
phd
|
phd
|
||||||
tcd
|
tcd
|
||||||
|
ldy #rec_real+8
|
||||||
|
lda [rec],y
|
||||||
|
pha save sign of real number
|
||||||
|
and #$7fff
|
||||||
|
sta [rec],y set sign of real number to positive
|
||||||
ph4 rec push addr of real number
|
ph4 rec push addr of real number
|
||||||
clc push addr of SANE comp number
|
clc push addr of SANE comp number
|
||||||
lda rec
|
lda rec
|
||||||
|
@ -61,7 +34,32 @@ rec_cmp equ 20 disp to comp (SANE) value
|
||||||
pha
|
pha
|
||||||
phx
|
phx
|
||||||
fx2c convert TOS to SANE comp number
|
fx2c convert TOS to SANE comp number
|
||||||
move4 0,4 return
|
pla
|
||||||
|
bpl ret if real number was negative
|
||||||
|
ldy #rec_real+8 restore original sign of real number
|
||||||
|
sta [rec],y
|
||||||
|
sec negate the comp value
|
||||||
|
ldy #rec_cmp
|
||||||
|
ldx #0
|
||||||
|
txa
|
||||||
|
sbc [rec],y
|
||||||
|
sta [rec],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
txa
|
||||||
|
sbc [rec],y
|
||||||
|
sta [rec],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
txa
|
||||||
|
sbc [rec],y
|
||||||
|
sta [rec],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
txa
|
||||||
|
sbc [rec],y
|
||||||
|
sta [rec],y
|
||||||
|
ret move4 0,4 return
|
||||||
pld
|
pld
|
||||||
pla
|
pla
|
||||||
pla
|
pla
|
||||||
|
@ -202,7 +200,7 @@ rval ds 10
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
InitLabels start cg
|
InitLabels start cg
|
||||||
maxLabel equ 3200
|
maxLabel equ 3275
|
||||||
|
|
||||||
! with labelTab[0] do begin
|
! with labelTab[0] do begin
|
||||||
lda #-1 val := -1;
|
lda #-1 val := -1;
|
||||||
|
@ -219,3 +217,24 @@ maxLabel equ 3200
|
||||||
stz intLabel intLabel := 0;
|
stz intLabel intLabel := 0;
|
||||||
rtl
|
rtl
|
||||||
end
|
end
|
||||||
|
datachk on
|
||||||
|
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
* function SignBit (val: extended): integer;
|
||||||
|
*
|
||||||
|
* returns the sign bit of a floating-point number
|
||||||
|
* (0 for positive, 1 for negative)
|
||||||
|
*
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
SignBit start cg
|
||||||
|
|
||||||
|
subroutine (10:val),0
|
||||||
|
|
||||||
|
asl val+8
|
||||||
|
stz val
|
||||||
|
rol val
|
||||||
|
|
||||||
|
return 2:val
|
||||||
|
end
|
||||||
|
|
88
CGC.macros
88
CGC.macros
|
@ -175,12 +175,6 @@
|
||||||
sta 2+&op
|
sta 2+&op
|
||||||
mend
|
mend
|
||||||
MACRO
|
MACRO
|
||||||
&LAB FX2X
|
|
||||||
&LAB PEA $0010
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FX2C
|
&LAB FX2C
|
||||||
&LAB PEA $0510
|
&LAB PEA $0510
|
||||||
LDX #$090A
|
LDX #$090A
|
||||||
|
@ -435,3 +429,85 @@
|
||||||
.g
|
.g
|
||||||
mnote "Missing closing '}'",16
|
mnote "Missing closing '}'",16
|
||||||
mend
|
mend
|
||||||
|
macro
|
||||||
|
&l add4 &m1,&m2,&m3
|
||||||
|
lclb &yistwo
|
||||||
|
lclc &c
|
||||||
|
&l ~setm
|
||||||
|
aif c:&m3,.a
|
||||||
|
&c amid "&m2",1,1
|
||||||
|
aif "&c"<>"#",.a
|
||||||
|
&c amid "&m1",1,1
|
||||||
|
aif "&c"="{",.a
|
||||||
|
aif "&c"="[",.a
|
||||||
|
&c amid "&m2",2,l:&m2-1
|
||||||
|
aif &c>=65536,.a
|
||||||
|
clc
|
||||||
|
~lda &m1
|
||||||
|
~op adc,&m2
|
||||||
|
~sta &m1
|
||||||
|
bcc ~&SYSCNT
|
||||||
|
~op.h inc,&m1
|
||||||
|
~&SYSCNT anop
|
||||||
|
ago .c
|
||||||
|
.a
|
||||||
|
aif c:&m3,.b
|
||||||
|
lclc &m3
|
||||||
|
&m3 setc &m1
|
||||||
|
.b
|
||||||
|
clc
|
||||||
|
~lda &m1
|
||||||
|
~op adc,&m2
|
||||||
|
~sta &m3
|
||||||
|
~lda.h &m1
|
||||||
|
~op.h adc,&m2
|
||||||
|
~sta.h &m3
|
||||||
|
.c
|
||||||
|
~restm
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&l ~op &opc,&op
|
||||||
|
lclc &c
|
||||||
|
&c amid "&op",1,1
|
||||||
|
aif "&c"<>"{",.b
|
||||||
|
&c amid "&op",l:&op,1
|
||||||
|
aif "&c"="}",.a
|
||||||
|
mnote "Missing closing '}'",2
|
||||||
|
&op setc &op}
|
||||||
|
.a
|
||||||
|
&op amid "&op",2,l:&op-2
|
||||||
|
&op setc (&op)
|
||||||
|
.b
|
||||||
|
&l &opc &op
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&l ~op.h &opc,&op
|
||||||
|
&l anop
|
||||||
|
lclc &c
|
||||||
|
&c amid "&op",1,1
|
||||||
|
aif "&c"="[",.b
|
||||||
|
aif "&c"<>"{",.d
|
||||||
|
&c amid "&op",l:&op,1
|
||||||
|
aif "&c"="}",.a
|
||||||
|
mnote "Missing closing '}'",2
|
||||||
|
&op setc &op}
|
||||||
|
.a
|
||||||
|
&op amid "&op",2,l:&op-2
|
||||||
|
&op setc (&op)
|
||||||
|
.b
|
||||||
|
aif &yistwo,.c
|
||||||
|
&yistwo setb 1
|
||||||
|
ldy #2
|
||||||
|
.c
|
||||||
|
&op setc "&op,y"
|
||||||
|
&opc &op
|
||||||
|
mexit
|
||||||
|
.d
|
||||||
|
aif "&c"<>"#",.e
|
||||||
|
&op amid "&op",2,l:&op-1
|
||||||
|
&op setc "#^&op"
|
||||||
|
&opc &op
|
||||||
|
mexit
|
||||||
|
.e
|
||||||
|
&opc 2+&op
|
||||||
|
mend
|
||||||
|
|
18
CGC.pas
18
CGC.pas
|
@ -31,9 +31,8 @@ uses CCommon, CGI;
|
||||||
type
|
type
|
||||||
{pcode code generation}
|
{pcode code generation}
|
||||||
{---------------------}
|
{---------------------}
|
||||||
realrec = record {used to convert from real to in-SANE}
|
realrec = record {used to convert from real to comp}
|
||||||
itsReal: extended;
|
itsReal: extended;
|
||||||
inSANE: packed array[1..10] of byte;
|
|
||||||
inCOMP: packed array[1..8] of byte;
|
inCOMP: packed array[1..8] of byte;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -58,15 +57,6 @@ procedure CnvSC (rec: realrec); extern;
|
||||||
{ has space for the result }
|
{ has space for the result }
|
||||||
|
|
||||||
|
|
||||||
procedure CnvSX (rec: realrec); extern;
|
|
||||||
|
|
||||||
{ convert a real number to SANE extended format }
|
|
||||||
{ }
|
|
||||||
{ parameters: }
|
|
||||||
{ rec - record containing the value to convert; also }
|
|
||||||
{ has space for the result }
|
|
||||||
|
|
||||||
|
|
||||||
procedure CnvXLL (var result: longlong; val: extended); extern;
|
procedure CnvXLL (var result: longlong; val: extended); extern;
|
||||||
|
|
||||||
{ convert a real number to long long }
|
{ convert a real number to long long }
|
||||||
|
@ -107,6 +97,12 @@ procedure InitLabels; extern;
|
||||||
{ }
|
{ }
|
||||||
{ Note: also defined in CGI.pas }
|
{ Note: also defined in CGI.pas }
|
||||||
|
|
||||||
|
|
||||||
|
function SignBit (val: extended): integer; extern;
|
||||||
|
|
||||||
|
{ returns the sign bit of a floating-point number }
|
||||||
|
{ (0 for positive, 1 for negative) }
|
||||||
|
|
||||||
{-- These routines are defined in the compiler, but used from cg --}
|
{-- These routines are defined in the compiler, but used from cg --}
|
||||||
|
|
||||||
function Calloc (bytes: integer): ptr; extern;
|
function Calloc (bytes: integer): ptr; extern;
|
||||||
|
|
56
CGI.Comments
56
CGI.Comments
|
@ -34,7 +34,8 @@
|
||||||
{ }
|
{ }
|
||||||
{ pc_lnm - line number }
|
{ pc_lnm - line number }
|
||||||
{ }
|
{ }
|
||||||
{ Gen2(pc_lnm, lc, flag) }
|
{ Gen2Name(pc_lnm, lc, flag, nil) }
|
||||||
|
{ Gen2Name(pc_lnm, lc, flag, pointer(filename)) }
|
||||||
{ }
|
{ }
|
||||||
{ Sets the current line number for the traceback facility and }
|
{ Sets the current line number for the traceback facility and }
|
||||||
{ debugger. This p-code should only be generated after the }
|
{ debugger. This p-code should only be generated after the }
|
||||||
|
@ -46,13 +47,17 @@
|
||||||
{ 1 - break point }
|
{ 1 - break point }
|
||||||
{ 2 - auto-go }
|
{ 2 - auto-go }
|
||||||
{ }
|
{ }
|
||||||
|
{ If filename is not nil, it is a pointer to a GS/OS output }
|
||||||
|
{ string giving the source file name. This is used to change }
|
||||||
|
{ the file name within a function that spans multiple files. }
|
||||||
|
{ }
|
||||||
{ }
|
{ }
|
||||||
{ pc_mov - move memory }
|
{ pc_mov - move memory }
|
||||||
{ }
|
{ }
|
||||||
{ Gen2(pc_mov, banks, bytes) }
|
{ Gen2(pc_mov, banks, bytes) }
|
||||||
{ }
|
{ }
|
||||||
{ The top of stack contains a source address, and TOS-1 has a }
|
{ The top of stack contains a source address, and TOS-1 has a }
|
||||||
{ destination address. The destination address is removed, }
|
{ destination address. The source address is removed, }
|
||||||
{ and BYTES bytes are moved from the source to the }
|
{ and BYTES bytes are moved from the source to the }
|
||||||
{ destination. BANKS is the number of full banks to move; it }
|
{ destination. BANKS is the number of full banks to move; it }
|
||||||
{ is used when 64K or more must be moved. The memory areas }
|
{ is used when 64K or more must be moved. The memory areas }
|
||||||
|
@ -71,7 +76,7 @@
|
||||||
{ debugFlag - are we generating debug code? }
|
{ debugFlag - are we generating debug code? }
|
||||||
{ profileFlag - are we profiling? }
|
{ profileFlag - are we profiling? }
|
||||||
{ traceBack - are we doing tracebacks? }
|
{ traceBack - are we doing tracebacks? }
|
||||||
{ sourceFile - current source file name }
|
{ debugSourceFileGS - current source file name }
|
||||||
{ }
|
{ }
|
||||||
{ }
|
{ }
|
||||||
{ pc_nat - native code generation }
|
{ pc_nat - native code generation }
|
||||||
|
@ -191,6 +196,15 @@
|
||||||
{ a SIZE bit value. Extra bits are dropped. }
|
{ a SIZE bit value. Extra bits are dropped. }
|
||||||
{ }
|
{ }
|
||||||
{ }
|
{ }
|
||||||
|
{ pc_ckp - check for null pointer }
|
||||||
|
{ }
|
||||||
|
{ Gen0(pc_ckp) }
|
||||||
|
{ Gen0(pc_ckn) }
|
||||||
|
{ }
|
||||||
|
{ Make sure a pointer value is not null. The pc_ckp form }
|
||||||
|
{ checks the value at tos; pc_ckn checks the value at tos-1. }
|
||||||
|
{ }
|
||||||
|
{ }
|
||||||
{ pc_cop - copy to a local variable }
|
{ pc_cop - copy to a local variable }
|
||||||
{ }
|
{ }
|
||||||
{ Gen2t(pc_cop, label, disp, type) }
|
{ Gen2t(pc_cop, label, disp, type) }
|
||||||
|
@ -301,6 +315,14 @@
|
||||||
{ the stack. }
|
{ the stack. }
|
||||||
{ }
|
{ }
|
||||||
{ }
|
{ }
|
||||||
|
{ pc_fix - fix a floating-point variable }
|
||||||
|
{ }
|
||||||
|
{ Gen1t(pc_fix, lab, type) }
|
||||||
|
{ }
|
||||||
|
{ Change a floating-point value (generally a passed parameter) }
|
||||||
|
{ from extended to cgReal, cgDouble,or cgComp. }
|
||||||
|
{ }
|
||||||
|
{ }
|
||||||
{ pc_gil - increment and load from a global variable }
|
{ pc_gil - increment and load from a global variable }
|
||||||
{ pc_gli - load a global variable, then inc the original }
|
{ pc_gli - load a global variable, then inc the original }
|
||||||
{ pc_gdl - decrement and load from a global variable }
|
{ pc_gdl - decrement and load from a global variable }
|
||||||
|
@ -344,11 +366,12 @@
|
||||||
{ }
|
{ }
|
||||||
{ pc_ind - load indirect }
|
{ pc_ind - load indirect }
|
||||||
{ }
|
{ }
|
||||||
{ Gen1t (pc_ind, disp, type) }
|
{ Gen2t (pc_ind, volatile, disp, type) }
|
||||||
{ }
|
{ }
|
||||||
{ A value of type TYPE is loaded from DISP bytes past the }
|
{ A value of type TYPE is loaded from DISP bytes past the }
|
||||||
{ address that is on the evaluation stack. The address is }
|
{ address that is on the evaluation stack. The address is }
|
||||||
{ removed from the stack and replaced with the value. }
|
{ removed from the stack and replaced with the value. }
|
||||||
|
{ VOLATILE is non-zero for a volatile load, or 0 otherwise. }
|
||||||
{ }
|
{ }
|
||||||
{ }
|
{ }
|
||||||
{ pc_ior - logical or }
|
{ pc_ior - logical or }
|
||||||
|
@ -407,7 +430,8 @@
|
||||||
{ GenS(pc_lca, str) }
|
{ GenS(pc_lca, str) }
|
||||||
{ }
|
{ }
|
||||||
{ Loads the address of a string onto the stack. Str is a }
|
{ Loads the address of a string onto the stack. Str is a }
|
||||||
{ pointer to a string constant. }
|
{ pointer to a string constant. No null terminator is added; }
|
||||||
|
{ it should be explicitly included in str if desired. }
|
||||||
{ }
|
{ }
|
||||||
{ }
|
{ }
|
||||||
{ pc_lda - load a local address }
|
{ pc_lda - load a local address }
|
||||||
|
@ -780,22 +804,36 @@
|
||||||
{ into the stack frame. }
|
{ into the stack frame. }
|
||||||
{ }
|
{ }
|
||||||
{ }
|
{ }
|
||||||
|
{ pc_rev - return a value from a subroutine }
|
||||||
|
{ }
|
||||||
|
{ Gen0t(pc_rev, type) }
|
||||||
|
{ }
|
||||||
|
{ This pcode is used to return from a function. The type is }
|
||||||
|
{ the type of the function, and is used to tell the code }
|
||||||
|
{ generator what type of value to return. It may be cgByte, }
|
||||||
|
{ cgUByte, cgWord, cgUWord, cgLong, or cgULong. The value }
|
||||||
|
{ to return is removed from the evaluation stack. }
|
||||||
|
{ }
|
||||||
|
{ }
|
||||||
{ pc_cui - call user procedure, indirect }
|
{ pc_cui - call user procedure, indirect }
|
||||||
{ }
|
{ }
|
||||||
{ Gen1t(pc_cui, repair, ftype) }
|
{ Gen1t(pc_cui, repair, ftype) }
|
||||||
{ }
|
{ }
|
||||||
{ Calls a user procedure or function through the address on }
|
{ Calls a user procedure or function through the address on }
|
||||||
{ the top of the evaluation stack. FTYPE is the return type. }
|
{ the top of the evaluation stack. FTYPE is the return type. }
|
||||||
{ Repair is 1 if stack repair should be forced, and 0 if not. }
|
{ Repair is 1 if stack repair should be forced, -1 if stack }
|
||||||
|
{ repair and checking should be disabled, or 0 if the regular }
|
||||||
|
{ settings should be used. }
|
||||||
{ }
|
{ }
|
||||||
{ }
|
{ }
|
||||||
{ pc_cup - call user procedure }
|
{ pc_cup - call user procedure }
|
||||||
{ }
|
{ }
|
||||||
{ Gen1tName(pc_cup, repair, name, ftype) }
|
{ Gen1tName(pc_cup, repair, ftype, name) }
|
||||||
{ }
|
{ }
|
||||||
{ Calls a user procedure or function. Ftype is the type. }
|
{ Calls a user procedure or function. Ftype is the type. }
|
||||||
{ Repair is 1 if stack repair should be forced, and 0 if not. }
|
{ Repair is 1 if stack repair should be forced, -1 if stack }
|
||||||
{ NAME is the name of the procedure. }
|
{ repair and checking should be disabled, or 0 if the regular }
|
||||||
|
{ settings should be used. NAME is the name of the procedure. }
|
||||||
{ }
|
{ }
|
||||||
{ }
|
{ }
|
||||||
{ dc_loc - define local label }
|
{ dc_loc - define local label }
|
||||||
|
|
17
CGI.Debug
17
CGI.Debug
|
@ -121,17 +121,25 @@ opt[pc_bqx] := 'bqx';
|
||||||
opt[pc_baq] := 'baq';
|
opt[pc_baq] := 'baq';
|
||||||
opt[pc_bnq] := 'bnq';
|
opt[pc_bnq] := 'bnq';
|
||||||
opt[pc_ngq] := 'ngq';
|
opt[pc_ngq] := 'ngq';
|
||||||
|
opt[pc_adq] := 'adq';
|
||||||
|
opt[pc_sbq] := 'sbq';
|
||||||
opt[pc_mpq] := 'mpq';
|
opt[pc_mpq] := 'mpq';
|
||||||
opt[pc_umq] := 'umq';
|
opt[pc_umq] := 'umq';
|
||||||
opt[pc_dvq] := 'dvq';
|
opt[pc_dvq] := 'dvq';
|
||||||
opt[pc_udq] := 'udq';
|
opt[pc_udq] := 'udq';
|
||||||
opt[pc_mdq] := 'mdq';
|
opt[pc_mdq] := 'mdq';
|
||||||
opt[pc_uqm] := 'uqm';
|
opt[pc_uqm] := 'uqm';
|
||||||
|
opt[pc_slq] := 'slq';
|
||||||
|
opt[pc_sqr] := 'sqr';
|
||||||
|
opt[pc_wsr] := 'wsr';
|
||||||
opt[pc_rbo] := 'rbo';
|
opt[pc_rbo] := 'rbo';
|
||||||
|
opt[pc_rev] := 'rev';
|
||||||
|
opt[pc_ckp] := 'ckp';
|
||||||
|
opt[pc_ckn] := 'ckn';
|
||||||
end; {InitWriteCode}
|
end; {InitWriteCode}
|
||||||
|
|
||||||
|
|
||||||
procedure PrintDAG (tag: stringPtr; code: icptr);
|
procedure PrintDAG {tag: stringPtr; code: icptr};
|
||||||
|
|
||||||
{ print a DAG }
|
{ print a DAG }
|
||||||
{ }
|
{ }
|
||||||
|
@ -273,13 +281,16 @@ with code^ do
|
||||||
pc_uml,pc_adr,pc_dvr,pc_mpr,pc_adi,pc_sbi,pc_mpi,pc_dvi,
|
pc_uml,pc_adr,pc_dvr,pc_mpr,pc_adi,pc_sbi,pc_mpi,pc_dvi,
|
||||||
pc_umi,pc_shl,pc_nop,pc_and,pc_lnd,pc_bnd,pc_lor,pc_ior,pc_bxr,
|
pc_umi,pc_shl,pc_nop,pc_and,pc_lnd,pc_bnd,pc_lor,pc_ior,pc_bxr,
|
||||||
pc_bnt,pc_blx,pc_bnl,pc_ngi,pc_ngl,pc_ngr,pc_ixa,pc_mdl,
|
pc_bnt,pc_blx,pc_bnl,pc_ngi,pc_ngl,pc_ngr,pc_ixa,pc_mdl,
|
||||||
pc_udi,pc_udl,pc_bqr,pc_bqx,pc_baq: ;
|
pc_udi,pc_udl,pc_bqr,pc_bqx,pc_baq,pc_bnq,pc_ngq,pc_adq,pc_sbq,
|
||||||
|
pc_mpq,pc_umq,pc_dvq,pc_udq,pc_mdq,pc_uqm,pc_slq,pc_sqr,pc_wsr,
|
||||||
|
pc_rbo,pc_sll,pc_shr,pc_usr,pc_slr,pc_vsr,pc_ckp,pc_ckn: ;
|
||||||
|
|
||||||
|
|
||||||
dc_prm:
|
dc_prm:
|
||||||
write(' ', q:1, ':', r:1, ':', s:1);
|
write(' ', q:1, ':', r:1, ':', s:1);
|
||||||
|
|
||||||
pc_equ,pc_neq,pc_geq,pc_leq,pc_grt,pc_les,pc_pop,pc_ret,pc_bno,
|
pc_equ,pc_neq,pc_geq,pc_leq,pc_grt,pc_les,pc_pop,pc_ret,pc_bno,
|
||||||
pc_cpi,pc_sto,pc_tri,pc_stk,pc_idl,pc_iil,pc_ili,pc_ild:
|
pc_cpi,pc_sto,pc_tri,pc_stk,pc_idl,pc_iil,pc_ili,pc_ild,pc_rev:
|
||||||
WriteType(optype);
|
WriteType(optype);
|
||||||
|
|
||||||
pc_cnv,pc_cnn: begin
|
pc_cnv,pc_cnn: begin
|
||||||
|
|
206
CGI.pas
206
CGI.pas
|
@ -33,17 +33,22 @@ const
|
||||||
cge1 = 57; {compiler error}
|
cge1 = 57; {compiler error}
|
||||||
cge2 = 58; {implementation restriction: too many local labels}
|
cge2 = 58; {implementation restriction: too many local labels}
|
||||||
cge3 = 60; {implementation restriction: string space exhausted}
|
cge3 = 60; {implementation restriction: string space exhausted}
|
||||||
|
cge4 = 188; {local variable out of range for DP addressing}
|
||||||
|
|
||||||
{65816 native code generation}
|
{65816 native code generation}
|
||||||
{----------------------------}
|
{----------------------------}
|
||||||
{instruction modifier flags}
|
{instruction modifier flags}
|
||||||
shift8 = 1; {shift operand left 8 bits}
|
shift8 = 1; {shift operand right 8 bits}
|
||||||
shift16 = 2; {shift operand left 16 bits}
|
shift16 = 2; {shift operand right 16 bits}
|
||||||
toolCall = 4; {generate a tool call}
|
toolCall = 4; {generate a tool call}
|
||||||
stringReference = 8; {generate a string reference}
|
stringReference = 8; {generate a string reference}
|
||||||
isPrivate = 32; {is the label private?}
|
isPrivate = 32; {is the label private?}
|
||||||
constantOpnd = 64; {the absolute operand is a constant}
|
constantOpnd = 64; {the absolute operand is a constant}
|
||||||
localLab = 128; {the operand is a local lab}
|
localLab = 128; {the operand is a local lab}
|
||||||
|
forFlags = 256; {instruction used for effect on flags only}
|
||||||
|
subtract1 = 512; {subtract 1 from address operand}
|
||||||
|
shiftLeft8 = 1024; {shift operand left 8 bits}
|
||||||
|
labelUsedOnce = 2048; {only one branch targets this label}
|
||||||
|
|
||||||
m_adc_abs = $6D; {op code #s for 65816 instructions}
|
m_adc_abs = $6D; {op code #s for 65816 instructions}
|
||||||
m_adc_dir = $65;
|
m_adc_dir = $65;
|
||||||
|
@ -67,6 +72,7 @@ const
|
||||||
m_bpl = $10;
|
m_bpl = $10;
|
||||||
m_bra = $80;
|
m_bra = $80;
|
||||||
m_brl = $82;
|
m_brl = $82;
|
||||||
|
m_bvc = $50;
|
||||||
m_bvs = $70;
|
m_bvs = $70;
|
||||||
m_clc = $18;
|
m_clc = $18;
|
||||||
m_cmp_abs = $CD;
|
m_cmp_abs = $CD;
|
||||||
|
@ -81,6 +87,7 @@ const
|
||||||
m_cpx_abs = 236;
|
m_cpx_abs = 236;
|
||||||
m_cpx_dir = 228;
|
m_cpx_dir = 228;
|
||||||
m_cpx_imm = 224;
|
m_cpx_imm = 224;
|
||||||
|
m_cpy_imm = $C0;
|
||||||
m_dea = 58;
|
m_dea = 58;
|
||||||
m_dec_abs = 206;
|
m_dec_abs = 206;
|
||||||
m_dec_absX = $DE;
|
m_dec_absX = $DE;
|
||||||
|
@ -102,6 +109,7 @@ const
|
||||||
m_inx = 232;
|
m_inx = 232;
|
||||||
m_iny = 200;
|
m_iny = 200;
|
||||||
m_jml = 92;
|
m_jml = 92;
|
||||||
|
m_jmp_indX = $7C;
|
||||||
m_jsl = 34;
|
m_jsl = 34;
|
||||||
m_lda_abs = 173;
|
m_lda_abs = 173;
|
||||||
m_lda_absx = 189;
|
m_lda_absx = 189;
|
||||||
|
@ -147,6 +155,8 @@ const
|
||||||
m_ply = 122;
|
m_ply = 122;
|
||||||
m_plp = 40;
|
m_plp = 40;
|
||||||
m_rep = 194;
|
m_rep = 194;
|
||||||
|
m_rol_a = $2A;
|
||||||
|
m_ror_a = $6A;
|
||||||
m_rtl = 107;
|
m_rtl = 107;
|
||||||
m_rts = 96;
|
m_rts = 96;
|
||||||
m_sbc_abs = 237;
|
m_sbc_abs = 237;
|
||||||
|
@ -199,17 +209,22 @@ const
|
||||||
d_wrd = 261;
|
d_wrd = 261;
|
||||||
d_sym = 262;
|
d_sym = 262;
|
||||||
d_cns = 263;
|
d_cns = 263;
|
||||||
|
d_dcb = 264;
|
||||||
|
d_dcw = 265;
|
||||||
|
d_dcl = 266;
|
||||||
|
|
||||||
max_opcode = 263;
|
max_opcode = 266;
|
||||||
|
|
||||||
|
asmFlag = $8000; {or'd with opcode to indicate asm code}
|
||||||
|
|
||||||
{Code Generation}
|
{Code Generation}
|
||||||
{---------------}
|
{---------------}
|
||||||
maxCBuff = 191; {length of constant buffer}
|
maxCBuff = 191; {length of constant buffer}
|
||||||
{Note: maxlabel is also defined in CCommon.pas}
|
{Note: maxlabel is also defined in CCommon.pas}
|
||||||
{Note: maxlabel is also defined in CGC.asm}
|
{Note: maxlabel is also defined in CGC.asm}
|
||||||
maxLabel = 3200; {max # of internal labels}
|
maxLabel = 3275; {max # of internal labels}
|
||||||
maxLocalLabel = 220; {max # local variables}
|
maxLocalLabel = 512; {max # local variables}
|
||||||
maxString = 12500; {max # chars in string space}
|
maxString = 32760; {max # chars in string space}
|
||||||
|
|
||||||
{size of internal types}
|
{size of internal types}
|
||||||
{----------------------}
|
{----------------------}
|
||||||
|
@ -225,6 +240,7 @@ const
|
||||||
|
|
||||||
type
|
type
|
||||||
segNameType = packed array[1..10] of char; {segment name}
|
segNameType = packed array[1..10] of char; {segment name}
|
||||||
|
stringSpaceType = packed array[1..maxstring] of char; {string space}
|
||||||
|
|
||||||
{p code}
|
{p code}
|
||||||
{------}
|
{------}
|
||||||
|
@ -242,7 +258,8 @@ type
|
||||||
pc_gli,pc_gdl,pc_gld,pc_cpi,pc_tri,pc_lbu,pc_lbf,pc_sbf,pc_cbf,dc_cns,
|
pc_gli,pc_gdl,pc_gld,pc_cpi,pc_tri,pc_lbu,pc_lbf,pc_sbf,pc_cbf,dc_cns,
|
||||||
dc_prm,pc_nat,pc_bno,pc_nop,pc_psh,pc_ili,pc_iil,pc_ild,pc_idl,
|
dc_prm,pc_nat,pc_bno,pc_nop,pc_psh,pc_ili,pc_iil,pc_ild,pc_idl,
|
||||||
pc_bqr,pc_bqx,pc_baq,pc_bnq,pc_ngq,pc_adq,pc_sbq,pc_mpq,pc_umq,pc_dvq,
|
pc_bqr,pc_bqx,pc_baq,pc_bnq,pc_ngq,pc_adq,pc_sbq,pc_mpq,pc_umq,pc_dvq,
|
||||||
pc_udq,pc_mdq,pc_uqm,pc_slq,pc_sqr,pc_wsr,pc_rbo);
|
pc_udq,pc_mdq,pc_uqm,pc_slq,pc_sqr,pc_wsr,pc_rbo,pc_fix,pc_rev,pc_ckp,
|
||||||
|
pc_ckn);
|
||||||
|
|
||||||
{intermediate code}
|
{intermediate code}
|
||||||
{-----------------}
|
{-----------------}
|
||||||
|
@ -267,11 +284,17 @@ type
|
||||||
cgDouble,
|
cgDouble,
|
||||||
cgComp,
|
cgComp,
|
||||||
cgExtended : (rval: extended);
|
cgExtended : (rval: extended);
|
||||||
cgString : (str: longStringPtr);
|
cgString : (
|
||||||
|
case isByteSeq: boolean of
|
||||||
|
false : (str: longStringPtr);
|
||||||
|
true : (data: ptr; len: longint);
|
||||||
|
);
|
||||||
cgVoid,
|
cgVoid,
|
||||||
ccPointer : (pval: longint; pstr: longStringPtr);
|
ccPointer : (pval: longint; pstr: longStringPtr);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
codeRef = icptr; {reference to a code location}
|
||||||
|
|
||||||
{basic blocks}
|
{basic blocks}
|
||||||
{------------}
|
{------------}
|
||||||
iclist = ^iclistRecord; {used to form lists of records}
|
iclist = ^iclistRecord; {used to form lists of records}
|
||||||
|
@ -317,6 +340,7 @@ var
|
||||||
{quality or characteristics of }
|
{quality or characteristics of }
|
||||||
{code }
|
{code }
|
||||||
{------------------------------}
|
{------------------------------}
|
||||||
|
checkNullPointers: boolean; {check for null pointer dereferences?}
|
||||||
checkStack: boolean; {check stack for stack errors?}
|
checkStack: boolean; {check stack for stack errors?}
|
||||||
cLineOptimize: boolean; {+o flag set?}
|
cLineOptimize: boolean; {+o flag set?}
|
||||||
code: icptr; {current intermediate code record}
|
code: icptr; {current intermediate code record}
|
||||||
|
@ -324,9 +348,11 @@ var
|
||||||
commonSubexpression: boolean; {do common subexpression removal?}
|
commonSubexpression: boolean; {do common subexpression removal?}
|
||||||
currentSegment,defaultSegment: segNameType; {current & default seg names}
|
currentSegment,defaultSegment: segNameType; {current & default seg names}
|
||||||
segmentKind: integer; {kind field of segment (ored with start/data)}
|
segmentKind: integer; {kind field of segment (ored with start/data)}
|
||||||
|
defaultSegmentKind: integer; {default segment kind}
|
||||||
debugFlag: boolean; {generate debugger calls?}
|
debugFlag: boolean; {generate debugger calls?}
|
||||||
debugStrFlag: boolean; {gsbug/niftylist debug names?}
|
debugStrFlag: boolean; {gsbug/niftylist debug names?}
|
||||||
dataBank: boolean; {save, restore data bank?}
|
dataBank: boolean; {save, restore data bank?}
|
||||||
|
fastMath: boolean; {do FP math opts that break IEEE rules?}
|
||||||
floatCard: integer; {0 -> SANE; 1 -> FPE}
|
floatCard: integer; {0 -> SANE; 1 -> FPE}
|
||||||
floatSlot: integer; {FPE slot}
|
floatSlot: integer; {FPE slot}
|
||||||
loopOptimizations: boolean; {do loop optimizations?}
|
loopOptimizations: boolean; {do loop optimizations?}
|
||||||
|
@ -342,7 +368,7 @@ var
|
||||||
stackSize: integer; {amount of stack space to reserve}
|
stackSize: integer; {amount of stack space to reserve}
|
||||||
strictVararg: boolean; {repair stack around vararg calls?}
|
strictVararg: boolean; {repair stack around vararg calls?}
|
||||||
stringsize: 0..maxstring; {amount of string space left}
|
stringsize: 0..maxstring; {amount of string space left}
|
||||||
stringspace: packed array[1..maxstring] of char; {string table}
|
stringspace: ^stringSpaceType; {string table}
|
||||||
symLength: integer; {length of debug symbol table}
|
symLength: integer; {length of debug symbol table}
|
||||||
toolParms: boolean; {generate tool format parameters?}
|
toolParms: boolean; {generate tool format parameters?}
|
||||||
volatile: boolean; {has a volatile qualifier been used?}
|
volatile: boolean; {has a volatile qualifier been used?}
|
||||||
|
@ -561,6 +587,16 @@ procedure GenS (fop: pcodes; str: longstringPtr);
|
||||||
{ str - pointer to string }
|
{ str - pointer to string }
|
||||||
|
|
||||||
|
|
||||||
|
procedure GenBS (fop: pcodes; data: ptr; len: longint);
|
||||||
|
|
||||||
|
{ generate an instruction that uses a byte sequence operand }
|
||||||
|
{ }
|
||||||
|
{ parameters: }
|
||||||
|
{ fop - operation code }
|
||||||
|
{ data - pointer to data }
|
||||||
|
{ data - length of data }
|
||||||
|
|
||||||
|
|
||||||
procedure GenL1 (fop: pcodes; lval: longint; fp1: integer);
|
procedure GenL1 (fop: pcodes; lval: longint; fp1: integer);
|
||||||
|
|
||||||
{ generate an instruction that uses a longint and an int }
|
{ generate an instruction that uses a longint and an int }
|
||||||
|
@ -624,6 +660,21 @@ procedure GenTool (fop: pcodes; fp1, fp2: integer; dispatcher: longint);
|
||||||
{ dispatcher - tool entry point }
|
{ dispatcher - tool entry point }
|
||||||
|
|
||||||
|
|
||||||
|
function GetCodeLocation: codeRef;
|
||||||
|
|
||||||
|
{ Get a reference to the current location in the generated }
|
||||||
|
{ code, suitable to be passed to RemoveCode. }
|
||||||
|
|
||||||
|
|
||||||
|
procedure InsertCode (theCode: codeRef);
|
||||||
|
|
||||||
|
{ Insert a section of already-generated code that was }
|
||||||
|
{ previously removed with RemoveCode. }
|
||||||
|
{ }
|
||||||
|
{ parameters: }
|
||||||
|
{ theCode - code removed (returned from RemoveCode) }
|
||||||
|
|
||||||
|
|
||||||
{procedure PrintBlocks (tag: stringPtr; bp: blockPtr); {debug}
|
{procedure PrintBlocks (tag: stringPtr; bp: blockPtr); {debug}
|
||||||
|
|
||||||
{ print a series of basic blocks }
|
{ print a series of basic blocks }
|
||||||
|
@ -633,6 +684,28 @@ procedure GenTool (fop: pcodes; fp1, fp2: integer; dispatcher: longint);
|
||||||
{ bp - first block to print }
|
{ bp - first block to print }
|
||||||
|
|
||||||
|
|
||||||
|
{procedure PrintDAG (tag: stringPtr; code: icptr); {debug}
|
||||||
|
|
||||||
|
{ print a DAG }
|
||||||
|
{ }
|
||||||
|
{ parameters: }
|
||||||
|
{ tag - label for lines }
|
||||||
|
{ code - first node in DAG }
|
||||||
|
|
||||||
|
|
||||||
|
function RemoveCode (start: codeRef): codeRef;
|
||||||
|
|
||||||
|
{ Remove a section of already-generated code, from immediately }
|
||||||
|
{ after start up to the latest code generated. Returns the }
|
||||||
|
{ code removed, so it may be re-inserted later. }
|
||||||
|
{ }
|
||||||
|
{ parameters: }
|
||||||
|
{ start - location to start removing from }
|
||||||
|
{ }
|
||||||
|
{ Note: start must be a top-level pcode (not a subexpression). }
|
||||||
|
{ Note: The region removed must not include a dc_enp. }
|
||||||
|
|
||||||
|
|
||||||
function TypeSize (tp: baseTypeEnum): integer;
|
function TypeSize (tp: baseTypeEnum): integer;
|
||||||
|
|
||||||
{ Find the size, in bytes, of a variable }
|
{ Find the size, in bytes, of a variable }
|
||||||
|
@ -794,9 +867,12 @@ isXCMD := false;
|
||||||
codeGeneration := false; {code generation is not turned on yet}
|
codeGeneration := false; {code generation is not turned on yet}
|
||||||
currentSegment := ' '; {start with the blank segment}
|
currentSegment := ' '; {start with the blank segment}
|
||||||
defaultSegment := ' ';
|
defaultSegment := ' ';
|
||||||
|
segmentKind := 0; {default to static code segments}
|
||||||
|
defaultSegmentKind := 0;
|
||||||
smallMemoryModel := true; {small memory model}
|
smallMemoryModel := true; {small memory model}
|
||||||
dataBank := false; {don't save/restore data bank}
|
dataBank := false; {don't save/restore data bank}
|
||||||
strictVararg := not cLineOptimize; {save/restore caller's stack around vararg}
|
strictVararg := {save/restore caller's stack around vararg}
|
||||||
|
(not cLineOptimize) or strictMode;
|
||||||
saveStack := not cLineOptimize; {save/restore caller's stack reg}
|
saveStack := not cLineOptimize; {save/restore caller's stack reg}
|
||||||
checkStack := false; {don't check stack for stack errors}
|
checkStack := false; {don't check stack for stack errors}
|
||||||
stackSize := 0; {default to the launcher's stack size}
|
stackSize := 0; {default to the launcher's stack size}
|
||||||
|
@ -812,14 +888,19 @@ profileFlag := false; {don't generate profiling code}
|
||||||
debugFlag := false; {don't generate debug code}
|
debugFlag := false; {don't generate debug code}
|
||||||
debugStrFlag := false; {don't generate gsbug debug strings}
|
debugStrFlag := false; {don't generate gsbug debug strings}
|
||||||
traceBack := false; {don't generate traceback code}
|
traceBack := false; {don't generate traceback code}
|
||||||
|
checkNullPointers := false; {don't check null pointers}
|
||||||
volatile := false; {no volatile qualifiers found}
|
volatile := false; {no volatile qualifiers found}
|
||||||
|
|
||||||
registers := cLineOptimize; {don't do register optimizations}
|
registers := cLineOptimize; {don't do register optimizations}
|
||||||
peepHole := cLineOptimize; {not doing peephole optimization (yet)}
|
peepHole := cLineOptimize; {not doing peephole optimization (yet)}
|
||||||
npeepHole := cLineOptimize;
|
npeepHole := cLineOptimize;
|
||||||
|
fastMath := cLineOptimize;
|
||||||
commonSubexpression := cLineOptimize; {not doing common subexpression elimination}
|
commonSubexpression := cLineOptimize; {not doing common subexpression elimination}
|
||||||
loopOptimizations := cLineOptimize; {not doing loop optimizations, yet}
|
loopOptimizations := cLineOptimize; {not doing loop optimizations, yet}
|
||||||
|
|
||||||
|
{allocate string space}
|
||||||
|
new(stringspace);
|
||||||
|
|
||||||
{allocate the initial p-code}
|
{allocate the initial p-code}
|
||||||
code := pointer(Calloc(sizeof(intermediate_code)));
|
code := pointer(Calloc(sizeof(intermediate_code)));
|
||||||
code^.optype := cgWord;
|
code^.optype := cgWord;
|
||||||
|
@ -1213,6 +1294,30 @@ if codeGeneration then begin
|
||||||
end; {GenS}
|
end; {GenS}
|
||||||
|
|
||||||
|
|
||||||
|
procedure GenBS {fop: pcodes; data: ptr; len: longint};
|
||||||
|
|
||||||
|
{ generate an instruction that uses a byte sequence operand }
|
||||||
|
{ }
|
||||||
|
{ parameters: }
|
||||||
|
{ fop - operation code }
|
||||||
|
{ data - pointer to data }
|
||||||
|
{ len - length of data }
|
||||||
|
|
||||||
|
var
|
||||||
|
lcode: icptr; {local copy of code}
|
||||||
|
|
||||||
|
begin {GenBS}
|
||||||
|
if codeGeneration then begin
|
||||||
|
lcode := code;
|
||||||
|
lcode^.optype := cgString;
|
||||||
|
lcode^.isByteSeq := true;
|
||||||
|
lcode^.data := data;
|
||||||
|
lcode^.len := len;
|
||||||
|
Gen0(fop);
|
||||||
|
end; {if}
|
||||||
|
end; {GenBS}
|
||||||
|
|
||||||
|
|
||||||
procedure GenL1 {fop: pcodes; lval: longint; fp1: integer};
|
procedure GenL1 {fop: pcodes; lval: longint; fp1: integer};
|
||||||
|
|
||||||
{ generate an instruction that uses a longint and an int }
|
{ generate an instruction that uses a longint and an int }
|
||||||
|
@ -1365,6 +1470,74 @@ if codeGeneration then begin
|
||||||
end; {GenLdcReal}
|
end; {GenLdcReal}
|
||||||
|
|
||||||
|
|
||||||
|
function GetCodeLocation{: codeRef};
|
||||||
|
|
||||||
|
{ Get a reference to the current location in the generated }
|
||||||
|
{ code, suitable to be passed to RemoveCode. }
|
||||||
|
|
||||||
|
begin {GetCodeLocation}
|
||||||
|
GetCodeLocation := DAGhead;
|
||||||
|
end {GetCodeLocation};
|
||||||
|
|
||||||
|
|
||||||
|
procedure InsertCode {theCode: codeRef};
|
||||||
|
|
||||||
|
{ Insert a section of already-generated code that was }
|
||||||
|
{ previously removed with RemoveCode. }
|
||||||
|
{ }
|
||||||
|
{ parameters: }
|
||||||
|
{ theCode - code removed (returned from RemoveCode) }
|
||||||
|
|
||||||
|
var
|
||||||
|
lcode: icptr;
|
||||||
|
|
||||||
|
begin {InsertCode}
|
||||||
|
if theCode <> nil then
|
||||||
|
if codeGeneration then begin
|
||||||
|
lcode := theCode;
|
||||||
|
{ PrintDAG(@'Inserting: ', lcode); {debug}
|
||||||
|
while lcode^.next <> nil do
|
||||||
|
lcode := lcode^.next;
|
||||||
|
lcode^.next := DAGhead;
|
||||||
|
DAGhead := theCode;
|
||||||
|
end; {if}
|
||||||
|
end; {InsertCode}
|
||||||
|
|
||||||
|
|
||||||
|
function RemoveCode {start: codeRef): codeRef};
|
||||||
|
|
||||||
|
{ Remove a section of already-generated code, from immediately }
|
||||||
|
{ after start up to the latest code generated. Returns the }
|
||||||
|
{ code removed, so it may be re-inserted later. }
|
||||||
|
{ }
|
||||||
|
{ parameters: }
|
||||||
|
{ start - location to start removing from }
|
||||||
|
{ }
|
||||||
|
{ Note: start must be a top-level pcode (not a subexpression). }
|
||||||
|
{ Note: The region removed must not include a dc_enp. }
|
||||||
|
|
||||||
|
var
|
||||||
|
lcode: icptr;
|
||||||
|
|
||||||
|
begin {RemoveCode}
|
||||||
|
if start = DAGhead then
|
||||||
|
RemoveCode := nil
|
||||||
|
else begin
|
||||||
|
RemoveCode := DAGhead;
|
||||||
|
if codeGeneration then begin
|
||||||
|
lcode := DAGhead;
|
||||||
|
while (lcode^.next <> start) and (lcode^.next <> nil) do
|
||||||
|
lcode := lcode^.next;
|
||||||
|
if lcode^.next = nil then
|
||||||
|
Error(cge1);
|
||||||
|
lcode^.next := nil;
|
||||||
|
{ PrintDAG(@'Removing: ', DAGhead); {debug}
|
||||||
|
DAGhead := start;
|
||||||
|
end; {if}
|
||||||
|
end; {else}
|
||||||
|
end; {RemoveCode}
|
||||||
|
|
||||||
|
|
||||||
function TypeSize {tp: baseTypeEnum): integer};
|
function TypeSize {tp: baseTypeEnum): integer};
|
||||||
|
|
||||||
{ Find the size, in bytes, of a variable }
|
{ Find the size, in bytes, of a variable }
|
||||||
|
@ -1411,10 +1584,15 @@ case tp of
|
||||||
d := rval;
|
d := rval;
|
||||||
rval := d;
|
rval := d;
|
||||||
end;
|
end;
|
||||||
cgComp: begin
|
cgComp: if rval < 0.0 then begin
|
||||||
c := rval;
|
{work around SANE comp conversion bug}
|
||||||
rval := c;
|
c := -rval;
|
||||||
end;
|
rval := -c;
|
||||||
|
end {if}
|
||||||
|
else begin
|
||||||
|
c := rval;
|
||||||
|
rval := c;
|
||||||
|
end; {else}
|
||||||
cgExtended: ;
|
cgExtended: ;
|
||||||
end; {case}
|
end; {case}
|
||||||
end; {LimitPrecision}
|
end; {LimitPrecision}
|
||||||
|
|
82
Charset.pas
82
Charset.pas
|
@ -28,6 +28,14 @@ const
|
||||||
|
|
||||||
type
|
type
|
||||||
ucsCodePoint = 0..maxUCSCodePoint;
|
ucsCodePoint = 0..maxUCSCodePoint;
|
||||||
|
utf8Rec = record
|
||||||
|
length: integer;
|
||||||
|
bytes: packed array [1..4] of byte;
|
||||||
|
end;
|
||||||
|
utf16Rec = record
|
||||||
|
length: integer;
|
||||||
|
codeUnits: packed array [1..2] of integer;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function ConvertMacRomanToUCS(ch: char): ucsCodePoint;
|
function ConvertMacRomanToUCS(ch: char): ucsCodePoint;
|
||||||
|
@ -36,6 +44,7 @@ function ConvertMacRomanToUCS(ch: char): ucsCodePoint;
|
||||||
{ }
|
{ }
|
||||||
{ Returns UCS code point value for the character. }
|
{ Returns UCS code point value for the character. }
|
||||||
|
|
||||||
|
|
||||||
function ConvertUCSToMacRoman(ch: ucsCodePoint): integer;
|
function ConvertUCSToMacRoman(ch: ucsCodePoint): integer;
|
||||||
|
|
||||||
{ convert a character from UCS (Unicode) to MacRoman charset }
|
{ convert a character from UCS (Unicode) to MacRoman charset }
|
||||||
|
@ -43,6 +52,23 @@ function ConvertUCSToMacRoman(ch: ucsCodePoint): integer;
|
||||||
{ Returns ordinal value of the character, or -1 if it can't be }
|
{ Returns ordinal value of the character, or -1 if it can't be }
|
||||||
{ converted. }
|
{ converted. }
|
||||||
|
|
||||||
|
|
||||||
|
procedure UTF16Encode(ch: ucsCodePoint; var utf16: utf16Rec);
|
||||||
|
|
||||||
|
{ Encode a UCS code point in UTF-16 }
|
||||||
|
{ }
|
||||||
|
{ ch - the code point }
|
||||||
|
{ utf16 - set to the UTF-16 representation of the code point }
|
||||||
|
|
||||||
|
|
||||||
|
procedure UTF8Encode(ch: ucsCodePoint; var utf8: utf8Rec);
|
||||||
|
|
||||||
|
{ Encode a UCS code point in UTF-8 }
|
||||||
|
{ }
|
||||||
|
{ ch - the code point }
|
||||||
|
{ utf16 - set to the UTF-8 representation of the code point }
|
||||||
|
|
||||||
|
|
||||||
function ValidUCNForIdentifier(ch: ucsCodePoint; initial: boolean): boolean;
|
function ValidUCNForIdentifier(ch: ucsCodePoint; initial: boolean): boolean;
|
||||||
|
|
||||||
{ Check if a code point is valid for a UCN in an identifier }
|
{ Check if a code point is valid for a UCN in an identifier }
|
||||||
|
@ -50,6 +76,8 @@ function ValidUCNForIdentifier(ch: ucsCodePoint; initial: boolean): boolean;
|
||||||
{ ch - the code point }
|
{ ch - the code point }
|
||||||
{ initial - is this UCN the initial element of the identifier? }
|
{ initial - is this UCN the initial element of the identifier? }
|
||||||
|
|
||||||
|
{----------------------------------------------------------------}
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
function ConvertMacRomanToUCS{(ch: char): ucsCodePoint};
|
function ConvertMacRomanToUCS{(ch: char): ucsCodePoint};
|
||||||
|
@ -100,6 +128,60 @@ else begin
|
||||||
end; {ConvertUCSToMacRoman}
|
end; {ConvertUCSToMacRoman}
|
||||||
|
|
||||||
|
|
||||||
|
procedure UTF16Encode{ch: ucsCodePoint; var utf16: utf16Rec};
|
||||||
|
|
||||||
|
{ Encode a UCS code point in UTF-16 }
|
||||||
|
{ }
|
||||||
|
{ ch - the code point }
|
||||||
|
{ utf16 - set to the UTF-16 representation of the code point }
|
||||||
|
|
||||||
|
begin {UTF16Encode}
|
||||||
|
if ch <= $00ffff then begin
|
||||||
|
utf16.length := 1;
|
||||||
|
utf16.codeUnits[1] := ord(ch);
|
||||||
|
end {if}
|
||||||
|
else begin
|
||||||
|
utf16.length := 2;
|
||||||
|
ch := ch - $010000;
|
||||||
|
utf16.codeUnits[1] := $D800 | ord(ch >> 10);
|
||||||
|
utf16.codeUnits[2] := $DC00 | ord(ch & $03ff);
|
||||||
|
end; {else}
|
||||||
|
end; {UTF16Encode}
|
||||||
|
|
||||||
|
|
||||||
|
procedure UTF8Encode{ch: ucsCodePoint; var utf8: utf8Rec};
|
||||||
|
|
||||||
|
{ Encode a UCS code point in UTF-8 }
|
||||||
|
{ }
|
||||||
|
{ ch - the code point }
|
||||||
|
{ utf16 - set to the UTF-8 representation of the code point }
|
||||||
|
|
||||||
|
begin {UTF8Encode}
|
||||||
|
if ch <= $00007f then begin
|
||||||
|
utf8.length := 1;
|
||||||
|
utf8.bytes[1] := ord(ch);
|
||||||
|
end {if}
|
||||||
|
else if ch <= $0007ff then begin
|
||||||
|
utf8.length := 2;
|
||||||
|
utf8.bytes[1] := $C0 | ord(ch >> 6);
|
||||||
|
utf8.bytes[2] := $80 | ord(ch & $3f)
|
||||||
|
end {else if}
|
||||||
|
else if ch <= $00ffff then begin
|
||||||
|
utf8.length := 3;
|
||||||
|
utf8.bytes[1] := $E0 | ord(ch >> 12);
|
||||||
|
utf8.bytes[2] := $80 | ord((ch >> 6) & $3f);
|
||||||
|
utf8.bytes[3] := $80 | ord(ch & $3f);
|
||||||
|
end {else if}
|
||||||
|
else begin
|
||||||
|
utf8.length := 4;
|
||||||
|
utf8.bytes[1] := $F0 | ord(ch >> 18);
|
||||||
|
utf8.bytes[2] := $80 | ord((ch >> 12) & $3f);
|
||||||
|
utf8.bytes[3] := $80 | ord((ch >> 6) & $3f);
|
||||||
|
utf8.bytes[4] := $80 | ord(ch & $3f);
|
||||||
|
end; {else}
|
||||||
|
end; {UTF8Encode}
|
||||||
|
|
||||||
|
|
||||||
function ValidUCNForIdentifier{(ch: ucsCodePoint; initial: boolean): boolean};
|
function ValidUCNForIdentifier{(ch: ucsCodePoint; initial: boolean): boolean};
|
||||||
|
|
||||||
{ Check if a code point is valid for a UCN in an identifier }
|
{ Check if a code point is valid for a UCN in an identifier }
|
||||||
|
|
163
DAG.pas
163
DAG.pas
|
@ -198,9 +198,12 @@ else if (op1 <> nil) and (op2 <> nil) then
|
||||||
CodesMatch := true;
|
CodesMatch := true;
|
||||||
cgReal, cgDouble, cgComp, cgExtended:
|
cgReal, cgDouble, cgComp, cgExtended:
|
||||||
if op1^.rval = op2^.rval then
|
if op1^.rval = op2^.rval then
|
||||||
CodesMatch := true;
|
if (SignBit(op1^.rval) = SignBit(op2^.rval))
|
||||||
|
or fastMath then
|
||||||
|
CodesMatch := true;
|
||||||
cgString:
|
cgString:
|
||||||
CodesMatch := LongStrCmp(op1^.str, op2^.str);
|
if not (op1^.isByteSeq or op1^.isByteSeq) then
|
||||||
|
CodesMatch := LongStrCmp(op1^.str, op2^.str);
|
||||||
cgVoid, ccPointer:
|
cgVoid, ccPointer:
|
||||||
if op1^.pval = op2^.pval then
|
if op1^.pval = op2^.pval then
|
||||||
CodesMatch := LongStrCmp(op1^.str, op2^.str);
|
CodesMatch := LongStrCmp(op1^.str, op2^.str);
|
||||||
|
@ -427,26 +430,6 @@ while not (op^.next^.opcode in [dc_lab, dc_enp, dc_cns, dc_glb,
|
||||||
end; {RemoveDeadCode}
|
end; {RemoveDeadCode}
|
||||||
|
|
||||||
|
|
||||||
function NoFunctions (op: icptr): boolean;
|
|
||||||
|
|
||||||
{ are there any function calls? }
|
|
||||||
{ }
|
|
||||||
{ parameters: }
|
|
||||||
{ op - operation tree to search }
|
|
||||||
{ }
|
|
||||||
{ returns: True if there are no pc_cup or pc_cui operations }
|
|
||||||
{ in the tree, else false. }
|
|
||||||
|
|
||||||
begin {NoFunctions}
|
|
||||||
if op = nil then
|
|
||||||
NoFunctions := true
|
|
||||||
else if op^.opcode in [pc_cup,pc_cui,pc_tl1] then
|
|
||||||
NoFunctions := false
|
|
||||||
else
|
|
||||||
NoFunctions := NoFunctions(op^.left) or NoFunctions(op^.right);
|
|
||||||
end; {NoFunctions}
|
|
||||||
|
|
||||||
|
|
||||||
function OneBit (val: longint): boolean;
|
function OneBit (val: longint): boolean;
|
||||||
|
|
||||||
{ See if there is exactly one bit set in val }
|
{ See if there is exactly one bit set in val }
|
||||||
|
@ -505,9 +488,6 @@ var
|
||||||
{ parameters: }
|
{ parameters: }
|
||||||
{ op - tree to check }
|
{ op - tree to check }
|
||||||
|
|
||||||
var
|
|
||||||
result: boolean; {temp result}
|
|
||||||
|
|
||||||
begin {SideEffects}
|
begin {SideEffects}
|
||||||
if op = nil then begin
|
if op = nil then begin
|
||||||
if volatile then
|
if volatile then
|
||||||
|
@ -518,7 +498,8 @@ var
|
||||||
else if op^.opcode in
|
else if op^.opcode in
|
||||||
[pc_mov,pc_cbf,pc_cop,pc_cpi,pc_cpo,pc_gil,pc_gli,pc_gdl,
|
[pc_mov,pc_cbf,pc_cop,pc_cpi,pc_cpo,pc_gil,pc_gli,pc_gdl,
|
||||||
pc_gld,pc_iil,pc_ili,pc_idl,pc_ild,pc_lil,pc_lli,pc_ldl,
|
pc_gld,pc_iil,pc_ili,pc_idl,pc_ild,pc_lil,pc_lli,pc_ldl,
|
||||||
pc_lld,pc_sbf,pc_sro,pc_sto,pc_str,pc_cui,pc_cup,pc_tl1] then
|
pc_lld,pc_sbf,pc_sro,pc_sto,pc_str,pc_cui,pc_cup,pc_tl1,
|
||||||
|
pc_fix,pc_ckp] then
|
||||||
SideEffects := true
|
SideEffects := true
|
||||||
else if op^.opcode = pc_ldc then
|
else if op^.opcode = pc_ldc then
|
||||||
SideEffects := false
|
SideEffects := false
|
||||||
|
@ -536,7 +517,6 @@ var
|
||||||
{ newOpcode - opcode to use if the jump sense is reversed }
|
{ newOpcode - opcode to use if the jump sense is reversed }
|
||||||
|
|
||||||
var
|
var
|
||||||
done: boolean; {optimization done test}
|
|
||||||
topcode: pcodes; {temp opcode}
|
topcode: pcodes; {temp opcode}
|
||||||
|
|
||||||
begin {JumpOptimizations}
|
begin {JumpOptimizations}
|
||||||
|
@ -585,6 +565,12 @@ var
|
||||||
false: (rval: real);
|
false: (rval: real);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
cnvdbl: record {for stuffing a double in a quad space}
|
||||||
|
case boolean of
|
||||||
|
true: (qval: longlong);
|
||||||
|
false: (rval: double);
|
||||||
|
end;
|
||||||
|
|
||||||
begin {RealStoreOptimizations}
|
begin {RealStoreOptimizations}
|
||||||
if opl^.opcode = pc_cnv then
|
if opl^.opcode = pc_cnv then
|
||||||
if baseTypeEnum(opl^.q & $000F) = op^.optype then
|
if baseTypeEnum(opl^.q & $000F) = op^.optype then
|
||||||
|
@ -601,7 +587,7 @@ var
|
||||||
if lab^ = op^.lab^ then
|
if lab^ = op^.lab^ then
|
||||||
same := true;
|
same := true;
|
||||||
end {if}
|
end {if}
|
||||||
else {if op^.opcode = pc_str then}
|
else if op^.opcode = pc_str then
|
||||||
if opcode = pc_lod then
|
if opcode = pc_lod then
|
||||||
if q = op^.q then
|
if q = op^.q then
|
||||||
if r = op^.r then
|
if r = op^.r then
|
||||||
|
@ -651,6 +637,19 @@ var
|
||||||
opl^.optype := cgLong;
|
opl^.optype := cgLong;
|
||||||
op^.optype := cgLong;
|
op^.optype := cgLong;
|
||||||
end; {if}
|
end; {if}
|
||||||
|
end {if}
|
||||||
|
else if op^.optype = cgDouble then begin
|
||||||
|
if opl^.opcode = pc_ldc then begin
|
||||||
|
cnvdbl.rval := opl^.rval;
|
||||||
|
opl^.qval := cnvdbl.qval;
|
||||||
|
opl^.optype := cgQuad;
|
||||||
|
op^.optype := cgQuad;
|
||||||
|
end {if}
|
||||||
|
else if opl^.opcode in [pc_ind,pc_ldo,pc_lod] then
|
||||||
|
if opl^.optype = cgDouble then begin
|
||||||
|
opl^.optype := cgQuad;
|
||||||
|
op^.optype := cgQuad;
|
||||||
|
end; {if}
|
||||||
end; {if}
|
end; {if}
|
||||||
end; {RealStoreOptimizations}
|
end; {RealStoreOptimizations}
|
||||||
|
|
||||||
|
@ -748,11 +747,13 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
op^.opcode := pc_inc;
|
op^.opcode := pc_inc;
|
||||||
op^.q := q;
|
op^.q := q;
|
||||||
op^.right := nil;
|
op^.right := nil;
|
||||||
|
PeepHoleOptimization(opv);
|
||||||
end {else if}
|
end {else if}
|
||||||
else {if q < 0 then} begin
|
else {if q < 0 then} begin
|
||||||
op^.opcode := pc_dec;
|
op^.opcode := pc_dec;
|
||||||
op^.q := -q;
|
op^.q := -q;
|
||||||
op^.right := nil;
|
op^.right := nil;
|
||||||
|
PeepHoleOptimization(opv);
|
||||||
end; {else if}
|
end; {else if}
|
||||||
end {if}
|
end {if}
|
||||||
else if CodesMatch(op^.left, op^.right, false) then begin
|
else if CodesMatch(op^.left, op^.right, false) then begin
|
||||||
|
@ -817,6 +818,7 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
op^.q := ord(lval);
|
op^.q := ord(lval);
|
||||||
op^.right := nil;
|
op^.right := nil;
|
||||||
done := true;
|
done := true;
|
||||||
|
PeepHoleOptimization(opv);
|
||||||
end {else if}
|
end {else if}
|
||||||
else if (lval > -maxint) and (lval < 0) then begin
|
else if (lval > -maxint) and (lval < 0) then begin
|
||||||
op^.opcode := pc_dec;
|
op^.opcode := pc_dec;
|
||||||
|
@ -824,6 +826,7 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
op^.q := -ord(lval);
|
op^.q := -ord(lval);
|
||||||
op^.right := nil;
|
op^.right := nil;
|
||||||
done := true;
|
done := true;
|
||||||
|
PeepHoleOptimization(opv);
|
||||||
end; {else if}
|
end; {else if}
|
||||||
end {if}
|
end {if}
|
||||||
else if CodesMatch(op^.left, op^.right, false) then
|
else if CodesMatch(op^.left, op^.right, false) then
|
||||||
|
@ -899,8 +902,9 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
if op^.left^.opcode = pc_ldc then
|
if op^.left^.opcode = pc_ldc then
|
||||||
ReverseChildren(op);
|
ReverseChildren(op);
|
||||||
if op^.right^.opcode = pc_ldc then begin
|
if op^.right^.opcode = pc_ldc then begin
|
||||||
if op^.right^.rval = 0.0 then
|
if fastMath then
|
||||||
opv := op^.left;
|
if op^.right^.rval = 0.0 then
|
||||||
|
opv := op^.left;
|
||||||
end; {if}
|
end; {if}
|
||||||
end; {else}
|
end; {else}
|
||||||
end; {case pc_adr}
|
end; {case pc_adr}
|
||||||
|
@ -1411,7 +1415,8 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
PeepHoleOptimization(opv);
|
PeepHoleOptimization(opv);
|
||||||
end; {if}
|
end; {if}
|
||||||
end {else if}
|
end {else if}
|
||||||
else if op^.left^.opcode in [pc_lod,pc_ldo,pc_ind] then begin
|
else if (op^.left^.opcode in [pc_lod,pc_ldo]) or
|
||||||
|
((op^.left^.opcode = pc_ind) and (op^.left^.r = 0)) then begin
|
||||||
if fromtype.optype in [cgWord,cgUWord] then
|
if fromtype.optype in [cgWord,cgUWord] then
|
||||||
if totype.optype in [cgByte,cgUByte,cgWord,cgUWord] then begin
|
if totype.optype in [cgByte,cgUByte,cgWord,cgUWord] then begin
|
||||||
op^.left^.optype := totype.optype;
|
op^.left^.optype := totype.optype;
|
||||||
|
@ -1449,7 +1454,8 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
with op^.left^ do
|
with op^.left^ do
|
||||||
if opcode in [pc_slr,pc_vsr] then
|
if opcode in [pc_slr,pc_vsr] then
|
||||||
if right^.opcode = pc_ldc then
|
if right^.opcode = pc_ldc then
|
||||||
if left^.opcode in [pc_lod,pc_ldo,pc_ind] then begin
|
if (left^.opcode in [pc_lod,pc_ldo]) or
|
||||||
|
((left^.opcode = pc_ind) and (left^.r = 0)) then begin
|
||||||
lq := right^.lval;
|
lq := right^.lval;
|
||||||
if long(lq).msw = 0 then
|
if long(lq).msw = 0 then
|
||||||
if long(lq).lsw in [8,16,24] then begin
|
if long(lq).lsw in [8,16,24] then begin
|
||||||
|
@ -1602,7 +1608,7 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
else if op^.right^.optype in [cgByte, cgUByte, cgWord, cgUWord] then begin
|
else if op^.right^.optype in [cgByte, cgUByte, cgWord, cgUWord] then begin
|
||||||
if op^.right^.q = 1 then
|
if op^.right^.q = 1 then
|
||||||
if op^.left^.opcode in
|
if op^.left^.opcode in
|
||||||
[pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt]
|
[pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt,pc_not]
|
||||||
then begin
|
then begin
|
||||||
opv := op^.left;
|
opv := op^.left;
|
||||||
opv^.next := op^.next;
|
opv^.next := op^.next;
|
||||||
|
@ -1611,7 +1617,7 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
else if op^.right^.optype in [cgLong, cgULong] then begin
|
else if op^.right^.optype in [cgLong, cgULong] then begin
|
||||||
if op^.right^.lval = 1 then
|
if op^.right^.lval = 1 then
|
||||||
if op^.left^.opcode in
|
if op^.left^.opcode in
|
||||||
[pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt]
|
[pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt,pc_not]
|
||||||
then begin
|
then begin
|
||||||
opv := op^.left;
|
opv := op^.left;
|
||||||
opv^.next := op^.next;
|
opv^.next := op^.next;
|
||||||
|
@ -1745,8 +1751,10 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
opv := op^.right;
|
opv := op^.right;
|
||||||
end; {if}
|
end; {if}
|
||||||
end {if}
|
end {if}
|
||||||
else
|
else begin
|
||||||
op^.opcode := pc_neq;
|
op^.opcode := pc_neq;
|
||||||
|
PeepHoleOptimization(opv);
|
||||||
|
end; {else}
|
||||||
end {if}
|
end {if}
|
||||||
end {if}
|
end {if}
|
||||||
else if op^.left^.opcode = pc_ldc then
|
else if op^.left^.opcode = pc_ldc then
|
||||||
|
@ -1831,8 +1839,14 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
and (op^.right^.qval.lo = 0) and (op^.right^.qval.hi = 0)) then
|
and (op^.right^.qval.lo = 0) and (op^.right^.qval.hi = 0)) then
|
||||||
begin
|
begin
|
||||||
case op^.opcode of
|
case op^.opcode of
|
||||||
pc_leq: op^.opcode := pc_equ;
|
pc_leq: begin
|
||||||
pc_grt: op^.opcode := pc_neq;
|
op^.opcode := pc_equ;
|
||||||
|
PeepHoleOptimization(opv);
|
||||||
|
end;
|
||||||
|
pc_grt: begin
|
||||||
|
op^.opcode := pc_neq;
|
||||||
|
PeepHoleOptimization(opv);
|
||||||
|
end;
|
||||||
pc_les: if not SideEffects(op^.left) then begin
|
pc_les: if not SideEffects(op^.left) then begin
|
||||||
op^.right^.optype := cgWord;
|
op^.right^.optype := cgWord;
|
||||||
op^.right^.q := 0;
|
op^.right^.q := 0;
|
||||||
|
@ -1845,8 +1859,9 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
end; {if}
|
end; {if}
|
||||||
end; {case}
|
end; {case}
|
||||||
end {if}
|
end {if}
|
||||||
else if (op^.opcode = pc_leq) and (op^.optype in [cgWord,cgUWord]) then
|
else if (op^.opcode = pc_leq) then
|
||||||
if op^.right^.q < maxint then begin
|
if ((op^.optype = cgWord) and (op^.right^.q <> maxint))
|
||||||
|
or ((op^.optype = cgUWord) and (op^.right^.q <> -1)) then begin
|
||||||
op^.right^.q := op^.right^.q + 1;
|
op^.right^.q := op^.right^.q + 1;
|
||||||
op^.opcode := pc_les;
|
op^.opcode := pc_les;
|
||||||
end; {if}
|
end; {if}
|
||||||
|
@ -1909,6 +1924,7 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
else begin
|
else begin
|
||||||
op^.opcode := pc_neq;
|
op^.opcode := pc_neq;
|
||||||
op^.optype := cgLong;
|
op^.optype := cgLong;
|
||||||
|
PeepHoleOptimization(opv);
|
||||||
end; {else}
|
end; {else}
|
||||||
end; {if}
|
end; {if}
|
||||||
end {if}
|
end {if}
|
||||||
|
@ -2069,8 +2085,9 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
if rval = 1.0 then
|
if rval = 1.0 then
|
||||||
opv := op^.left
|
opv := op^.left
|
||||||
else if rval = 0.0 then
|
else if rval = 0.0 then
|
||||||
if not SideEffects(op^.left) then
|
if fastMath then
|
||||||
opv := op^.right;
|
if not SideEffects(op^.left) then
|
||||||
|
opv := op^.right;
|
||||||
end; {if}
|
end; {if}
|
||||||
end; {else}
|
end; {else}
|
||||||
end; {case pc_mpr}
|
end; {case pc_mpr}
|
||||||
|
@ -2119,7 +2136,7 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
else if op^.right^.optype in [cgByte, cgUByte, cgWord, cgUWord] then begin
|
else if op^.right^.optype in [cgByte, cgUByte, cgWord, cgUWord] then begin
|
||||||
if op^.right^.q = 0 then
|
if op^.right^.q = 0 then
|
||||||
if op^.left^.opcode in
|
if op^.left^.opcode in
|
||||||
[pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt]
|
[pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt,pc_not]
|
||||||
then begin
|
then begin
|
||||||
opv := op^.left;
|
opv := op^.left;
|
||||||
opv^.next := op^.next;
|
opv^.next := op^.next;
|
||||||
|
@ -2128,7 +2145,7 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
else if op^.right^.optype in [cgLong, cgULong] then begin
|
else if op^.right^.optype in [cgLong, cgULong] then begin
|
||||||
if op^.right^.lval = 0 then
|
if op^.right^.lval = 0 then
|
||||||
if op^.left^.opcode in
|
if op^.left^.opcode in
|
||||||
[pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt]
|
[pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt,pc_not]
|
||||||
then begin
|
then begin
|
||||||
opv := op^.left;
|
opv := op^.left;
|
||||||
opv^.next := op^.next;
|
opv^.next := op^.next;
|
||||||
|
@ -2275,11 +2292,13 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
op^.opcode := pc_dec;
|
op^.opcode := pc_dec;
|
||||||
op^.q := q;
|
op^.q := q;
|
||||||
op^.right := nil;
|
op^.right := nil;
|
||||||
|
PeepHoleOptimization(opv);
|
||||||
end {else if}
|
end {else if}
|
||||||
else {if q < 0) then} begin
|
else {if q < 0) then} begin
|
||||||
op^.opcode := pc_inc;
|
op^.opcode := pc_inc;
|
||||||
op^.q := -q;
|
op^.q := -q;
|
||||||
op^.right := nil;
|
op^.right := nil;
|
||||||
|
PeepHoleOptimization(opv);
|
||||||
end; {else if}
|
end; {else if}
|
||||||
end {if}
|
end {if}
|
||||||
else if op^.left^.opcode in [pc_inc,pc_dec] then
|
else if op^.left^.opcode in [pc_inc,pc_dec] then
|
||||||
|
@ -2330,12 +2349,14 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
op^.q := ord(lval);
|
op^.q := ord(lval);
|
||||||
op^.right := nil;
|
op^.right := nil;
|
||||||
op^.optype := cgLong;
|
op^.optype := cgLong;
|
||||||
|
PeepHoleOptimization(opv);
|
||||||
end {else if}
|
end {else if}
|
||||||
else if (lval > -maxint) and (lval < 0) then begin
|
else if (lval > -maxint) and (lval < 0) then begin
|
||||||
op^.opcode := pc_inc;
|
op^.opcode := pc_inc;
|
||||||
op^.q := -ord(lval);
|
op^.q := -ord(lval);
|
||||||
op^.right := nil;
|
op^.right := nil;
|
||||||
op^.optype := cgLong;
|
op^.optype := cgLong;
|
||||||
|
PeepHoleOptimization(opv);
|
||||||
end; {else if}
|
end; {else if}
|
||||||
end; {if}
|
end; {if}
|
||||||
end; {case pc_sbl}
|
end; {case pc_sbl}
|
||||||
|
@ -2346,15 +2367,17 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
op^.left^.rval := op^.left^.rval - op^.right^.rval;
|
op^.left^.rval := op^.left^.rval - op^.right^.rval;
|
||||||
opv := op^.left;
|
opv := op^.left;
|
||||||
end {if}
|
end {if}
|
||||||
else if op^.left^.rval = 0.0 then begin
|
else if op^.left^.rval = 0.0 then
|
||||||
op^.opcode := pc_ngr;
|
if fastMath then begin
|
||||||
op^.left := op^.right;
|
op^.opcode := pc_ngr;
|
||||||
op^.right := nil;
|
op^.left := op^.right;
|
||||||
end; {else if}
|
op^.right := nil;
|
||||||
|
end; {if}
|
||||||
end {if}
|
end {if}
|
||||||
else if op^.right^.opcode = pc_ldc then begin
|
else if op^.right^.opcode = pc_ldc then begin
|
||||||
if op^.right^.rval = 0.0 then
|
if fastMath then
|
||||||
opv := op^.left;
|
if op^.right^.rval = 0.0 then
|
||||||
|
opv := op^.left;
|
||||||
end; {if}
|
end; {if}
|
||||||
end; {case pc_sbr}
|
end; {case pc_sbr}
|
||||||
|
|
||||||
|
@ -2452,22 +2475,23 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
end; {case pc_sro, pc_str}
|
end; {case pc_sro, pc_str}
|
||||||
|
|
||||||
pc_sto: begin {pc_sto}
|
pc_sto: begin {pc_sto}
|
||||||
if op^.optype in [cgReal,cgDouble,cgExtended,cgComp] then
|
op2 := op^.right;
|
||||||
RealStoreOptimizations(op, op^.right);
|
|
||||||
if op^.left^.opcode = pc_lao then begin
|
if op^.left^.opcode = pc_lao then begin
|
||||||
op^.q := op^.left^.q;
|
op^.q := op^.left^.q;
|
||||||
op^.lab := op^.left^.lab;
|
op^.lab := op^.left^.lab;
|
||||||
op^.opcode := pc_sro;
|
op^.opcode := pc_sro;
|
||||||
op^.left := op^.right;
|
op^.left := op2;
|
||||||
op^.right := nil;
|
op^.right := nil;
|
||||||
end {if}
|
end {if}
|
||||||
else if op^.left^.opcode = pc_lda then begin
|
else if op^.left^.opcode = pc_lda then begin
|
||||||
op^.q := op^.left^.q;
|
op^.q := op^.left^.q;
|
||||||
op^.r := op^.left^.r;
|
op^.r := op^.left^.r;
|
||||||
op^.opcode := pc_str;
|
op^.opcode := pc_str;
|
||||||
op^.left := op^.right;
|
op^.left := op2;
|
||||||
op^.right := nil;
|
op^.right := nil;
|
||||||
end; {if}
|
end; {if}
|
||||||
|
if op^.optype in [cgReal,cgDouble,cgExtended,cgComp] then
|
||||||
|
RealStoreOptimizations(op, op2);
|
||||||
end; {case pc_sto}
|
end; {case pc_sto}
|
||||||
|
|
||||||
pc_sqr: begin {pc_sqr}
|
pc_sqr: begin {pc_sqr}
|
||||||
|
@ -2545,7 +2569,17 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
ReverseChildren(op^.right);
|
ReverseChildren(op^.right);
|
||||||
op^.left := op^.left^.left;
|
op^.left := op^.left^.left;
|
||||||
end; {if}
|
end; {if}
|
||||||
end; {else if}
|
end {else if}
|
||||||
|
else if opcode = pc_ldc then
|
||||||
|
if op^.left^.optype in [cgWord,cgUWord] then
|
||||||
|
if op^.next = nil then
|
||||||
|
if op^.left^.q <> 0 then begin
|
||||||
|
if op^.optype = TypeOf(op^.right^.left) then
|
||||||
|
opv := op^.right^.left;
|
||||||
|
end {if}
|
||||||
|
else
|
||||||
|
if op^.optype = TypeOf(op^.right^.right) then
|
||||||
|
opv := op^.right^.right;
|
||||||
end; {case pc_tri}
|
end; {case pc_tri}
|
||||||
|
|
||||||
pc_udi: begin {pc_udi}
|
pc_udi: begin {pc_udi}
|
||||||
|
@ -2798,7 +2832,7 @@ case op^.opcode of
|
||||||
pc_cnn, pc_cnv:
|
pc_cnn, pc_cnv:
|
||||||
TypeOf := baseTypeEnum(op^.q & $000F);
|
TypeOf := baseTypeEnum(op^.q & $000F);
|
||||||
|
|
||||||
pc_stk:
|
pc_stk, pc_ckp:
|
||||||
TypeOf := TypeOf(op^.left);
|
TypeOf := TypeOf(op^.left);
|
||||||
|
|
||||||
pc_bno:
|
pc_bno:
|
||||||
|
@ -3324,7 +3358,7 @@ var
|
||||||
str^.opcode := pc_str;
|
str^.opcode := pc_str;
|
||||||
str^.optype := optype;
|
str^.optype := optype;
|
||||||
str^.r := llab;
|
str^.r := llab;
|
||||||
str^.q := 0;
|
{str^.q := 0;}
|
||||||
str^.left := op2;
|
str^.left := op2;
|
||||||
if lop = nil then begin {insert the store in the basic block}
|
if lop = nil then begin {insert the store in the basic block}
|
||||||
str^.next := bb^.code;
|
str^.next := bb^.code;
|
||||||
|
@ -4922,7 +4956,7 @@ var
|
||||||
str^.opcode := pc_str;
|
str^.opcode := pc_str;
|
||||||
str^.optype := optype;
|
str^.optype := optype;
|
||||||
str^.r := loc^.r;
|
str^.r := loc^.r;
|
||||||
str^.q := 0;
|
{str^.q := 0;}
|
||||||
str^.left := op2;
|
str^.left := op2;
|
||||||
str^.next := loc^.next; {insert the store in the basic block}
|
str^.next := loc^.next; {insert the store in the basic block}
|
||||||
loc^.next := str;
|
loc^.next := str;
|
||||||
|
@ -5460,7 +5494,7 @@ case code^.opcode of
|
||||||
pc_bnt, pc_bnl, pc_cnv, pc_dec, pc_inc, pc_ind, pc_lbf, pc_lbu,
|
pc_bnt, pc_bnl, pc_cnv, pc_dec, pc_inc, pc_ind, pc_lbf, pc_lbu,
|
||||||
pc_ngi, pc_ngl, pc_ngr, pc_not, pc_stk, pc_cop, pc_cpo, pc_tl1,
|
pc_ngi, pc_ngl, pc_ngr, pc_not, pc_stk, pc_cop, pc_cpo, pc_tl1,
|
||||||
pc_sro, pc_str, pc_fjp, pc_tjp, pc_xjp, pc_cup, pc_pop, pc_iil,
|
pc_sro, pc_str, pc_fjp, pc_tjp, pc_xjp, pc_cup, pc_pop, pc_iil,
|
||||||
pc_ili, pc_idl, pc_ild, pc_bnq, pc_ngq, pc_rbo:
|
pc_ili, pc_idl, pc_ild, pc_bnq, pc_ngq, pc_rbo, pc_rev, pc_ckp:
|
||||||
begin
|
begin
|
||||||
code^.left := Pop;
|
code^.left := Pop;
|
||||||
Push(code);
|
Push(code);
|
||||||
|
@ -5484,7 +5518,7 @@ case code^.opcode of
|
||||||
pc_gil, pc_gli, pc_gdl, pc_gld, pc_lil, pc_lli, pc_ldl, pc_lld,
|
pc_gil, pc_gli, pc_gdl, pc_gld, pc_lil, pc_lli, pc_ldl, pc_lld,
|
||||||
pc_lad, pc_lao, pc_lca, pc_lda, pc_ldc, pc_ldo, pc_lod, pc_nop,
|
pc_lad, pc_lao, pc_lca, pc_lda, pc_ldc, pc_ldo, pc_lod, pc_nop,
|
||||||
dc_cns, dc_glb, dc_dst, pc_lnm, pc_nam, pc_nat, dc_lab, pc_add,
|
dc_cns, dc_glb, dc_dst, pc_lnm, pc_nam, pc_nat, dc_lab, pc_add,
|
||||||
pc_ujp, dc_pin, pc_ent, dc_sym:
|
pc_ujp, dc_pin, pc_ent, dc_sym, pc_fix:
|
||||||
Push(code);
|
Push(code);
|
||||||
|
|
||||||
pc_ret:
|
pc_ret:
|
||||||
|
@ -5495,6 +5529,15 @@ case code^.opcode of
|
||||||
Push(code);
|
Push(code);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
pc_ckn:
|
||||||
|
begin
|
||||||
|
code^.opcode := pc_ckp;
|
||||||
|
temp := Pop;
|
||||||
|
code^.left := Pop;
|
||||||
|
Push(code);
|
||||||
|
Push(temp);
|
||||||
|
end;
|
||||||
|
|
||||||
pc_cnn:
|
pc_cnn:
|
||||||
begin
|
begin
|
||||||
code^.opcode := pc_cnv;
|
code^.opcode := pc_cnv;
|
||||||
|
|
734
Expression.pas
734
Expression.pas
File diff suppressed because it is too large
Load Diff
132
Header.pas
132
Header.pas
|
@ -15,10 +15,10 @@ interface
|
||||||
|
|
||||||
uses CCommon, MM, Scanner, Symbol, CGI;
|
uses CCommon, MM, Scanner, Symbol, CGI;
|
||||||
|
|
||||||
{$segment 'SCANNER'}
|
{$segment 'HEADER'}
|
||||||
|
|
||||||
const
|
const
|
||||||
symFileVersion = 16; {version number of .sym file format}
|
symFileVersion = 44; {version number of .sym file format}
|
||||||
|
|
||||||
var
|
var
|
||||||
inhibitHeader: boolean; {should .sym includes be blocked?}
|
inhibitHeader: boolean; {should .sym includes be blocked?}
|
||||||
|
@ -719,7 +719,10 @@ procedure EndInclude {chPtr: ptr};
|
||||||
stringConstant: begin
|
stringConstant: begin
|
||||||
WriteLongString(token.sval);
|
WriteLongString(token.sval);
|
||||||
WriteByte(ord(token.ispstring));
|
WriteByte(ord(token.ispstring));
|
||||||
|
WriteByte(ord(token.prefix));
|
||||||
end;
|
end;
|
||||||
|
otherCharacter: WriteByte(ord(token.ch));
|
||||||
|
preprocessingNumber:WriteWord(token.errCode);
|
||||||
macroParameter: WriteWord(token.pnum);
|
macroParameter: WriteWord(token.pnum);
|
||||||
reservedSymbol: if token.kind in [lbracech,rbracech,lbrackch,
|
reservedSymbol: if token.kind in [lbracech,rbracech,lbrackch,
|
||||||
rbrackch,poundch,poundpoundop] then
|
rbrackch,poundch,poundpoundop] then
|
||||||
|
@ -743,7 +746,6 @@ procedure EndInclude {chPtr: ptr};
|
||||||
tp := mp^.tokens; {loop over token list}
|
tp := mp^.tokens; {loop over token list}
|
||||||
while tp <> nil do begin
|
while tp <> nil do begin
|
||||||
WriteByte(1); {write tokenListRecord}
|
WriteByte(1); {write tokenListRecord}
|
||||||
WriteLongString(tp^.tokenString);
|
|
||||||
WriteToken(tp^.token);
|
WriteToken(tp^.token);
|
||||||
WriteByte(ord(tp^.expandEnabled));
|
WriteByte(ord(tp^.expandEnabled));
|
||||||
WriteChars(tp^.tokenStart, tp^.tokenEnd);
|
WriteChars(tp^.tokenStart, tp^.tokenEnd);
|
||||||
|
@ -797,10 +799,10 @@ procedure EndInclude {chPtr: ptr};
|
||||||
WriteWord(floatSlot);
|
WriteWord(floatSlot);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
p_keep: WriteLongString(@outFileGS.theString);
|
p_keep: WriteLongString(@pragmaKeepFile^.theString);
|
||||||
|
|
||||||
p_line: begin
|
p_line: begin
|
||||||
WriteWord(lineNumber);
|
WriteLong(lineNumber);
|
||||||
WriteLongString(@sourceFileGS.theString);
|
WriteLongString(@sourceFileGS.theString);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -826,6 +828,7 @@ procedure EndInclude {chPtr: ptr};
|
||||||
| (ord(profileFlag) << 2)
|
| (ord(profileFlag) << 2)
|
||||||
| (ord(traceBack) << 3)
|
| (ord(traceBack) << 3)
|
||||||
| (ord(checkStack) << 4)
|
| (ord(checkStack) << 4)
|
||||||
|
| (ord(checkNullPointers) << 5)
|
||||||
| (ord(debugStrFlag) << 15));
|
| (ord(debugStrFlag) << 15));
|
||||||
|
|
||||||
p_lint: begin
|
p_lint: begin
|
||||||
|
@ -844,7 +847,8 @@ procedure EndInclude {chPtr: ptr};
|
||||||
| (ord(saveStack) << 3)
|
| (ord(saveStack) << 3)
|
||||||
| (ord(commonSubexpression) << 4)
|
| (ord(commonSubexpression) << 4)
|
||||||
| (ord(loopOptimizations) << 5)
|
| (ord(loopOptimizations) << 5)
|
||||||
| (ord(strictVararg) << 6));
|
| (ord(strictVararg) << 6)
|
||||||
|
| (ord(fastMath) << 7));
|
||||||
|
|
||||||
p_stacksize: WriteWord(stackSize);
|
p_stacksize: WriteWord(stackSize);
|
||||||
|
|
||||||
|
@ -885,11 +889,16 @@ procedure EndInclude {chPtr: ptr};
|
||||||
WriteByte(currentSegment[i]);
|
WriteByte(currentSegment[i]);
|
||||||
end; {for}
|
end; {for}
|
||||||
WriteWord(segmentKind);
|
WriteWord(segmentKind);
|
||||||
|
WriteWord(defaultSegmentKind);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
p_unix: WriteByte(ord(unix_1));
|
p_unix: WriteByte(ord(unix_1));
|
||||||
|
|
||||||
p_fenv_access: WriteByte(ord(fenvAccess));
|
p_fenv_access: WriteByte(ord(fenvAccess));
|
||||||
|
|
||||||
|
p_extensions:
|
||||||
|
WriteByte(ord(extendedKeywords)
|
||||||
|
| (ord(extendedParameters) << 1));
|
||||||
|
|
||||||
end; {case}
|
end; {case}
|
||||||
end; {if}
|
end; {if}
|
||||||
|
@ -1008,6 +1017,10 @@ procedure EndInclude {chPtr: ptr};
|
||||||
WriteByte(16)
|
WriteByte(16)
|
||||||
else if tp = uShortPtr then
|
else if tp = uShortPtr then
|
||||||
WriteByte(17)
|
WriteByte(17)
|
||||||
|
else if tp = utf16StringTypePtr then
|
||||||
|
WriteByte(18)
|
||||||
|
else if tp = utf32StringTypePtr then
|
||||||
|
WriteByte(19)
|
||||||
else if tp^.saveDisp <> 0 then begin
|
else if tp^.saveDisp <> 0 then begin
|
||||||
WriteByte(1);
|
WriteByte(1);
|
||||||
WriteLong(tp^.saveDisp);
|
WriteLong(tp^.saveDisp);
|
||||||
|
@ -1058,6 +1071,7 @@ procedure EndInclude {chPtr: ptr};
|
||||||
end; {while}
|
end; {while}
|
||||||
WriteByte(0);
|
WriteByte(0);
|
||||||
WriteByte(ord(tp^.constMember));
|
WriteByte(ord(tp^.constMember));
|
||||||
|
WriteByte(ord(tp^.flexibleArrayMember));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
otherwise: ;
|
otherwise: ;
|
||||||
|
@ -1094,6 +1108,9 @@ procedure EndInclude {chPtr: ptr};
|
||||||
WriteByte(ord(ip^.isForwardDeclared));
|
WriteByte(ord(ip^.isForwardDeclared));
|
||||||
WriteByte(ord(ip^.class));
|
WriteByte(ord(ip^.class));
|
||||||
WriteByte(ord(ip^.storage));
|
WriteByte(ord(ip^.storage));
|
||||||
|
if ip^.storage = external then
|
||||||
|
WriteByte(ord(ip^.inlineDefinition));
|
||||||
|
{if ip^.storage = none then ip^.anonMemberField must be false}
|
||||||
end; {WriteIdent}
|
end; {WriteIdent}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1188,6 +1205,8 @@ type
|
||||||
var
|
var
|
||||||
done: boolean; {for loop termination test}
|
done: boolean; {for loop termination test}
|
||||||
typeDispList: typeDispPtr; {type displacement/pointer table}
|
typeDispList: typeDispPtr; {type displacement/pointer table}
|
||||||
|
includesPtr: ptr; {ptr to includes section from sym file}
|
||||||
|
i: 1..maxint; {loop/index variable}
|
||||||
|
|
||||||
|
|
||||||
procedure DisposeTypeDispList;
|
procedure DisposeTypeDispList;
|
||||||
|
@ -1246,6 +1265,7 @@ var
|
||||||
symRefnum := opRec.refnum;
|
symRefnum := opRec.refnum;
|
||||||
OpenSymbols := true;
|
OpenSymbols := true;
|
||||||
WriteWord(symFileVersion);
|
WriteWord(symFileVersion);
|
||||||
|
WriteLongString(pointer(@infoStringGS.theString));
|
||||||
tokenMark := GetMark;
|
tokenMark := GetMark;
|
||||||
includeMark := false;
|
includeMark := false;
|
||||||
end; {if}
|
end; {if}
|
||||||
|
@ -1298,17 +1318,39 @@ var
|
||||||
match := false;
|
match := false;
|
||||||
len := 0;
|
len := 0;
|
||||||
end; {else}
|
end; {else}
|
||||||
if match and progress then begin
|
|
||||||
write('Including ');
|
|
||||||
for i := 1 to giRec.pathname^.size do
|
|
||||||
write(giRec.pathname^.theString[i]);
|
|
||||||
writeln;
|
|
||||||
end; {if}
|
|
||||||
end; {while}
|
end; {while}
|
||||||
DatesMatch := match;
|
DatesMatch := match;
|
||||||
end; {DatesMatch}
|
end; {DatesMatch}
|
||||||
|
|
||||||
|
|
||||||
|
procedure PrintIncludes;
|
||||||
|
|
||||||
|
{ Print "Including ..." lines for the headers }
|
||||||
|
|
||||||
|
type
|
||||||
|
longptr = ^longint;
|
||||||
|
|
||||||
|
var
|
||||||
|
dataPtr: ptr; {pointer to data from sym file}
|
||||||
|
endPtr: ptr; {pointer to end of includes section}
|
||||||
|
i: 1..maxint; {loop/index variable}
|
||||||
|
includeNamePtr: gsosInStringPtr; {pointer to an include file name}
|
||||||
|
|
||||||
|
begin {PrintIncludes}
|
||||||
|
dataPtr := includesPtr;
|
||||||
|
endPtr := pointer(ord4(dataPtr) + longptr(dataPtr)^ + 4);
|
||||||
|
dataPtr := pointer(ord4(dataPtr) + 4);
|
||||||
|
while dataPtr <> endPtr do begin
|
||||||
|
includeNamePtr := gsosInStringPtr(dataPtr);
|
||||||
|
write('Including ');
|
||||||
|
for i := 1 to includeNamePtr^.size do
|
||||||
|
write(includeNamePtr^.theString[i]);
|
||||||
|
writeln;
|
||||||
|
dataPtr := pointer(ord4(dataPtr) + includeNamePtr^.size + 18);
|
||||||
|
end; {while}
|
||||||
|
end; {PrintIncludes}
|
||||||
|
|
||||||
|
|
||||||
procedure ReadMacroTable;
|
procedure ReadMacroTable;
|
||||||
|
|
||||||
{ Read macros from the symbol file }
|
{ Read macros from the symbol file }
|
||||||
|
@ -1348,7 +1390,10 @@ var
|
||||||
stringConstant: begin
|
stringConstant: begin
|
||||||
token.sval := ReadLongString;
|
token.sval := ReadLongString;
|
||||||
token.ispstring := ReadByte <> 0;
|
token.ispstring := ReadByte <> 0;
|
||||||
|
token.prefix := charStrPrefixEnum(ReadByte);
|
||||||
end;
|
end;
|
||||||
|
otherCharacter: token.ch := chr(ReadByte);
|
||||||
|
preprocessingNumber: token.errCode := ReadWord;
|
||||||
macroParameter: token.pnum := ReadWord;
|
macroParameter: token.pnum := ReadWord;
|
||||||
reservedSymbol: if token.kind in [lbracech,rbracech,lbrackch,
|
reservedSymbol: if token.kind in [lbracech,rbracech,lbrackch,
|
||||||
rbrackch,poundch,poundpoundop] then
|
rbrackch,poundch,poundpoundop] then
|
||||||
|
@ -1381,7 +1426,6 @@ var
|
||||||
while ReadByte <> 0 do begin
|
while ReadByte <> 0 do begin
|
||||||
tp := pointer(GMalloc(sizeof(tokenListRecord)));
|
tp := pointer(GMalloc(sizeof(tokenListRecord)));
|
||||||
tp^.next := nil;
|
tp^.next := nil;
|
||||||
tp^.tokenString := ReadLongString;
|
|
||||||
ReadToken(tp^.token);
|
ReadToken(tp^.token);
|
||||||
tp^.expandEnabled := boolean(ReadByte);
|
tp^.expandEnabled := boolean(ReadByte);
|
||||||
ReadChars(tp^.tokenStart, tp^.tokenEnd);
|
ReadChars(tp^.tokenStart, tp^.tokenEnd);
|
||||||
|
@ -1436,15 +1480,17 @@ var
|
||||||
end;
|
end;
|
||||||
|
|
||||||
p_keep: begin
|
p_keep: begin
|
||||||
liDCBGS.kFlag := 1;
|
|
||||||
lsPtr := ReadLongString;
|
lsPtr := ReadLongString;
|
||||||
outFileGS.theString.size := lsPtr^.length;
|
if liDCBGS.kFlag = 0 then begin
|
||||||
for i := 1 to outFileGS.theString.size do
|
liDCBGS.kFlag := 1;
|
||||||
outFileGS.theString.theString[i] := lsPtr^.str[i];
|
outFileGS.theString.size := lsPtr^.length;
|
||||||
|
for i := 1 to outFileGS.theString.size do
|
||||||
|
outFileGS.theString.theString[i] := lsPtr^.str[i];
|
||||||
|
end; {if}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
p_line: begin
|
p_line: begin
|
||||||
lineNumber := ReadWord;
|
lineNumber := ReadLong - 1;
|
||||||
lsPtr := ReadLongString;
|
lsPtr := ReadLongString;
|
||||||
sourceFileGS.theString.size := lsPtr^.length;
|
sourceFileGS.theString.size := lsPtr^.length;
|
||||||
for i := 1 to sourceFileGS.theString.size do
|
for i := 1 to sourceFileGS.theString.size do
|
||||||
|
@ -1480,6 +1526,7 @@ var
|
||||||
profileFlag := odd(val >> 2);
|
profileFlag := odd(val >> 2);
|
||||||
traceback := odd(val >> 3);
|
traceback := odd(val >> 3);
|
||||||
checkStack := odd(val >> 4);
|
checkStack := odd(val >> 4);
|
||||||
|
checkNullPointers := odd(val >> 5);
|
||||||
debugStrFlag := odd(val >> 15);
|
debugStrFlag := odd(val >> 15);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -1501,6 +1548,7 @@ var
|
||||||
commonSubexpression := odd(val >> 4);
|
commonSubexpression := odd(val >> 4);
|
||||||
loopOptimizations := odd(val >> 5);
|
loopOptimizations := odd(val >> 5);
|
||||||
strictVararg := odd(val >> 6);
|
strictVararg := odd(val >> 6);
|
||||||
|
fastMath := odd(val >> 7);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
p_stacksize: stackSize := ReadWord;
|
p_stacksize: stackSize := ReadWord;
|
||||||
|
@ -1547,11 +1595,18 @@ var
|
||||||
currentSegment[i] := chr(ReadByte);
|
currentSegment[i] := chr(ReadByte);
|
||||||
end; {for}
|
end; {for}
|
||||||
segmentKind := ReadWord;
|
segmentKind := ReadWord;
|
||||||
|
defaultSegmentKind := ReadWord;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
p_unix: unix_1 := boolean(ReadByte);
|
p_unix: unix_1 := boolean(ReadByte);
|
||||||
|
|
||||||
p_fenv_access: fenvAccess := boolean(ReadByte);
|
p_fenv_access: fenvAccess := boolean(ReadByte);
|
||||||
|
|
||||||
|
p_extensions: begin
|
||||||
|
i := ReadByte;
|
||||||
|
extendedKeywords := odd(i);
|
||||||
|
extendedParameters := odd(i >> 1);
|
||||||
|
end;
|
||||||
|
|
||||||
otherwise: begin
|
otherwise: begin
|
||||||
PurgeSymbols;
|
PurgeSymbols;
|
||||||
|
@ -1694,6 +1749,7 @@ var
|
||||||
ep := ip;
|
ep := ip;
|
||||||
end; {while}
|
end; {while}
|
||||||
tp^.constMember := boolean(ReadByte);
|
tp^.constMember := boolean(ReadByte);
|
||||||
|
tp^.flexibleArrayMember := boolean(ReadByte);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
enumType: ;
|
enumType: ;
|
||||||
|
@ -1741,6 +1797,8 @@ var
|
||||||
15: tp := uCharPtr;
|
15: tp := uCharPtr;
|
||||||
16: tp := shortPtr;
|
16: tp := shortPtr;
|
||||||
17: tp := uShortPtr;
|
17: tp := uShortPtr;
|
||||||
|
18: tp := utf16StringTypePtr;
|
||||||
|
19: tp := utf32StringTypePtr;
|
||||||
|
|
||||||
otherwise: begin
|
otherwise: begin
|
||||||
PurgeSymbols;
|
PurgeSymbols;
|
||||||
|
@ -1783,6 +1841,11 @@ var
|
||||||
sp^.isForwardDeclared := boolean(ReadByte);
|
sp^.isForwardDeclared := boolean(ReadByte);
|
||||||
sp^.class := tokenEnum(ReadByte);
|
sp^.class := tokenEnum(ReadByte);
|
||||||
sp^.storage := storageType(ReadByte);
|
sp^.storage := storageType(ReadByte);
|
||||||
|
sp^.used := false;
|
||||||
|
if sp^.storage = none then
|
||||||
|
sp^.anonMemberField := false
|
||||||
|
else if sp^.storage = external then
|
||||||
|
sp^.inlineDefinition := boolean(ReadByte);
|
||||||
ReadIdent := sp;
|
ReadIdent := sp;
|
||||||
end; {ReadIdent}
|
end; {ReadIdent}
|
||||||
|
|
||||||
|
@ -1862,15 +1925,31 @@ var
|
||||||
end; {OpenSymbolFile}
|
end; {OpenSymbolFile}
|
||||||
|
|
||||||
|
|
||||||
function SymbolVersion: integer;
|
function SymbolFileIsUsable: boolean;
|
||||||
|
|
||||||
{ Read the symbol file version number }
|
{ Read the symbol file header to check if it is usable }
|
||||||
{ }
|
{ }
|
||||||
{ Returns: version number }
|
{ Returns: True if the symbol file is usable, false if not }
|
||||||
|
|
||||||
begin {SymbolVersion}
|
label 1;
|
||||||
SymbolVersion := ReadWord;
|
|
||||||
end; {SymbolVersion}
|
var
|
||||||
|
ccPtr: longStringPtr; {cc= string recorded in symbol file}
|
||||||
|
i: integer; {loop counter}
|
||||||
|
|
||||||
|
begin {SymbolFileIsUsable}
|
||||||
|
SymbolFileIsUsable := false;
|
||||||
|
if ReadWord = symFileVersion then begin
|
||||||
|
ccPtr := ReadLongString;
|
||||||
|
if ccPtr^.length = infoStringGS.theString.size then begin
|
||||||
|
for i := 1 to infoStringGS.theString.size do
|
||||||
|
if ccPtr^.str[i] <> infoStringGS.theString.theString[i] then
|
||||||
|
goto 1;
|
||||||
|
SymbolFileIsUsable := true;
|
||||||
|
end; {if}
|
||||||
|
end; {if}
|
||||||
|
1:
|
||||||
|
end; {SymbolFileIsUsable}
|
||||||
|
|
||||||
|
|
||||||
function SourceMatches: boolean;
|
function SourceMatches: boolean;
|
||||||
|
@ -1924,14 +2003,17 @@ if not ignoreSymbols then begin
|
||||||
includeLevel := 0; {no nested includes}
|
includeLevel := 0; {no nested includes}
|
||||||
symChPtr := chPtr; {record initial source location}
|
symChPtr := chPtr; {record initial source location}
|
||||||
if OpenSymbolFile(fName) then begin {check for symbol file}
|
if OpenSymbolFile(fName) then begin {check for symbol file}
|
||||||
if SymbolVersion = symFileVersion then begin
|
if SymbolFileIsUsable then begin
|
||||||
done := EndOfSymbols; {valid file found - process it}
|
done := EndOfSymbols; {valid file found - process it}
|
||||||
if done then
|
if done then
|
||||||
PurgeSymbols;
|
PurgeSymbols;
|
||||||
typeDispList := nil;
|
typeDispList := nil;
|
||||||
while not done do begin
|
while not done do begin
|
||||||
|
includesPtr := symPtr;
|
||||||
if DatesMatch then begin
|
if DatesMatch then begin
|
||||||
if SourceMatches then begin
|
if SourceMatches then begin
|
||||||
|
if progress then
|
||||||
|
PrintIncludes;
|
||||||
ReadMacroTable;
|
ReadMacroTable;
|
||||||
ReadSymbolTable;
|
ReadSymbolTable;
|
||||||
ReadPragmas;
|
ReadPragmas;
|
||||||
|
|
44
MM.pas
44
MM.pas
|
@ -23,6 +23,7 @@
|
||||||
{ GCalloc - allocate & clear memory from the global pool }
|
{ GCalloc - allocate & clear memory from the global pool }
|
||||||
{ GInit - initialize a global pool }
|
{ GInit - initialize a global pool }
|
||||||
{ GMalloc - allocate memory from the global pool }
|
{ GMalloc - allocate memory from the global pool }
|
||||||
|
{ GLongMalloc - allocate global memory }
|
||||||
{ LInit - initialize a local pool }
|
{ LInit - initialize a local pool }
|
||||||
{ LMalloc - allocate memory from the local pool }
|
{ LMalloc - allocate memory from the local pool }
|
||||||
{ Malloc - allocate memory }
|
{ Malloc - allocate memory }
|
||||||
|
@ -73,6 +74,15 @@ procedure GInit;
|
||||||
{ Initialize a global pool }
|
{ Initialize a global pool }
|
||||||
|
|
||||||
|
|
||||||
|
function GLongMalloc (bytes: longint): ptr;
|
||||||
|
|
||||||
|
{ Allocate a potentially large amount of global memory. }
|
||||||
|
{ }
|
||||||
|
{ Parameters: }
|
||||||
|
{ bytes - number of bytes to allocate }
|
||||||
|
{ ptr - points to the first byte of the allocated memory }
|
||||||
|
|
||||||
|
|
||||||
function GMalloc (bytes: integer): ptr;
|
function GMalloc (bytes: integer): ptr;
|
||||||
|
|
||||||
{ Allocate memory from the global pool. }
|
{ Allocate memory from the global pool. }
|
||||||
|
@ -168,8 +178,11 @@ var
|
||||||
|
|
||||||
begin {GMalloc}
|
begin {GMalloc}
|
||||||
if bytes > globalSize then begin {allocate a new pool, if needed}
|
if bytes > globalSize then begin {allocate a new pool, if needed}
|
||||||
globalSize := poolSize;
|
if bytes > poolSize then
|
||||||
myhandle := NewHandle(poolSize, globalID, $C010, nil);
|
globalSize := bytes
|
||||||
|
else
|
||||||
|
globalSize := poolSize;
|
||||||
|
myhandle := NewHandle(globalSize, globalID, $C010, nil);
|
||||||
if ToolError <> 0 then TermError(5);
|
if ToolError <> 0 then TermError(5);
|
||||||
globalPtr := myhandle^;
|
globalPtr := myhandle^;
|
||||||
end; {if}
|
end; {if}
|
||||||
|
@ -179,6 +192,24 @@ globalPtr := pointer(ord4(globalPtr) + bytes);
|
||||||
end; {GMalloc}
|
end; {GMalloc}
|
||||||
|
|
||||||
|
|
||||||
|
function GLongMalloc {bytes: longint): ptr};
|
||||||
|
|
||||||
|
{ Allocate a potentially large amount of global memory. }
|
||||||
|
{ }
|
||||||
|
{ Parameters: }
|
||||||
|
{ bytes - number of bytes to allocate }
|
||||||
|
{ ptr - points to the first byte of the allocated memory }
|
||||||
|
|
||||||
|
var
|
||||||
|
myhandle: handle; {for dereferencing the block}
|
||||||
|
|
||||||
|
begin {GLongMalloc}
|
||||||
|
myhandle := NewHandle(bytes, globalID, $C000, nil);
|
||||||
|
if ToolError <> 0 then TermError(5);
|
||||||
|
GLongMalloc := myhandle^;
|
||||||
|
end; {GLongMalloc}
|
||||||
|
|
||||||
|
|
||||||
procedure LInit;
|
procedure LInit;
|
||||||
|
|
||||||
{ Initialize a local pool }
|
{ Initialize a local pool }
|
||||||
|
@ -209,8 +240,11 @@ var
|
||||||
|
|
||||||
begin {LMalloc}
|
begin {LMalloc}
|
||||||
if bytes > localSize then begin {allocate a new pool, if needed}
|
if bytes > localSize then begin {allocate a new pool, if needed}
|
||||||
localSize := poolSize;
|
if bytes > poolSize then
|
||||||
myhandle := NewHandle(poolSize, localID, $C010, nil);
|
localSize := bytes
|
||||||
|
else
|
||||||
|
localSize := poolSize;
|
||||||
|
myhandle := NewHandle(localSize, localID, $C010, nil);
|
||||||
if ToolError <> 0 then TermError(5);
|
if ToolError <> 0 then TermError(5);
|
||||||
localPtr := myhandle^;
|
localPtr := myhandle^;
|
||||||
end; {if}
|
end; {if}
|
||||||
|
@ -227,6 +261,8 @@ procedure MMQuit;
|
||||||
begin {MMQuit}
|
begin {MMQuit}
|
||||||
DisposeAll(globalID);
|
DisposeAll(globalID);
|
||||||
DisposeAll(localID);
|
DisposeAll(localID);
|
||||||
|
globalID := 0; {do not use old IDs after restart}
|
||||||
|
localID := 0;
|
||||||
end; {MMQuit}
|
end; {MMQuit}
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
BIN
Manual.docx
Normal file
BIN
Manual.docx
Normal file
Binary file not shown.
15
Native.asm
15
Native.asm
|
@ -50,7 +50,8 @@ rtl dec nNextSpot nnextspot := nnextspot-1;
|
||||||
*
|
*
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
Short start
|
Short start CodeGen
|
||||||
|
using ShortData
|
||||||
elSize equ 12 size of npeep array element
|
elSize equ 12 size of npeep array element
|
||||||
peep_opcode equ 0 disp in nativeType of opcode
|
peep_opcode equ 0 disp in nativeType of opcode
|
||||||
peep_mode equ 2 disp in nativeType of mode
|
peep_mode equ 2 disp in nativeType of mode
|
||||||
|
@ -86,7 +87,8 @@ lb1 lda nPeep+peep_opcode,X if npeep[i].opcode = d_lab then
|
||||||
inc fn
|
inc fn
|
||||||
bra lab1 goto 1;
|
bra lab1 goto 1;
|
||||||
lb2 anop end;
|
lb2 anop end;
|
||||||
lda nPeep+peep_opcode,X len := len+size[npeep[i].mode];
|
lda nPeep+peep_opcode,X len := len+size[npeep[i].opcode & ~asmFlag];
|
||||||
|
and #$7FFF
|
||||||
tay
|
tay
|
||||||
lda size,Y
|
lda size,Y
|
||||||
and #$00FF
|
and #$00FF
|
||||||
|
@ -122,7 +124,8 @@ lb4 lda i while i < nnextspot do begin
|
||||||
inc fn
|
inc fn
|
||||||
bra lab1 goto 1;
|
bra lab1 goto 1;
|
||||||
lb5 anop end;
|
lb5 anop end;
|
||||||
lda nPeep+peep_opcode,X len := len+size[npeep[i].mode];
|
lda nPeep+peep_opcode,X len := len+size[npeep[i].opcode & ~asmFlag];
|
||||||
|
and #$7FFF
|
||||||
tay
|
tay
|
||||||
lda size,Y
|
lda size,Y
|
||||||
and #$00FF
|
and #$00FF
|
||||||
|
@ -138,7 +141,9 @@ lb5 anop end;
|
||||||
lb6 stz fn Short := false;
|
lb6 stz fn Short := false;
|
||||||
lab1 anop 1:end; {Short}
|
lab1 anop 1:end; {Short}
|
||||||
return 2:fn
|
return 2:fn
|
||||||
|
end
|
||||||
|
|
||||||
|
ShortData privdata
|
||||||
fn ds 2 function return value
|
fn ds 2 function return value
|
||||||
|
|
||||||
size dc i1'2,2,2,2,2,2,2,2,1,3,1,1,3,3,3,4'
|
size dc i1'2,2,2,2,2,2,2,2,1,3,1,1,3,3,3,4'
|
||||||
|
@ -159,5 +164,5 @@ size dc i1'2,2,2,2,2,2,2,2,1,3,1,1,3,3,3,4'
|
||||||
dc i1'3,2,2,2,2,2,2,2,1,3,1,1,3,3,3,4'
|
dc i1'3,2,2,2,2,2,2,2,1,3,1,1,3,3,3,4'
|
||||||
dc i1'2,2,2,2,3,2,2,2,1,3,1,1,3,3,3,4'
|
dc i1'2,2,2,2,3,2,2,2,1,3,1,1,3,3,3,4'
|
||||||
|
|
||||||
dc i1'0,0,1,2,0,2,0,255'
|
dc i1'0,0,1,2,0,2,0,255,1,2,4'
|
||||||
end
|
end
|
||||||
|
|
498
Native.pas
498
Native.pas
|
@ -86,6 +86,14 @@ procedure GenImplied (p_opcode: integer);
|
||||||
{ p_code - operation code }
|
{ p_code - operation code }
|
||||||
|
|
||||||
|
|
||||||
|
procedure GenImpliedForFlags (p_opcode: integer);
|
||||||
|
|
||||||
|
{ Generate implied addressing instruction used for flags only. }
|
||||||
|
{ }
|
||||||
|
{ parameters: }
|
||||||
|
{ p_code - operation code (m_tax or m_tay) }
|
||||||
|
|
||||||
|
|
||||||
procedure GenCall (callNum: integer);
|
procedure GenCall (callNum: integer);
|
||||||
|
|
||||||
{ short form of jsl to library subroutine - reduces code size }
|
{ short form of jsl to library subroutine - reduces code size }
|
||||||
|
@ -102,6 +110,14 @@ procedure GenLab (lnum: integer);
|
||||||
{ lnum - label number }
|
{ lnum - label number }
|
||||||
|
|
||||||
|
|
||||||
|
procedure GenLabUsedOnce (lnum: integer);
|
||||||
|
|
||||||
|
{ generate a label that is only targeted by one branch }
|
||||||
|
{ }
|
||||||
|
{ parameters: }
|
||||||
|
{ lnum - label number }
|
||||||
|
|
||||||
|
|
||||||
procedure InitFile (keepName: gsosOutStringPtr; keepFlag: integer; partial: boolean);
|
procedure InitFile (keepName: gsosOutStringPtr; keepFlag: integer; partial: boolean);
|
||||||
|
|
||||||
{ Set up the object file }
|
{ Set up the object file }
|
||||||
|
@ -180,11 +196,15 @@ type
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
{native peephole optimization}
|
{register optimization}
|
||||||
{----------------------------}
|
{---------------------}
|
||||||
aRegister, {current register contents}
|
aRegister, {current register contents}
|
||||||
xRegister,
|
xRegister,
|
||||||
yRegister: registerType;
|
yRegister: registerType;
|
||||||
|
lastRegOpcode: integer; {opcode of last reg/flag-setting instr.}
|
||||||
|
|
||||||
|
{native peephole optimization}
|
||||||
|
{----------------------------}
|
||||||
nleadOpcodes: set of 0..max_opcode; {instructions that can start an opt.}
|
nleadOpcodes: set of 0..max_opcode; {instructions that can start an opt.}
|
||||||
nstopOpcodes: set of 0..max_opcode; {instructions not involved in opt.}
|
nstopOpcodes: set of 0..max_opcode; {instructions not involved in opt.}
|
||||||
nnextspot: npeepRange; {next empty spot in npeep}
|
nnextspot: npeepRange; {next empty spot in npeep}
|
||||||
|
@ -281,7 +301,7 @@ else begin
|
||||||
end; {if}
|
end; {if}
|
||||||
if shift <> 0 then begin
|
if shift <> 0 then begin
|
||||||
Out(129); {shift the address}
|
Out(129); {shift the address}
|
||||||
Out2(-shift); Out2(-1);
|
Out2(-shift); if (shift > 0) then Out2(-1) else Out2(0);
|
||||||
Out(7);
|
Out(7);
|
||||||
end; {if}
|
end; {if}
|
||||||
if lab <> maxlabel then {if not a string, end the expression}
|
if lab <> maxlabel then {if not a string, end the expression}
|
||||||
|
@ -300,7 +320,7 @@ procedure UpDate (lab: integer; labelValue: longint);
|
||||||
{ labelValue - displacement in seg where label is located }
|
{ labelValue - displacement in seg where label is located }
|
||||||
|
|
||||||
var
|
var
|
||||||
next,temp: labelptr; {work pointers}
|
next: labelptr; {work pointer}
|
||||||
|
|
||||||
begin {UpDate}
|
begin {UpDate}
|
||||||
if labeltab[lab].defined then
|
if labeltab[lab].defined then
|
||||||
|
@ -322,7 +342,6 @@ else begin
|
||||||
Out2(long(labelvalue).lsw);
|
Out2(long(labelvalue).lsw);
|
||||||
Out2(long(labelvalue).msw);
|
Out2(long(labelvalue).msw);
|
||||||
blkcnt := blkcnt-4;
|
blkcnt := blkcnt-4;
|
||||||
temp := next;
|
|
||||||
next := next^.next;
|
next := next^.next;
|
||||||
end; {while}
|
end; {while}
|
||||||
segdisp := blkcnt;
|
segdisp := blkcnt;
|
||||||
|
@ -346,9 +365,10 @@ procedure WriteNative (opcode: integer; mode: addressingMode; operand: integer;
|
||||||
label 1;
|
label 1;
|
||||||
|
|
||||||
type
|
type
|
||||||
rkind = (k1,k2,k3,k4); {cnv record types}
|
rkind = (k1,k2,k3,k4,k5); {cnv record types}
|
||||||
|
|
||||||
var
|
var
|
||||||
|
bp: ^byte; {byte pointer}
|
||||||
ch: char; {temp storage for string constants}
|
ch: char; {temp storage for string constants}
|
||||||
cns: realRec; {for converting reals to bytes}
|
cns: realRec; {for converting reals to bytes}
|
||||||
cnv: record {for converting double, real to bytes}
|
cnv: record {for converting double, real to bytes}
|
||||||
|
@ -356,7 +376,8 @@ var
|
||||||
k1: (rval: real;);
|
k1: (rval: real;);
|
||||||
k2: (dval: double;);
|
k2: (dval: double;);
|
||||||
k3: (qval: longlong);
|
k3: (qval: longlong);
|
||||||
k4: (ival1,ival2,ival3,ival4: integer;);
|
k4: (eval: extended);
|
||||||
|
k5: (ival1,ival2,ival3,ival4,ival5: integer;);
|
||||||
end;
|
end;
|
||||||
count: integer; {number of constants to repeat}
|
count: integer; {number of constants to repeat}
|
||||||
i,j,k: integer; {loop variables}
|
i,j,k: integer; {loop variables}
|
||||||
|
@ -382,7 +403,7 @@ var
|
||||||
pc := pc+1;
|
pc := pc+1;
|
||||||
end {if}
|
end {if}
|
||||||
else if (flags & localLab) <> 0 then
|
else if (flags & localLab) <> 0 then
|
||||||
LabelSearch(long(name).lsw, 1, ord(odd(flags div shift16))*16, operand)
|
LabelSearch(long(name).lsw, 1, ord((flags & shift16) <> 0)*16, operand)
|
||||||
else if (flags & shift16) <> 0 then
|
else if (flags & shift16) <> 0 then
|
||||||
RefName(name, operand, 1, -16)
|
RefName(name, operand, 1, -16)
|
||||||
else
|
else
|
||||||
|
@ -414,7 +435,7 @@ var
|
||||||
else if (flags & shift8) <> 0 then
|
else if (flags & shift8) <> 0 then
|
||||||
RefName(name, operand, 2, -8)
|
RefName(name, operand, 2, -8)
|
||||||
else if (flags & localLab) <> 0 then
|
else if (flags & localLab) <> 0 then
|
||||||
LabelSearch(long(name).lsw, 2, ord(odd(flags div shift16))*16, operand)
|
LabelSearch(long(name).lsw, 2, ord((flags & shift16) <> 0)*16, operand)
|
||||||
else if (flags & shift16) <> 0 then
|
else if (flags & shift16) <> 0 then
|
||||||
RefName(name, operand, 2, -16)
|
RefName(name, operand, 2, -16)
|
||||||
else if name = nil then
|
else if name = nil then
|
||||||
|
@ -446,6 +467,26 @@ var
|
||||||
end; {DefGlobal}
|
end; {DefGlobal}
|
||||||
|
|
||||||
|
|
||||||
|
function ShiftSize (flags: integer): integer;
|
||||||
|
|
||||||
|
{ Determine the shift size specified by flags. }
|
||||||
|
{ (Positive means right shift, negative means left shift.) }
|
||||||
|
{ }
|
||||||
|
{ parameters: }
|
||||||
|
{ flags - the flags }
|
||||||
|
|
||||||
|
begin {ShiftSize}
|
||||||
|
if (flags & shift8) <> 0 then
|
||||||
|
ShiftSize := 8
|
||||||
|
else if (flags & shift16) <> 0 then
|
||||||
|
ShiftSize := 16
|
||||||
|
else if (flags & shiftLeft8) <> 0 then
|
||||||
|
ShiftSize := -8
|
||||||
|
else
|
||||||
|
ShiftSize := 0;
|
||||||
|
end; {ShiftSize}
|
||||||
|
|
||||||
|
|
||||||
begin {WriteNative}
|
begin {WriteNative}
|
||||||
{ writeln('WriteNative: ',opcode:4, ', mode=', ord(mode):1,
|
{ writeln('WriteNative: ',opcode:4, ', mode=', ord(mode):1,
|
||||||
' operand=', operand:1); {debug}
|
' operand=', operand:1); {debug}
|
||||||
|
@ -462,6 +503,7 @@ case mode of
|
||||||
if not longA then
|
if not longA then
|
||||||
if operand = 255 then
|
if operand = 255 then
|
||||||
goto 1;
|
goto 1;
|
||||||
|
opcode := opcode & ~asmFlag;
|
||||||
CnOut(opcode);
|
CnOut(opcode);
|
||||||
if opcode = m_pea then
|
if opcode = m_pea then
|
||||||
GenImmediate2
|
GenImmediate2
|
||||||
|
@ -475,12 +517,12 @@ case mode of
|
||||||
else if opcode in [m_rep,m_sep,m_cop] then begin
|
else if opcode in [m_rep,m_sep,m_cop] then begin
|
||||||
GenImmediate1;
|
GenImmediate1;
|
||||||
if opcode = m_rep then begin
|
if opcode = m_rep then begin
|
||||||
if odd(operand div 32) then longA := true;
|
if (operand & 32) <> 0 then longA := true;
|
||||||
if odd(operand div 16) then longI := true;
|
if (operand & 16) <> 0 then longI := true;
|
||||||
end {if}
|
end {if}
|
||||||
else if opcode = m_sep then begin
|
else if opcode = m_sep then begin
|
||||||
if odd(operand div 32) then longA := false;
|
if (operand & 32) <> 0 then longA := false;
|
||||||
if odd(operand div 16) then longI := false;
|
if (operand & 16) <> 0 then longI := false;
|
||||||
end; {else}
|
end; {else}
|
||||||
end {else}
|
end {else}
|
||||||
else
|
else
|
||||||
|
@ -493,16 +535,16 @@ case mode of
|
||||||
|
|
||||||
longabs: begin
|
longabs: begin
|
||||||
CnOut(opcode);
|
CnOut(opcode);
|
||||||
isJSL := opcode = m_jsl; {allow for dynamic segs}
|
isJSL := (opcode & ~asmFlag) = m_jsl; {allow for dynamic segs}
|
||||||
if name = nil then
|
if name = nil then
|
||||||
if odd(flags div toolcall) then begin
|
if (flags & toolcall) <> 0 then begin
|
||||||
CnOut2(0);
|
CnOut2(0);
|
||||||
CnOut(225);
|
CnOut(225);
|
||||||
end {if}
|
end {if}
|
||||||
else
|
else
|
||||||
LabelSearch(operand, 3, 0, 0)
|
LabelSearch(operand, 3, 0, 0)
|
||||||
else
|
else
|
||||||
if odd(flags div toolcall) then begin
|
if (flags & toolcall) <> 0 then begin
|
||||||
CnOut2(long(name).lsw);
|
CnOut2(long(name).lsw);
|
||||||
CnOut(long(name).msw);
|
CnOut(long(name).msw);
|
||||||
end {if}
|
end {if}
|
||||||
|
@ -512,7 +554,7 @@ case mode of
|
||||||
end;
|
end;
|
||||||
|
|
||||||
longabsolute: begin
|
longabsolute: begin
|
||||||
if opcode <> d_add then begin
|
if opcode <> d_dcl then begin
|
||||||
CnOut(opcode);
|
CnOut(opcode);
|
||||||
i := 3;
|
i := 3;
|
||||||
end {if}
|
end {if}
|
||||||
|
@ -523,7 +565,7 @@ case mode of
|
||||||
else if (flags & constantOpnd) <> 0 then begin
|
else if (flags & constantOpnd) <> 0 then begin
|
||||||
lval := ord4(name);
|
lval := ord4(name);
|
||||||
CnOut2(long(lval).lsw);
|
CnOut2(long(lval).lsw);
|
||||||
if opcode = d_add then
|
if opcode = d_dcl then
|
||||||
CnOut2(long(lval).msw)
|
CnOut2(long(lval).msw)
|
||||||
else
|
else
|
||||||
CnOut(long(lval).msw);
|
CnOut(long(lval).msw);
|
||||||
|
@ -533,13 +575,13 @@ case mode of
|
||||||
else begin
|
else begin
|
||||||
CnOut2(operand);
|
CnOut2(operand);
|
||||||
CnOut(0);
|
CnOut(0);
|
||||||
if opcode = d_add then
|
if opcode = d_dcl then
|
||||||
CnOut(0);
|
CnOut(0);
|
||||||
end; {else}
|
end; {else}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
absolute: begin
|
absolute: begin
|
||||||
if opcode <> d_add then
|
if opcode <> d_dcw then
|
||||||
CnOut(opcode);
|
CnOut(opcode);
|
||||||
if (flags & localLab) <> 0 then
|
if (flags & localLab) <> 0 then
|
||||||
LabelSearch(long(name).lsw, 2, 0, operand)
|
LabelSearch(long(name).lsw, 2, 0, operand)
|
||||||
|
@ -552,7 +594,7 @@ case mode of
|
||||||
end;
|
end;
|
||||||
|
|
||||||
direct: begin
|
direct: begin
|
||||||
if opcode <> d_add then
|
if opcode <> d_dcb then
|
||||||
CnOut(opcode);
|
CnOut(opcode);
|
||||||
if (flags & localLab) <> 0 then
|
if (flags & localLab) <> 0 then
|
||||||
LabelSearch(long(name).lsw, 1, 0, operand)
|
LabelSearch(long(name).lsw, 1, 0, operand)
|
||||||
|
@ -633,15 +675,28 @@ case mode of
|
||||||
CnOut(cns.inCOMP[j]);
|
CnOut(cns.inCOMP[j]);
|
||||||
end;
|
end;
|
||||||
cgExtended : begin
|
cgExtended : begin
|
||||||
cns.itsReal := icptr(name)^.rval;
|
cnv.eval := icptr(name)^.rval;
|
||||||
CnvSX(cns);
|
CnOut2(cnv.ival1);
|
||||||
for j := 1 to 10 do
|
CnOut2(cnv.ival2);
|
||||||
CnOut(cns.inSANE[j]);
|
CnOut2(cnv.ival3);
|
||||||
|
CnOut2(cnv.ival4);
|
||||||
|
CnOut2(cnv.ival5);
|
||||||
end;
|
end;
|
||||||
cgString : begin
|
cgString : begin
|
||||||
sptr := icptr(name)^.str;
|
if not icptr(name)^.isByteSeq then begin
|
||||||
for j := 1 to sptr^.length do
|
sptr := icptr(name)^.str;
|
||||||
CnOut(ord(sPtr^.str[j]));
|
for j := 1 to sptr^.length do
|
||||||
|
CnOut(ord(sPtr^.str[j]));
|
||||||
|
end {if}
|
||||||
|
else begin
|
||||||
|
lval := 0;
|
||||||
|
while lval < icptr(name)^.len do begin
|
||||||
|
bp := pointer(
|
||||||
|
ord4(icptr(name)^.data) + lval);
|
||||||
|
CnOut(bp^);
|
||||||
|
lval := lval + 1;
|
||||||
|
end;
|
||||||
|
end; {else}
|
||||||
end;
|
end;
|
||||||
ccPointer : begin
|
ccPointer : begin
|
||||||
if icptr(name)^.lab <> nil then begin
|
if icptr(name)^.lab <> nil then begin
|
||||||
|
@ -674,12 +729,11 @@ case mode of
|
||||||
GenImmediate2;
|
GenImmediate2;
|
||||||
sptr := icptr(name)^.pStr;
|
sptr := icptr(name)^.pStr;
|
||||||
j := sptr^.length;
|
j := sptr^.length;
|
||||||
if maxString-stringSize >= j+1 then begin
|
if maxString-stringSize >= j then begin
|
||||||
for k := 1 to j do
|
for k := 1 to j do
|
||||||
stringSpace[k+stringSize] :=
|
stringSpace^[k+stringSize] :=
|
||||||
sptr^.str[k];
|
sptr^.str[k];
|
||||||
stringSpace[stringSize+j+1] := chr(0);
|
stringSize := stringSize+j;
|
||||||
stringSize := stringSize+j+1;
|
|
||||||
end {if}
|
end {if}
|
||||||
else
|
else
|
||||||
Error(cge3);
|
Error(cge3);
|
||||||
|
@ -690,7 +744,7 @@ case mode of
|
||||||
end;
|
end;
|
||||||
|
|
||||||
genAddress: begin
|
genAddress: begin
|
||||||
if opcode < 256 then
|
if opcode < 256 then {includes opcodes with asmFlag}
|
||||||
CnOut(opcode);
|
CnOut(opcode);
|
||||||
if (flags & stringReference) <> 0 then begin
|
if (flags & stringReference) <> 0 then begin
|
||||||
Purge;
|
Purge;
|
||||||
|
@ -720,8 +774,10 @@ case mode of
|
||||||
LabelSearch(operand, 2, 16, 0)
|
LabelSearch(operand, 2, 16, 0)
|
||||||
else
|
else
|
||||||
LabelSearch(operand, 1, 16, 0)
|
LabelSearch(operand, 1, 16, 0)
|
||||||
|
else if (flags & subtract1) <> 0 then
|
||||||
|
LabelSearch(operand, 0, ShiftSize(flags), 0)
|
||||||
else
|
else
|
||||||
LabelSearch(operand, 0, 0, 0);
|
LabelSearch(operand, 2, 0, 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
special:
|
special:
|
||||||
|
@ -766,7 +822,25 @@ procedure CheckRegisters(p_opcode: integer; p_mode: addressingMode;
|
||||||
{ p_name - named operand }
|
{ p_name - named operand }
|
||||||
{ p_flags - operand modifier flags }
|
{ p_flags - operand modifier flags }
|
||||||
|
|
||||||
label 1,2;
|
label 1,2,3;
|
||||||
|
|
||||||
|
function NZMatchA: boolean;
|
||||||
|
|
||||||
|
{ Are the N and Z flags known to match the value in A? }
|
||||||
|
{ }
|
||||||
|
{ Note: Assumes long registers }
|
||||||
|
|
||||||
|
begin {NZMatchA}
|
||||||
|
NZMatchA := lastRegOpcode in
|
||||||
|
[m_adc_abs,m_adc_dir,m_adc_imm,m_adc_s,m_adc_indl,m_adc_indly,
|
||||||
|
m_and_abs,m_and_dir,m_and_imm,m_and_s,m_and_indl,m_and_indly,m_asl_a,
|
||||||
|
m_dea,m_eor_abs,m_eor_dir,m_eor_imm,m_eor_s,m_eor_indl,m_eor_indly,
|
||||||
|
m_ina,m_lda_abs,m_lda_absx,m_lda_dir,m_lda_dirx,m_lda_imm,m_lda_indl,
|
||||||
|
m_lda_indly,m_lda_long,m_lda_longx,m_lda_s,m_lsr_a,m_ora_abs,m_ora_dir,
|
||||||
|
m_ora_dirX,m_ora_imm,m_ora_long,m_ora_longX,m_ora_s,m_ora_indl,
|
||||||
|
m_ora_indly,m_pla,m_rol_a,m_ror_a,m_sbc_abs,m_sbc_dir,m_sbc_imm,m_sbc_s,
|
||||||
|
m_sbc_indl,m_sbc_indly,m_tax,m_tay,m_tcd,m_tdc,m_txa,m_tya];
|
||||||
|
end; {NZMatchA}
|
||||||
|
|
||||||
begin {CheckRegisters}
|
begin {CheckRegisters}
|
||||||
case p_opcode of
|
case p_opcode of
|
||||||
|
@ -776,7 +850,7 @@ case p_opcode of
|
||||||
m_ora_dir,m_ora_dirX,m_ora_imm,m_ora_long,m_ora_longX,m_ora_s,m_pla,
|
m_ora_dir,m_ora_dirX,m_ora_imm,m_ora_long,m_ora_longX,m_ora_s,m_pla,
|
||||||
m_sbc_abs,m_sbc_dir,m_sbc_imm,m_sbc_s,m_tdc,m_tsc,m_adc_indl,m_adc_indly,
|
m_sbc_abs,m_sbc_dir,m_sbc_imm,m_sbc_s,m_tdc,m_tsc,m_adc_indl,m_adc_indly,
|
||||||
m_and_indl,m_and_indly,m_ora_indl,m_ora_indly,m_sbc_indl,m_sbc_indly,
|
m_and_indl,m_and_indly,m_ora_indl,m_ora_indly,m_sbc_indl,m_sbc_indly,
|
||||||
m_eor_indl,m_eor_indly:
|
m_eor_indl,m_eor_indly,m_rol_a,m_ror_a:
|
||||||
aRegister.condition := regUnknown;
|
aRegister.condition := regUnknown;
|
||||||
|
|
||||||
m_ldy_absX,m_ldy_dirX,m_ply:
|
m_ldy_absX,m_ldy_dirX,m_ply:
|
||||||
|
@ -785,10 +859,13 @@ case p_opcode of
|
||||||
m_plx:
|
m_plx:
|
||||||
xRegister.condition := regUnknown;
|
xRegister.condition := regUnknown;
|
||||||
|
|
||||||
m_bcc,m_bcs,m_beq,m_bmi,m_bne,m_bpl,m_bra,m_brl,m_bvs,m_clc,m_cmp_abs,
|
m_bcc,m_bcs,m_beq,m_bmi,m_bne,m_bpl,m_bvc,m_bvs,
|
||||||
m_cmp_dir,m_cmp_imm,m_cmp_s,m_cmp_indl,m_cmp_indly,m_cpx_imm,m_jml,
|
m_pha,m_phb,m_phd,m_php,m_phx,m_phy,m_pei_dir,m_tcs:
|
||||||
m_pha,m_phb,m_phd,m_phx,m_phy,m_plb,m_rtl,m_rts,m_sec,m_tcs,d_add,d_pin,
|
goto 3;
|
||||||
m_pei_dir,m_cpx_abs,m_cpx_dir,m_cmp_dirx,m_php,m_plp,m_cop,d_wrd: ;
|
|
||||||
|
m_bra,m_brl,m_clc,m_cmp_abs,m_cmp_dir,m_cmp_imm,m_cmp_s,m_cmp_indl,
|
||||||
|
m_cmp_indly,m_cpx_imm,m_jml,m_jmp_indX,m_plb,m_rtl,m_rts,m_sec,d_add,d_pin,
|
||||||
|
m_cpx_abs,m_cpx_dir,m_cpy_imm,m_cmp_dirx,m_plp,m_cop,d_wrd: ;
|
||||||
|
|
||||||
m_pea: begin
|
m_pea: begin
|
||||||
if aRegister.condition = regImmediate then
|
if aRegister.condition = regImmediate then
|
||||||
|
@ -818,9 +895,20 @@ case p_opcode of
|
||||||
goto 2;
|
goto 2;
|
||||||
end; {if}
|
end; {if}
|
||||||
end; {if}
|
end; {if}
|
||||||
|
goto 3;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
m_sta_s,m_pld,m_tcd: begin
|
m_sta_s: begin
|
||||||
|
if aRegister.condition = regLocal then
|
||||||
|
aRegister.condition := regUnknown;
|
||||||
|
if xRegister.condition = regLocal then
|
||||||
|
xRegister.condition := regUnknown;
|
||||||
|
if yRegister.condition = regLocal then
|
||||||
|
yRegister.condition := regUnknown;
|
||||||
|
goto 3;
|
||||||
|
end;
|
||||||
|
|
||||||
|
m_pld,m_tcd: begin
|
||||||
if aRegister.condition = regLocal then
|
if aRegister.condition = regLocal then
|
||||||
aRegister.condition := regUnknown;
|
aRegister.condition := regUnknown;
|
||||||
if xRegister.condition = regLocal then
|
if xRegister.condition = regLocal then
|
||||||
|
@ -836,6 +924,7 @@ case p_opcode of
|
||||||
xRegister.condition := regUnknown;
|
xRegister.condition := regUnknown;
|
||||||
if yRegister.condition <> regImmediate then
|
if yRegister.condition <> regImmediate then
|
||||||
yRegister.condition := regUnknown;
|
yRegister.condition := regUnknown;
|
||||||
|
goto 3;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
m_sta_absX,m_stz_absX,m_sta_longX: begin
|
m_sta_absX,m_stz_absX,m_sta_longX: begin
|
||||||
|
@ -848,10 +937,25 @@ case p_opcode of
|
||||||
if yRegister.condition = regAbsolute then
|
if yRegister.condition = regAbsolute then
|
||||||
if yRegister.lab = p_name then
|
if yRegister.lab = p_name then
|
||||||
yRegister.condition := regUnknown;
|
yRegister.condition := regUnknown;
|
||||||
|
goto 3;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
m_dec_abs,m_inc_abs,m_sta_abs,m_stx_abs,m_sty_abs,m_sta_long,m_stz_abs,
|
m_dec_abs,m_inc_abs,m_tsb_abs: begin
|
||||||
m_tsb_abs: begin
|
if aRegister.condition = regAbsolute then
|
||||||
|
if aRegister.lab = p_name then
|
||||||
|
if aRegister.value = p_operand then
|
||||||
|
aRegister.condition := regUnknown;
|
||||||
|
if xRegister.condition = regAbsolute then
|
||||||
|
if xRegister.lab = p_name then
|
||||||
|
if xRegister.value = p_operand then
|
||||||
|
xRegister.condition := regUnknown;
|
||||||
|
if yRegister.condition = regAbsolute then
|
||||||
|
if yRegister.lab = p_name then
|
||||||
|
if yRegister.value = p_operand then
|
||||||
|
yRegister.condition := regUnknown;
|
||||||
|
end;
|
||||||
|
|
||||||
|
m_sta_abs,m_stx_abs,m_sty_abs,m_sta_long,m_stz_abs: begin
|
||||||
if aRegister.condition = regAbsolute then
|
if aRegister.condition = regAbsolute then
|
||||||
if aRegister.lab = p_name then
|
if aRegister.lab = p_name then
|
||||||
if aRegister.value = p_operand then
|
if aRegister.value = p_operand then
|
||||||
|
@ -867,9 +971,22 @@ case p_opcode of
|
||||||
if yRegister.value = p_operand then
|
if yRegister.value = p_operand then
|
||||||
if p_opcode <> m_sty_abs then
|
if p_opcode <> m_sty_abs then
|
||||||
yRegister.condition := regUnknown;
|
yRegister.condition := regUnknown;
|
||||||
|
goto 3;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
m_dec_dir,m_inc_dir,m_tsb_dir,m_sta_dir,m_stx_dir,m_sty_dir,m_stz_dir: begin
|
m_dec_dir,m_inc_dir,m_tsb_dir: begin
|
||||||
|
if aRegister.condition = regLocal then
|
||||||
|
if aRegister.value = p_operand then
|
||||||
|
aRegister.condition := regUnknown;
|
||||||
|
if xRegister.condition = regLocal then
|
||||||
|
if xRegister.value = p_operand then
|
||||||
|
xRegister.condition := regUnknown;
|
||||||
|
if yRegister.condition = regLocal then
|
||||||
|
if yRegister.value = p_operand then
|
||||||
|
yRegister.condition := regUnknown;
|
||||||
|
end;
|
||||||
|
|
||||||
|
m_sta_dir,m_stx_dir,m_sty_dir,m_stz_dir: begin
|
||||||
if aRegister.condition = regLocal then
|
if aRegister.condition = regLocal then
|
||||||
if aRegister.value = p_operand then
|
if aRegister.value = p_operand then
|
||||||
if p_opcode <> m_sta_dir then
|
if p_opcode <> m_sta_dir then
|
||||||
|
@ -882,9 +999,10 @@ case p_opcode of
|
||||||
if yRegister.value = p_operand then
|
if yRegister.value = p_operand then
|
||||||
if p_opcode <> m_sty_dir then
|
if p_opcode <> m_sty_dir then
|
||||||
yRegister.condition := regUnknown;
|
yRegister.condition := regUnknown;
|
||||||
|
goto 3;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
m_dec_dirX,m_inc_dirX,m_sta_dirX,m_sty_dirX,m_stz_dirX: begin
|
m_dec_dirX,m_inc_dirX: begin
|
||||||
if aRegister.condition = regLocal then
|
if aRegister.condition = regLocal then
|
||||||
if aRegister.value >= p_operand-1 then
|
if aRegister.value >= p_operand-1 then
|
||||||
aRegister.condition := regUnknown;
|
aRegister.condition := regUnknown;
|
||||||
|
@ -895,6 +1013,19 @@ case p_opcode of
|
||||||
if yRegister.value >= p_operand-1 then
|
if yRegister.value >= p_operand-1 then
|
||||||
yRegister.condition := regUnknown;
|
yRegister.condition := regUnknown;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
m_sta_dirX,m_sty_dirX,m_stz_dirX: begin
|
||||||
|
if aRegister.condition = regLocal then
|
||||||
|
if aRegister.value >= p_operand-1 then
|
||||||
|
aRegister.condition := regUnknown;
|
||||||
|
if xRegister.condition = regLocal then
|
||||||
|
if xRegister.value >= p_operand-1 then
|
||||||
|
xRegister.condition := regUnknown;
|
||||||
|
if yRegister.condition = regLocal then
|
||||||
|
if yRegister.value >= p_operand-1 then
|
||||||
|
yRegister.condition := regUnknown;
|
||||||
|
goto 3;
|
||||||
|
end;
|
||||||
|
|
||||||
m_dex:
|
m_dex:
|
||||||
if xRegister.condition = regImmediate then
|
if xRegister.condition = regImmediate then
|
||||||
|
@ -1231,7 +1362,13 @@ case p_opcode of
|
||||||
end;
|
end;
|
||||||
|
|
||||||
m_tax: begin
|
m_tax: begin
|
||||||
if aRegister.condition <> regUnknown then
|
if (p_flags & forFlags) <> 0 then begin
|
||||||
|
if longA then
|
||||||
|
if longI then
|
||||||
|
if NZMatchA then
|
||||||
|
goto 1;
|
||||||
|
end {if}
|
||||||
|
else if aRegister.condition <> regUnknown then
|
||||||
if aRegister.condition = xRegister.condition then
|
if aRegister.condition = xRegister.condition then
|
||||||
if aRegister.value = xRegister.value then
|
if aRegister.value = xRegister.value then
|
||||||
if aRegister.flags = xRegister.flags then
|
if aRegister.flags = xRegister.flags then
|
||||||
|
@ -1243,7 +1380,13 @@ case p_opcode of
|
||||||
end;
|
end;
|
||||||
|
|
||||||
m_tay: begin
|
m_tay: begin
|
||||||
if aRegister.condition <> regUnknown then
|
if (p_flags & forFlags) <> 0 then begin
|
||||||
|
if longA then
|
||||||
|
if longI then
|
||||||
|
if NZMatchA then
|
||||||
|
goto 1;
|
||||||
|
end {if}
|
||||||
|
else if aRegister.condition <> regUnknown then
|
||||||
if aRegister.condition = yRegister.condition then
|
if aRegister.condition = yRegister.condition then
|
||||||
if aRegister.value = yRegister.value then
|
if aRegister.value = yRegister.value then
|
||||||
if aRegister.flags = yRegister.flags then
|
if aRegister.flags = yRegister.flags then
|
||||||
|
@ -1302,9 +1445,12 @@ case p_opcode of
|
||||||
xRegister := yRegister;
|
xRegister := yRegister;
|
||||||
end;
|
end;
|
||||||
end; {case}
|
end; {case}
|
||||||
2:
|
2: {emit the instruction normally}
|
||||||
|
lastRegOpcode := p_opcode;
|
||||||
|
3: {branch here for instructions that}
|
||||||
|
{do not modify A/X/Y or flags }
|
||||||
WriteNative(p_opcode, p_mode, p_operand, p_name, p_flags);
|
WriteNative(p_opcode, p_mode, p_operand, p_name, p_flags);
|
||||||
1:
|
1: {branch here to skip the instruction}
|
||||||
end; {CheckRegisters}
|
end; {CheckRegisters}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1338,16 +1484,16 @@ Purge; {dump constant buffer}
|
||||||
if stringsize <> 0 then begin {define string space}
|
if stringsize <> 0 then begin {define string space}
|
||||||
UpDate(maxLabel, pc); {define the local label for the string space}
|
UpDate(maxLabel, pc); {define the local label for the string space}
|
||||||
for i := 1 to stringsize do
|
for i := 1 to stringsize do
|
||||||
CnOut(ord(stringspace[i]));
|
CnOut(ord(stringspace^[i]));
|
||||||
Purge;
|
Purge;
|
||||||
end; {if}
|
end; {if}
|
||||||
Out(0); {end the segment}
|
Out(0); {end the segment}
|
||||||
segDisp := 8; {update header}
|
segDisp := 8; {update header}
|
||||||
Out2(long(pc).lsw);
|
Out2(long(pc).lsw);
|
||||||
Out2(long(pc).msw);
|
Out2(long(pc).msw);
|
||||||
if pc > $0000FFFF then
|
if pc > $00010000 then
|
||||||
if currentSegment <> '~ARRAYS ' then
|
if currentSegment <> '~ARRAYS ' then
|
||||||
Error(112);
|
Error(184);
|
||||||
blkcnt := blkcnt-4; {purge the segment to disk}
|
blkcnt := blkcnt-4; {purge the segment to disk}
|
||||||
segDisp := blkcnt;
|
segDisp := blkcnt;
|
||||||
CloseSeg;
|
CloseSeg;
|
||||||
|
@ -1422,11 +1568,11 @@ var
|
||||||
for i := ns to nnextSpot-1 do begin
|
for i := ns to nnextSpot-1 do begin
|
||||||
opcode := npeep[i].opcode;
|
opcode := npeep[i].opcode;
|
||||||
if opcode in
|
if opcode in
|
||||||
[m_bcc,m_bcs,m_beq,m_bmi,m_bne,m_bpl,m_bra,m_brl,m_bvs,m_jml,m_jsl,
|
[m_bcc,m_bcs,m_beq,m_bmi,m_bne,m_bpl,m_bra,m_brl,m_bvc,m_bvs,m_jml,
|
||||||
m_lda_abs,m_lda_absx,m_lda_dir,m_lda_dirx,m_lda_imm,m_lda_indl,
|
m_jmp_indX,m_jsl,m_lda_abs,m_lda_absx,m_lda_dir,m_lda_dirx,
|
||||||
m_lda_indly,m_lda_long,m_lda_longx,m_lda_s,m_mvn,m_pla,m_rtl,
|
m_lda_imm,m_lda_indl,m_lda_indly,m_lda_long,m_lda_longx,m_lda_s,
|
||||||
m_rts,m_tdc,m_txa,m_tya,m_tsc,d_end,d_bmov,d_add,d_pin,d_wrd,
|
m_pla,m_rtl,m_rts,m_tdc,m_txa,m_tya,m_tsc,d_end,d_bmov,
|
||||||
d_sym,d_cns] then begin
|
d_add,d_pin,d_wrd,d_sym,d_cns] then begin
|
||||||
ASafe := true;
|
ASafe := true;
|
||||||
goto 1;
|
goto 1;
|
||||||
end {if}
|
end {if}
|
||||||
|
@ -1499,7 +1645,7 @@ var
|
||||||
end; {if}
|
end; {if}
|
||||||
|
|
||||||
m_bcs,m_beq,m_bne,m_bmi,m_bpl,m_bcc:
|
m_bcs,m_beq,m_bne,m_bmi,m_bpl,m_bcc:
|
||||||
if npeep[ns+2].opcode = d_lab then
|
if npeep[ns+2].opcode = d_lab then begin
|
||||||
if npeep[ns+2].operand = operand then
|
if npeep[ns+2].operand = operand then
|
||||||
if npeep[ns+1].opcode = m_brl then begin
|
if npeep[ns+1].opcode = m_brl then begin
|
||||||
if Short(ns,npeep[ns+1].operand) then begin
|
if Short(ns,npeep[ns+1].operand) then begin
|
||||||
|
@ -1534,7 +1680,22 @@ var
|
||||||
opcode := m_bcs
|
opcode := m_bcs
|
||||||
else
|
else
|
||||||
opcode := m_bmi;
|
opcode := m_bmi;
|
||||||
end; {else if m_bra}
|
end {else if m_bra}
|
||||||
|
else if npeep[ns+3].opcode in [m_bra,m_brl] then
|
||||||
|
if Short(ns,npeep[ns+3].operand) then begin
|
||||||
|
operand := npeep[ns+3].operand;
|
||||||
|
if (npeep[ns+2].flags & labelUsedOnce) <> 0 then
|
||||||
|
Remove(ns+2);
|
||||||
|
end; {if}
|
||||||
|
end {if}
|
||||||
|
else if npeep[ns+3].opcode = d_lab then
|
||||||
|
if npeep[ns+3].operand = operand then
|
||||||
|
if npeep[ns+4].opcode in [m_bra,m_brl] then
|
||||||
|
if Short(ns,npeep[ns+4].operand) then begin
|
||||||
|
operand := npeep[ns+4].operand;
|
||||||
|
if (npeep[ns+3].flags & labelUsedOnce) <> 0 then
|
||||||
|
Remove(ns+3);
|
||||||
|
end; {if}
|
||||||
|
|
||||||
m_brl:
|
m_brl:
|
||||||
if Short(ns,operand) then begin
|
if Short(ns,operand) then begin
|
||||||
|
@ -1543,7 +1704,8 @@ var
|
||||||
didOne := true;
|
didOne := true;
|
||||||
end; {if}
|
end; {if}
|
||||||
|
|
||||||
m_bvs:
|
{disabled because current codegen does not produce this sequence}
|
||||||
|
{m_bvs:
|
||||||
if npeep[ns+2].opcode = d_lab then
|
if npeep[ns+2].opcode = d_lab then
|
||||||
if npeep[ns+2].operand = operand then
|
if npeep[ns+2].operand = operand then
|
||||||
if npeep[ns+1].opcode = m_bmi then
|
if npeep[ns+1].opcode = m_bmi then
|
||||||
|
@ -1558,11 +1720,12 @@ var
|
||||||
Remove(ns+3);
|
Remove(ns+3);
|
||||||
end; {if}
|
end; {if}
|
||||||
|
|
||||||
m_dec_abs:
|
{disabled - can generate bad code}
|
||||||
|
{m_dec_abs:
|
||||||
if npeep[ns+1].opcode = m_lda_abs then
|
if npeep[ns+1].opcode = m_lda_abs then
|
||||||
if name^ = npeep[ns+1].name^ then
|
if name^ = npeep[ns+1].name^ then
|
||||||
if npeep[ns+2].opcode = m_beq then
|
if npeep[ns+2].opcode = m_beq then
|
||||||
Remove(ns+1);
|
Remove(ns+1);}
|
||||||
|
|
||||||
m_lda_abs:
|
m_lda_abs:
|
||||||
if npeep[ns+1].opcode = m_clc then begin
|
if npeep[ns+1].opcode = m_clc then begin
|
||||||
|
@ -1637,13 +1800,52 @@ var
|
||||||
npeep[ns+2] := npeep[ns];
|
npeep[ns+2] := npeep[ns];
|
||||||
Remove(ns);
|
Remove(ns);
|
||||||
end {else if}
|
end {else if}
|
||||||
else if npeep[ns+1].opcode = m_xba then
|
else if npeep[ns+1].opcode = m_xba then begin
|
||||||
if npeep[ns+2].opcode = m_and_imm then
|
if npeep[ns+2].opcode = m_and_imm then
|
||||||
if npeep[ns+2].operand = $00FF then begin
|
if npeep[ns+2].operand = $00FF then begin
|
||||||
operand := operand+1;
|
operand := operand+1;
|
||||||
Remove(ns+1);
|
Remove(ns+1);
|
||||||
|
end {if}
|
||||||
|
end {else if}
|
||||||
|
else if npeep[ns+1].opcode = m_tay then
|
||||||
|
if npeep[ns+2].opcode in [m_lda_dir,m_lda_indly,m_pla] then begin
|
||||||
|
opcode := m_ldy_dir;
|
||||||
|
Remove(ns+1);
|
||||||
|
end {if}
|
||||||
|
else if npeep[ns+2].opcode = m_pld then
|
||||||
|
if npeep[ns+3].opcode = m_tsc then begin
|
||||||
|
opcode := m_ldy_dir;
|
||||||
|
Remove(ns+1);
|
||||||
end; {if}
|
end; {if}
|
||||||
|
|
||||||
|
m_ldx_dir:
|
||||||
|
if npeep[ns+1].opcode = m_txs then {optimize stack repair code}
|
||||||
|
if npeep[ns+2].opcode = m_tsx then begin
|
||||||
|
if npeep[ns+3].opcode = m_stx_dir then
|
||||||
|
if npeep[ns+3].operand = npeep[ns].operand then begin
|
||||||
|
Remove(ns+2);
|
||||||
|
Remove(ns+2);
|
||||||
|
end; {if}
|
||||||
|
end {if}
|
||||||
|
else if npeep[ns+2].opcode in
|
||||||
|
[m_sta_dir,m_sta_abs,m_sta_long,m_sta_indl,m_tyx] then begin
|
||||||
|
if (npeep[ns+2].opcode <> m_sta_dir)
|
||||||
|
or (npeep[ns+2].operand <> npeep[ns].operand) then
|
||||||
|
if npeep[ns+3].opcode = m_tsx then
|
||||||
|
if npeep[ns+4].opcode = m_stx_dir then
|
||||||
|
if npeep[ns+4].operand = npeep[ns].operand then begin
|
||||||
|
Remove(ns+3);
|
||||||
|
Remove(ns+3);
|
||||||
|
if npeep[ns+2].opcode = m_tyx then
|
||||||
|
Remove(ns+2);
|
||||||
|
end; {if}
|
||||||
|
end {else if}
|
||||||
|
else if npeep[ns+2].opcode = m_tsc then begin
|
||||||
|
npeep[ns].opcode := m_lda_dir;
|
||||||
|
npeep[ns+1].opcode := m_tcs;
|
||||||
|
Remove(ns+2);
|
||||||
|
end; {else if}
|
||||||
|
|
||||||
m_pei_dir:
|
m_pei_dir:
|
||||||
if npeep[ns+1].opcode = m_pla then begin
|
if npeep[ns+1].opcode = m_pla then begin
|
||||||
opcode := m_lda_dir;
|
opcode := m_lda_dir;
|
||||||
|
@ -1703,14 +1905,14 @@ var
|
||||||
if operand = npeep[ns+1].operand then
|
if operand = npeep[ns+1].operand then
|
||||||
if name = npeep[ns+1].name then
|
if name = npeep[ns+1].name then
|
||||||
if not (npeep[ns+2].opcode in
|
if not (npeep[ns+2].opcode in
|
||||||
[m_bcc,m_bcs,m_beq,m_bmi,m_bne,m_bpl,m_bvs]) then
|
[m_bcc,m_bcs,m_beq,m_bmi,m_bne,m_bpl,m_bvc,m_bvs]) then
|
||||||
Remove(ns+1);
|
Remove(ns+1);
|
||||||
|
|
||||||
m_sta_dir:
|
m_sta_dir:
|
||||||
if npeep[ns+1].opcode = m_lda_dir then
|
if npeep[ns+1].opcode = m_lda_dir then
|
||||||
if operand = npeep[ns+1].operand then
|
if operand = npeep[ns+1].operand then
|
||||||
if not (npeep[ns+2].opcode in
|
if not (npeep[ns+2].opcode in
|
||||||
[m_bcc,m_bcs,m_beq,m_bmi,m_bne,m_bpl,m_bvs]) then
|
[m_bcc,m_bcs,m_beq,m_bmi,m_bne,m_bpl,m_bvc,m_bvs]) then
|
||||||
Remove(ns+1);
|
Remove(ns+1);
|
||||||
|
|
||||||
m_plb:
|
m_plb:
|
||||||
|
@ -1735,7 +1937,7 @@ var
|
||||||
end {if}
|
end {if}
|
||||||
else if npeep[ns+1].opcode = m_txa then begin
|
else if npeep[ns+1].opcode = m_txa then begin
|
||||||
if not (npeep[ns+2].opcode in
|
if not (npeep[ns+2].opcode in
|
||||||
[m_bcc,m_bcs,m_beq,m_bmi,m_bne,m_bpl,m_bvs]) then begin
|
[m_bcc,m_bcs,m_beq,m_bmi,m_bne,m_bpl,m_bvc,m_bvs]) then begin
|
||||||
Remove(ns);
|
Remove(ns);
|
||||||
Remove(ns);
|
Remove(ns);
|
||||||
end; {if}
|
end; {if}
|
||||||
|
@ -1754,12 +1956,16 @@ var
|
||||||
|
|
||||||
m_tya:
|
m_tya:
|
||||||
if npeep[ns+1].opcode = m_sta_dir then begin
|
if npeep[ns+1].opcode = m_sta_dir then begin
|
||||||
npeep[ns+1].opcode := m_sty_dir;
|
if ASafe(ns+2) then begin
|
||||||
Remove(ns);
|
npeep[ns+1].opcode := m_sty_dir;
|
||||||
|
Remove(ns);
|
||||||
|
end; {if}
|
||||||
end {if}
|
end {if}
|
||||||
else if npeep[ns+1].opcode = m_sta_abs then begin
|
else if npeep[ns+1].opcode = m_sta_abs then begin
|
||||||
npeep[ns+1].opcode := m_sty_abs;
|
if ASafe(ns+2) then begin
|
||||||
Remove(ns);
|
npeep[ns+1].opcode := m_sty_abs;
|
||||||
|
Remove(ns);
|
||||||
|
end; {if}
|
||||||
end; {else if}
|
end; {else if}
|
||||||
|
|
||||||
m_tyx:
|
m_tyx:
|
||||||
|
@ -1773,7 +1979,8 @@ var
|
||||||
Remove(ns);
|
Remove(ns);
|
||||||
Remove(ns);
|
Remove(ns);
|
||||||
end {if}
|
end {if}
|
||||||
else if npeep[ns+1].opcode in [m_ldx_abs,m_ldx_dir] then
|
else if npeep[ns+1].opcode in
|
||||||
|
[m_ldx_abs,m_ldx_dir,m_ldy_imm,m_ldy_dir] then
|
||||||
if npeep[ns+2].opcode = m_pla then begin
|
if npeep[ns+2].opcode = m_pla then begin
|
||||||
Remove(ns+2);
|
Remove(ns+2);
|
||||||
Remove(ns);
|
Remove(ns);
|
||||||
|
@ -1807,6 +2014,35 @@ var
|
||||||
if not volatile then
|
if not volatile then
|
||||||
Remove(ns+1);
|
Remove(ns+1);
|
||||||
|
|
||||||
|
m_tcd:
|
||||||
|
if npeep[ns+1].opcode = m_tdc then
|
||||||
|
Remove(ns+1)
|
||||||
|
else if npeep[ns+1].opcode in [m_pea,m_stz_dir,m_stz_abs] then
|
||||||
|
if npeep[ns+2].opcode = m_tdc then
|
||||||
|
Remove(ns+2);
|
||||||
|
|
||||||
|
m_tcs:
|
||||||
|
if npeep[ns+1].opcode = m_tsx then
|
||||||
|
if npeep[ns+2].opcode = m_stx_dir then begin
|
||||||
|
npeep[ns+2].opcode := m_sta_dir;
|
||||||
|
Remove(ns+1);
|
||||||
|
end; {if}
|
||||||
|
|
||||||
|
m_tsx:
|
||||||
|
if npeep[ns+1].opcode = m_stx_dir then
|
||||||
|
if npeep[ns+2].opcode = m_pei_dir then
|
||||||
|
if npeep[ns+3].opcode = m_tsx then
|
||||||
|
if npeep[ns+4].opcode = m_stx_dir then
|
||||||
|
if npeep[ns+1].operand = npeep[ns+2].operand then
|
||||||
|
if npeep[ns+1].operand = npeep[ns+4].operand then
|
||||||
|
begin
|
||||||
|
npeep[ns+1].opcode := m_phx;
|
||||||
|
npeep[ns+1].mode := implied;
|
||||||
|
Remove(ns+2);
|
||||||
|
end; {if}
|
||||||
|
|
||||||
|
{extra explicit cases to ensure this case statement uses a jump table}
|
||||||
|
m_rtl,m_rts,m_jml,m_jsl,m_mvn,m_plp,m_pld,m_txs,
|
||||||
otherwise: ;
|
otherwise: ;
|
||||||
|
|
||||||
end; {case}
|
end; {case}
|
||||||
|
@ -1816,7 +2052,7 @@ var
|
||||||
begin {GenNative}
|
begin {GenNative}
|
||||||
{ writeln('GenNative: ',p_opcode:4, ', mode=', ord(p_mode):1,
|
{ writeln('GenNative: ',p_opcode:4, ', mode=', ord(p_mode):1,
|
||||||
' operand=', p_operand:1); {debug}
|
' operand=', p_operand:1); {debug}
|
||||||
if npeephole and not (strictVararg and hasVarargsCall) then begin
|
if npeephole then begin
|
||||||
if (nnextspot = 1) and not (p_opcode in nleadOpcodes) then begin
|
if (nnextspot = 1) and not (p_opcode in nleadOpcodes) then begin
|
||||||
if p_opcode <> d_end then
|
if p_opcode <> d_end then
|
||||||
if registers then
|
if registers then
|
||||||
|
@ -1945,6 +2181,18 @@ GenNative(p_opcode, implied, 0, nil, 0);
|
||||||
end; {GenImplied}
|
end; {GenImplied}
|
||||||
|
|
||||||
|
|
||||||
|
procedure GenImpliedForFlags {p_opcode: integer};
|
||||||
|
|
||||||
|
{ Generate implied addressing instruction used for flags only. }
|
||||||
|
{ }
|
||||||
|
{ parameters: }
|
||||||
|
{ p_code - operation code (m_tax or m_tay) }
|
||||||
|
|
||||||
|
begin {GenImpliedForFlags}
|
||||||
|
GenNative(p_opcode, implied, 0, nil, forFlags);
|
||||||
|
end; {GenImpliedForFlags}
|
||||||
|
|
||||||
|
|
||||||
procedure GenCall {callNum: integer};
|
procedure GenCall {callNum: integer};
|
||||||
|
|
||||||
{ short form of jsl to library subroutine - reduces code size }
|
{ short form of jsl to library subroutine - reduces code size }
|
||||||
|
@ -2050,6 +2298,11 @@ case callNum of
|
||||||
91: sp := @'~SINGLEPRECISION';
|
91: sp := @'~SINGLEPRECISION';
|
||||||
92: sp := @'~DOUBLEPRECISION';
|
92: sp := @'~DOUBLEPRECISION';
|
||||||
93: sp := @'~COMPPRECISION';
|
93: sp := @'~COMPPRECISION';
|
||||||
|
94: sp := @'~CUMUL2';
|
||||||
|
95: sp := @'~REALFIX';
|
||||||
|
96: sp := @'~DOUBLEFIX';
|
||||||
|
97: sp := @'~COMPFIX';
|
||||||
|
98: sp := @'~CHECKPTRC';
|
||||||
otherwise:
|
otherwise:
|
||||||
Error(cge1);
|
Error(cge1);
|
||||||
end; {case}
|
end; {case}
|
||||||
|
@ -2069,6 +2322,18 @@ GenNative(d_lab, gnrlabel, lnum, nil, 0);
|
||||||
end; {GenLab}
|
end; {GenLab}
|
||||||
|
|
||||||
|
|
||||||
|
procedure GenLabUsedOnce {lnum: integer};
|
||||||
|
|
||||||
|
{ generate a label that is only targeted by one branch }
|
||||||
|
{ }
|
||||||
|
{ parameters: }
|
||||||
|
{ lnum - label number }
|
||||||
|
|
||||||
|
begin {GenLabUsedOnce}
|
||||||
|
GenNative(d_lab, gnrlabel, lnum, nil, labelUsedOnce);
|
||||||
|
end; {GenLabUsedOnce}
|
||||||
|
|
||||||
|
|
||||||
procedure InitFile {keepName: gsosOutStringPtr; keepFlag: integer; partial: boolean};
|
procedure InitFile {keepName: gsosOutStringPtr; keepFlag: integer; partial: boolean};
|
||||||
|
|
||||||
{ Set up the object file }
|
{ Set up the object file }
|
||||||
|
@ -2107,11 +2372,17 @@ procedure InitFile {keepName: gsosOutStringPtr; keepFlag: integer; partial: bool
|
||||||
|
|
||||||
{ set up the data bank register }
|
{ set up the data bank register }
|
||||||
|
|
||||||
|
var
|
||||||
|
lisJSL: boolean; {saved copy of isJSL}
|
||||||
|
|
||||||
begin {SetDataBank}
|
begin {SetDataBank}
|
||||||
|
lisJSL := isJSL;
|
||||||
|
isJSL := false;
|
||||||
CnOut(m_pea);
|
CnOut(m_pea);
|
||||||
RefName(@'~GLOBALS', 0, 2, -8);
|
RefName(@'~GLOBALS', 0, 2, -8);
|
||||||
CnOut(m_plb);
|
CnOut(m_plb);
|
||||||
CnOut(m_plb);
|
CnOut(m_plb);
|
||||||
|
isJSL := lisJSL;
|
||||||
end; {SetDataBank}
|
end; {SetDataBank}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2121,6 +2392,12 @@ procedure InitFile {keepName: gsosOutStringPtr; keepFlag: integer; partial: bool
|
||||||
fname2.theString.size := length(fname2.theString.theString);
|
fname2.theString.size := length(fname2.theString.theString);
|
||||||
OpenObj(fname2);
|
OpenObj(fname2);
|
||||||
|
|
||||||
|
{force this to be a static segment}
|
||||||
|
if (segmentKind & $8000) <> 0 then begin
|
||||||
|
currentSegment := ' ';
|
||||||
|
segmentKind := 0;
|
||||||
|
end; {if}
|
||||||
|
|
||||||
{write the header}
|
{write the header}
|
||||||
InitNative;
|
InitNative;
|
||||||
Header(@'~_ROOT', $4000, 0);
|
Header(@'~_ROOT', $4000, 0);
|
||||||
|
@ -2142,6 +2419,7 @@ procedure InitFile {keepName: gsosOutStringPtr; keepFlag: integer; partial: bool
|
||||||
CnOut(0);
|
CnOut(0);
|
||||||
|
|
||||||
{glue code for calling open routine}
|
{glue code for calling open routine}
|
||||||
|
isJSL := true;
|
||||||
CnOut(m_phb);
|
CnOut(m_phb);
|
||||||
SetDataBank;
|
SetDataBank;
|
||||||
CnOut(m_jsl);
|
CnOut(m_jsl);
|
||||||
|
@ -2182,6 +2460,7 @@ procedure InitFile {keepName: gsosOutStringPtr; keepFlag: integer; partial: bool
|
||||||
RefName(initName, 0, 3, 0);
|
RefName(initName, 0, 3, 0);
|
||||||
CnOut(m_plb);
|
CnOut(m_plb);
|
||||||
CnOut(m_rtl);
|
CnOut(m_rtl);
|
||||||
|
isJSL := false;
|
||||||
end
|
end
|
||||||
|
|
||||||
{classic desk accessory initialization}
|
{classic desk accessory initialization}
|
||||||
|
@ -2199,6 +2478,7 @@ procedure InitFile {keepName: gsosOutStringPtr; keepFlag: integer; partial: bool
|
||||||
RefName(lab, menuLen + dispToCDAClose, 4, 0);
|
RefName(lab, menuLen + dispToCDAClose, 4, 0);
|
||||||
|
|
||||||
{glue code for calling open routine}
|
{glue code for calling open routine}
|
||||||
|
isJSL := true;
|
||||||
CnOut(m_pea);
|
CnOut(m_pea);
|
||||||
CnOut2(1);
|
CnOut2(1);
|
||||||
CnOut(m_jsl);
|
CnOut(m_jsl);
|
||||||
|
@ -2225,33 +2505,40 @@ procedure InitFile {keepName: gsosOutStringPtr; keepFlag: integer; partial: bool
|
||||||
RefName(@'~DAID', 0, 3, 0);
|
RefName(@'~DAID', 0, 3, 0);
|
||||||
CnOut(m_plb);
|
CnOut(m_plb);
|
||||||
CnOut(m_rtl);
|
CnOut(m_rtl);
|
||||||
|
isJSL := false;
|
||||||
end
|
end
|
||||||
|
|
||||||
{control panel device initialization}
|
{control panel device initialization}
|
||||||
else if isCDev then begin
|
else if isCDev then begin
|
||||||
CnOut(m_pea);
|
CnOut(m_phb); {save data bank}
|
||||||
CnOut2(1);
|
SetDataBank; {set data bank}
|
||||||
|
CnOut(m_plx); {get RTL address & original data bank}
|
||||||
|
CnOut(m_ply);
|
||||||
|
CnOut(m_lda_s); CnOut(3); {move CDev parameters}
|
||||||
|
CnOut(m_pha);
|
||||||
|
CnOut(m_lda_s); CnOut(3);
|
||||||
|
CnOut(m_pha);
|
||||||
|
CnOut(m_lda_s); CnOut(9);
|
||||||
|
CnOut(m_sta_s); CnOut(5);
|
||||||
|
CnOut(m_lda_s); CnOut(11);
|
||||||
|
CnOut(m_sta_s); CnOut(7);
|
||||||
|
CnOut(m_lda_s); CnOut(13);
|
||||||
|
CnOut(m_sta_s); CnOut(9);
|
||||||
|
CnOut(m_sta_s); CnOut(15); {store message in result space}
|
||||||
|
CnOut(m_lda_long); {store original user ID in result space}
|
||||||
|
RefName(@'~USER_ID',0,3,0);
|
||||||
|
CnOut(m_sta_s); CnOut(17);
|
||||||
|
CnOut(m_txa); {save RTL address & original data bank}
|
||||||
|
CnOut(m_sta_s); CnOut(11);
|
||||||
|
CnOut(m_tya);
|
||||||
|
CnOut(m_sta_s); CnOut(13);
|
||||||
|
CnOut(m_pea); CnOut2(1); {get user ID}
|
||||||
CnOut(m_jsl);
|
CnOut(m_jsl);
|
||||||
RefName(@'~DAID', 0, 3, 0);
|
RefName(@'~DAID', 0, 3, 0);
|
||||||
CnOut(m_phb);
|
CnOut(m_jsl); {call CDev main routine}
|
||||||
SetDataBank;
|
|
||||||
CnOut(m_pla);
|
|
||||||
CnOut(m_sta_s); CnOut(13);
|
|
||||||
CnOut(m_pla);
|
|
||||||
CnOut(m_sta_s); CnOut(13);
|
|
||||||
CnOut(m_jsl);
|
|
||||||
RefName(openName,0,3,0);
|
RefName(openName,0,3,0);
|
||||||
CnOut(m_tay);
|
CnOut(m_jml); {clean up and return to caller}
|
||||||
CnOut(m_lda_s); CnOut(3);
|
RefName(@'~CDEVCLEANUP', 0, 3, 0);
|
||||||
CnOut(m_pha);
|
|
||||||
CnOut(m_lda_s); CnOut(3);
|
|
||||||
CnOut(m_pha);
|
|
||||||
CnOut(m_txa);
|
|
||||||
CnOut(m_sta_s); CnOut(7);
|
|
||||||
CnOut(m_tya);
|
|
||||||
CnOut(m_sta_s); CnOut(5);
|
|
||||||
CnOut(m_plb);
|
|
||||||
CnOut(m_rtl);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
{NBA initialization}
|
{NBA initialization}
|
||||||
|
@ -2282,6 +2569,7 @@ procedure InitFile {keepName: gsosOutStringPtr; keepFlag: integer; partial: bool
|
||||||
else begin
|
else begin
|
||||||
|
|
||||||
{write the initial JSL}
|
{write the initial JSL}
|
||||||
|
isJSL := true;
|
||||||
CnOut(m_jsl);
|
CnOut(m_jsl);
|
||||||
if rtl then
|
if rtl then
|
||||||
RefName(@'~_BWSTARTUP4', 0, 3, 0)
|
RefName(@'~_BWSTARTUP4', 0, 3, 0)
|
||||||
|
@ -2291,6 +2579,17 @@ procedure InitFile {keepName: gsosOutStringPtr; keepFlag: integer; partial: bool
|
||||||
{set the data bank register}
|
{set the data bank register}
|
||||||
SetDataBank;
|
SetDataBank;
|
||||||
|
|
||||||
|
{set FPE slot, if using FPE}
|
||||||
|
if floatCard = 1 then begin
|
||||||
|
CnOut(m_lda_imm);
|
||||||
|
if floatSlot in [1..7] then
|
||||||
|
CnOut2(floatSlot)
|
||||||
|
else
|
||||||
|
CnOut2(0);
|
||||||
|
CnOut(m_jsl);
|
||||||
|
RefName(@'~INITFLOAT', 0, 3, 0);
|
||||||
|
end; {if}
|
||||||
|
|
||||||
{write JSL to main entry point}
|
{write JSL to main entry point}
|
||||||
CnOut(m_jsl);
|
CnOut(m_jsl);
|
||||||
if rtl then
|
if rtl then
|
||||||
|
@ -2299,7 +2598,8 @@ procedure InitFile {keepName: gsosOutStringPtr; keepFlag: integer; partial: bool
|
||||||
RefName(@'~C_STARTUP', 0, 3, 0);
|
RefName(@'~C_STARTUP', 0, 3, 0);
|
||||||
CnOut(m_jsl);
|
CnOut(m_jsl);
|
||||||
RefName(@'main', 0, 3, 0);
|
RefName(@'main', 0, 3, 0);
|
||||||
CnOut(m_jsl);
|
isJSL := false;
|
||||||
|
CnOut(m_jml);
|
||||||
if rtl then
|
if rtl then
|
||||||
RefName(@'~C_SHUTDOWN2', 0, 3, 0)
|
RefName(@'~C_SHUTDOWN2', 0, 3, 0)
|
||||||
else
|
else
|
||||||
|
@ -2318,6 +2618,7 @@ procedure InitFile {keepName: gsosOutStringPtr; keepFlag: integer; partial: bool
|
||||||
begin {SetStack}
|
begin {SetStack}
|
||||||
if stackSize <> 0 then begin
|
if stackSize <> 0 then begin
|
||||||
currentSegment := '~_STACK '; {write the header}
|
currentSegment := '~_STACK '; {write the header}
|
||||||
|
segmentKind := 0;
|
||||||
Header(@'~_STACK', $4012, 0);
|
Header(@'~_STACK', $4012, 0);
|
||||||
Out($F1); {write the DS record to reserve space}
|
Out($F1); {write the DS record to reserve space}
|
||||||
Out2(stackSize);
|
Out2(stackSize);
|
||||||
|
@ -2354,11 +2655,12 @@ begin {InitNative}
|
||||||
aRegister.condition := regUnknown; {set up the peephole optimizer}
|
aRegister.condition := regUnknown; {set up the peephole optimizer}
|
||||||
xRegister.condition := regUnknown;
|
xRegister.condition := regUnknown;
|
||||||
yRegister.condition := regUnknown;
|
yRegister.condition := regUnknown;
|
||||||
|
lastRegOpcode := 0; {BRK}
|
||||||
nnextspot := 1;
|
nnextspot := 1;
|
||||||
nleadOpcodes := [m_asl_a,m_bcs,m_beq,m_bmi,m_bne,m_bpl,m_brl,m_bvs,m_bcc,
|
nleadOpcodes := [m_asl_a,m_bcc,m_bcs,m_beq,m_bmi,m_bne,m_bpl,m_brl,{m_bvs,}
|
||||||
m_dec_abs,m_lda_abs,m_lda_dir,m_lda_imm,m_ldx_imm,m_sta_abs,m_sta_dir,
|
{m_dec_abs,}m_lda_abs,m_lda_dir,m_lda_imm,m_ldx_imm,m_sta_abs,m_sta_dir,
|
||||||
m_pha,m_plb,m_plx,m_tax,m_tya,m_tyx,m_phy,m_pei_dir,m_ldy_imm,m_rep,
|
m_pha,m_plb,{m_plx,}m_tax,m_tya,m_tyx,m_phy,m_pei_dir,m_ldy_imm,m_rep,
|
||||||
m_ora_dir,m_ora_abs,m_and_imm,m_pea];
|
m_ora_dir,m_ora_abs,m_and_imm,m_pea,m_tcd];
|
||||||
nstopOpcodes := [d_end,d_pin];
|
nstopOpcodes := [d_end,d_pin];
|
||||||
|
|
||||||
stringSize := 0; {initialize scalars for a new segment}
|
stringSize := 0; {initialize scalars for a new segment}
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#define clearAction 0x0009
|
#define clearAction 0x0009
|
||||||
#define sysClickAction 0x000A
|
#define sysClickAction 0x000A
|
||||||
#define optionalCloseAction 0x000B
|
#define optionalCloseAction 0x000B
|
||||||
|
#define reOpenAction 0x000C
|
||||||
|
|
||||||
/* SystemEdit Codes */
|
/* SystemEdit Codes */
|
||||||
#define undoEdit 0x0001
|
#define undoEdit 0x0001
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#define EACCESS 9 /* alias for EACCES */
|
#define EACCESS 9 /* alias for EACCES */
|
||||||
#define EEXIST 10 /* the file exists */
|
#define EEXIST 10 /* the file exists */
|
||||||
#define ENOSPC 11 /* the file is too large */
|
#define ENOSPC 11 /* the file is too large */
|
||||||
|
#define EILSEQ 12 /* encoding error */
|
||||||
|
|
||||||
extern int errno;
|
extern int errno;
|
||||||
#define errno errno
|
#define errno errno
|
||||||
|
|
|
@ -35,6 +35,6 @@ int fcntl(int, int, ...);
|
||||||
long lseek(int, long, int);
|
long lseek(int, long, int);
|
||||||
int open(const char *, int, ...);
|
int open(const char *, int, ...);
|
||||||
int read(int, void *, unsigned);
|
int read(int, void *, unsigned);
|
||||||
int write(int, void *, unsigned);
|
int write(int, const void *, unsigned);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,8 +27,8 @@ typedef unsigned short fexcept_t;
|
||||||
#define FE_TOWARDZERO 0xC0
|
#define FE_TOWARDZERO 0xC0
|
||||||
#define FE_UPWARD 0x40
|
#define FE_UPWARD 0x40
|
||||||
|
|
||||||
extern const fenv_t __FE_DFL_ENV;
|
extern const fenv_t __FE_DFL_ENV[1];
|
||||||
#define FE_DFL_ENV (&__FE_DFL_ENV)
|
#define FE_DFL_ENV (&*__FE_DFL_ENV)
|
||||||
|
|
||||||
int feclearexcept(int);
|
int feclearexcept(int);
|
||||||
int fegetexceptflag(fexcept_t *, int);
|
int fegetexceptflag(fexcept_t *, int);
|
||||||
|
|
|
@ -38,13 +38,13 @@ int __get_flt_rounds(void);
|
||||||
#define DBL_DIG 15
|
#define DBL_DIG 15
|
||||||
#define LDBL_DIG 18
|
#define LDBL_DIG 18
|
||||||
|
|
||||||
#define FLT_MIN_EXP -125
|
#define FLT_MIN_EXP (-125)
|
||||||
#define DBL_MIN_EXP -1021
|
#define DBL_MIN_EXP (-1021)
|
||||||
#define LDBL_MIN_EXP -16382
|
#define LDBL_MIN_EXP (-16382)
|
||||||
|
|
||||||
#define FLT_MIN_10_EXP -37
|
#define FLT_MIN_10_EXP (-37)
|
||||||
#define DBL_MIN_10_EXP -307
|
#define DBL_MIN_10_EXP (-307)
|
||||||
#define LDBL_MIN_10_EXP -4931
|
#define LDBL_MIN_10_EXP (-4931)
|
||||||
|
|
||||||
#define FLT_MAX_EXP 128
|
#define FLT_MAX_EXP 128
|
||||||
#define DBL_MAX_EXP 1024
|
#define DBL_MAX_EXP 1024
|
||||||
|
|
|
@ -14,13 +14,17 @@
|
||||||
#ifndef __GSBUG__
|
#ifndef __GSBUG__
|
||||||
#define __GSBUG__
|
#define __GSBUG__
|
||||||
|
|
||||||
|
/* Error Codes */
|
||||||
|
#define debugUnImpErr 0xFF01
|
||||||
|
#define debugBadSelErr 0xFF02
|
||||||
|
|
||||||
#define dgiProgramCounter 0 /* for DebugGetInfo */
|
#define dgiProgramCounter 0 /* for DebugGetInfo */
|
||||||
|
|
||||||
extern pascal Word DebugVersion() inline(0x04FF,dispatcher);
|
extern pascal Word DebugVersion(void) inline(0x04FF,dispatcher);
|
||||||
extern pascal Word DebugStatus() inline(0x06FF,dispatcher);
|
extern pascal Word DebugStatus(void) inline(0x06FF,dispatcher);
|
||||||
extern pascal void DebugStr() inline(0x09FF,dispatcher);
|
extern pascal void DebugStr(Pointer) inline(0x09FF,dispatcher);
|
||||||
extern pascal void SetMileStone() inline(0x0AFF,dispatcher);
|
extern pascal void SetMileStone(Pointer) inline(0x0AFF,dispatcher);
|
||||||
extern pascal void DebugSetHook() inline(0x0BFF,dispatcher);
|
extern pascal void DebugSetHook(VoidProcPtr) inline(0x0BFF,dispatcher);
|
||||||
extern pascal LongWord DebugGetInfo() inline(0x0CFF,dispatcher);
|
extern pascal LongWord DebugGetInfo(Word) inline(0x0CFF,dispatcher);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -126,7 +126,7 @@
|
||||||
#define invalidFSTop 0x0065 /* invalid FST operation */
|
#define invalidFSTop 0x0065 /* invalid FST operation */
|
||||||
#define fstCaution 0x0066 /* FST handled call, but result is weird */
|
#define fstCaution 0x0066 /* FST handled call, but result is weird */
|
||||||
#define devNameErr 0x0067 /* device exists with same name as replacement name */
|
#define devNameErr 0x0067 /* device exists with same name as replacement name */
|
||||||
#define defListFull 0x0068 /* device list is full */
|
#define devListFull 0x0068 /* device list is full */
|
||||||
#define supListFull 0x0069 /* supervisor list is full */
|
#define supListFull 0x0069 /* supervisor list is full */
|
||||||
#define fstError 0x006a /* generic FST error */
|
#define fstError 0x006a /* generic FST error */
|
||||||
#define resExistsErr 0x0070 /* cannot expand file, resource already exists */
|
#define resExistsErr 0x0070 /* cannot expand file, resource already exists */
|
||||||
|
|
54
ORCACDefs/locale.h
Normal file
54
ORCACDefs/locale.h
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* locale.h - locales
|
||||||
|
*
|
||||||
|
* September 2021
|
||||||
|
* Stephen Heumann
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#ifndef __locale__
|
||||||
|
#define __locale__
|
||||||
|
|
||||||
|
struct lconv {
|
||||||
|
char *decimal_point;
|
||||||
|
char *thousands_sep;
|
||||||
|
char *grouping;
|
||||||
|
char *mon_decimal_point;
|
||||||
|
char *mon_thousands_sep;
|
||||||
|
char *mon_grouping;
|
||||||
|
char *positive_sign;
|
||||||
|
char *negative_sign;
|
||||||
|
char *currency_symbol;
|
||||||
|
char frac_digits;
|
||||||
|
char p_cs_precedes;
|
||||||
|
char n_cs_precedes;
|
||||||
|
char p_sep_by_space;
|
||||||
|
char n_sep_by_space;
|
||||||
|
char p_sign_posn;
|
||||||
|
char n_sign_posn;
|
||||||
|
char *int_curr_symbol;
|
||||||
|
char int_frac_digits;
|
||||||
|
char int_p_cs_precedes;
|
||||||
|
char int_n_cs_precedes;
|
||||||
|
char int_p_sep_by_space;
|
||||||
|
char int_n_sep_by_space;
|
||||||
|
char int_p_sign_posn;
|
||||||
|
char int_n_sign_posn;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
#define NULL (void *) 0L
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LC_ALL 0
|
||||||
|
#define LC_COLLATE 1
|
||||||
|
#define LC_CTYPE 2
|
||||||
|
#define LC_MONETARY 3
|
||||||
|
#define LC_NUMERIC 4
|
||||||
|
#define LC_TIME 5
|
||||||
|
|
||||||
|
struct lconv *localeconv(void);
|
||||||
|
char *setlocale(int, const char *);
|
||||||
|
|
||||||
|
#endif
|
201
ORCACDefs/math.h
201
ORCACDefs/math.h
|
@ -24,6 +24,13 @@ typedef long double double_t;
|
||||||
|
|
||||||
#define NAN (0.0F/0.0F)
|
#define NAN (0.0F/0.0F)
|
||||||
|
|
||||||
|
#define FP_ILOGB0 (-32767-1)
|
||||||
|
#define FP_ILOGBNAN (-32767-1)
|
||||||
|
|
||||||
|
#define MATH_ERRNO 1
|
||||||
|
#define MATH_ERREXCEPT 2
|
||||||
|
#define math_errhandling 2
|
||||||
|
|
||||||
#define FP_INFINITE 0xFE
|
#define FP_INFINITE 0xFE
|
||||||
#define FP_NAN 0xFD
|
#define FP_NAN 0xFD
|
||||||
#define FP_NORMAL 0x00
|
#define FP_NORMAL 0x00
|
||||||
|
@ -34,43 +41,203 @@ int __fpclassifyf(float);
|
||||||
int __fpclassifyd(double);
|
int __fpclassifyd(double);
|
||||||
int __fpclassifyl(long double);
|
int __fpclassifyl(long double);
|
||||||
int __signbit(long double);
|
int __signbit(long double);
|
||||||
|
int __fpcompare(long double, long double, short);
|
||||||
|
|
||||||
#define fpclassify(x) _Generic((x), \
|
#define __fpclassify(x) _Generic((x), \
|
||||||
float: __fpclassifyf, \
|
float: __fpclassifyf, \
|
||||||
double: __fpclassifyd, \
|
double: __fpclassifyd, \
|
||||||
long double: __fpclassifyl)(x)
|
long double: __fpclassifyl)(x)
|
||||||
|
|
||||||
#define isfinite(x) (((fpclassify(x) + 1) & 0xF0) == 0)
|
#define fpclassify(x) __fpclassify(x)
|
||||||
#define isinf(x) (fpclassify(x) == FP_INFINITE)
|
#define isfinite(x) (((__fpclassify(x) + 1) & 0xF0) == 0)
|
||||||
#define isnan(x) (fpclassify((long double)(x)) == FP_NAN)
|
#define isinf(x) (__fpclassify(x) == FP_INFINITE)
|
||||||
#define isnormal(x) (fpclassify(x) == FP_NORMAL)
|
#define isnan(x) (__fpclassify((long double)(x)) == FP_NAN)
|
||||||
#define signbit(x) __signbit(x)
|
#define isnormal(x) (__fpclassify(x) == FP_NORMAL)
|
||||||
|
#define signbit(x) __signbit(x)
|
||||||
|
|
||||||
|
#define isgreater(x,y) __fpcompare((x),(y),0x40)
|
||||||
|
#define isgreaterequal(x,y) __fpcompare((x),(y),0x42)
|
||||||
|
#define isless(x,y) __fpcompare((x),(y),0x80)
|
||||||
|
#define islessequal(x,y) __fpcompare((x),(y),0x82)
|
||||||
|
#define islessgreater(x,y) __fpcompare((x),(y),0xC0)
|
||||||
|
#define isunordered(x,y) __fpcompare((x),(y),0x01)
|
||||||
|
|
||||||
#ifndef __KeepNamespacePure__
|
#ifndef __KeepNamespacePure__
|
||||||
#define arctan(x) atan(x)
|
#define arctan(x) atan(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
double acos(double);
|
double acos(double);
|
||||||
|
float acosf(float);
|
||||||
|
long double acosl(long double);
|
||||||
|
double acosh(double);
|
||||||
|
float acoshf(float);
|
||||||
|
long double acoshl(long double);
|
||||||
double asin(double);
|
double asin(double);
|
||||||
|
float asinf(float);
|
||||||
|
long double asinl(long double);
|
||||||
|
double asinh(double);
|
||||||
|
float asinhf(float);
|
||||||
|
long double asinhl(long double);
|
||||||
double atan(double);
|
double atan(double);
|
||||||
double cos(double);
|
float atanf(float);
|
||||||
double cosh(double);
|
long double atanl(long double);
|
||||||
double exp(double);
|
double atanh(double);
|
||||||
double log(double);
|
float atanhf(float);
|
||||||
double log10(double);
|
long double atanhl(long double);
|
||||||
double sin(double);
|
|
||||||
double sinh(double);
|
|
||||||
double sqrt(double);
|
|
||||||
double tan(double);
|
|
||||||
double tanh(double);
|
|
||||||
double atan2(double, double);
|
double atan2(double, double);
|
||||||
|
float atan2f(float, float);
|
||||||
|
long double atan2l(long double, long double);
|
||||||
|
double cbrt(double);
|
||||||
|
float cbrtf(float);
|
||||||
|
long double cbrtl(long double);
|
||||||
double ceil(double);
|
double ceil(double);
|
||||||
|
float ceilf(float);
|
||||||
|
long double ceill(long double);
|
||||||
|
double copysign(double, double);
|
||||||
|
float copysignf(float, float);
|
||||||
|
long double copysignl(long double, long double);
|
||||||
|
double cos(double);
|
||||||
|
float cosf(float);
|
||||||
|
long double cosl(long double);
|
||||||
|
double cosh(double);
|
||||||
|
float coshf(float);
|
||||||
|
long double coshl(long double);
|
||||||
|
double erf(double);
|
||||||
|
float erff(float);
|
||||||
|
long double erfl(long double);
|
||||||
|
double erfc(double);
|
||||||
|
float erfcf(float);
|
||||||
|
long double erfcl(long double);
|
||||||
|
double exp(double);
|
||||||
|
float expf(float);
|
||||||
|
long double expl(long double);
|
||||||
|
double exp2(double);
|
||||||
|
float exp2f(float);
|
||||||
|
long double exp2l(long double);
|
||||||
|
double expm1(double);
|
||||||
|
float expm1f(float);
|
||||||
|
long double expm1l(long double);
|
||||||
double fabs(double);
|
double fabs(double);
|
||||||
|
float fabsf(float);
|
||||||
|
long double fabsl(long double);
|
||||||
|
double fdim(double, double);
|
||||||
|
float fdimf(float, float);
|
||||||
|
long double fdiml(long double, long double);
|
||||||
double floor(double);
|
double floor(double);
|
||||||
|
float floorf(float);
|
||||||
|
long double floorl(long double);
|
||||||
|
double fma(double, double, double);
|
||||||
|
float fmaf(float, float, float);
|
||||||
|
long double fmal(long double, long double, long double);
|
||||||
|
double fmax(double, double);
|
||||||
|
float fmaxf(float, float);
|
||||||
|
long double fmaxl(long double, long double);
|
||||||
|
double fmin(double, double);
|
||||||
|
float fminf(float, float);
|
||||||
|
long double fminl(long double, long double);
|
||||||
double fmod(double, double);
|
double fmod(double, double);
|
||||||
|
float fmodf(float, float);
|
||||||
|
long double fmodl(long double, long double);
|
||||||
double frexp(double, int *);
|
double frexp(double, int *);
|
||||||
|
float frexpf(float, int *);
|
||||||
|
long double frexpl(long double, int *);
|
||||||
|
double hypot(double, double);
|
||||||
|
float hypotf(float, float);
|
||||||
|
long double hypotl(long double, long double);
|
||||||
|
int ilogb(double);
|
||||||
|
int ilogbf(float);
|
||||||
|
int ilogbl(long double);
|
||||||
double ldexp(double, int);
|
double ldexp(double, int);
|
||||||
|
float ldexpf(float, int);
|
||||||
|
long double ldexpl(long double, int);
|
||||||
|
double lgamma(double);
|
||||||
|
float lgammaf(float);
|
||||||
|
long double lgammal(long double);
|
||||||
|
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
|
||||||
|
long long llrint(double);
|
||||||
|
long long llrintf(float);
|
||||||
|
long long llrintl(long double);
|
||||||
|
long long llround(double);
|
||||||
|
long long llroundf(float);
|
||||||
|
long long llroundl(long double);
|
||||||
|
#endif
|
||||||
|
double log(double);
|
||||||
|
float logf(float);
|
||||||
|
long double logl(long double);
|
||||||
|
double log10(double);
|
||||||
|
float log10f(float);
|
||||||
|
long double log10l(long double);
|
||||||
|
double log1p(double);
|
||||||
|
float log1pf(float);
|
||||||
|
long double log1pl(long double);
|
||||||
|
double log2(double);
|
||||||
|
float log2f(float);
|
||||||
|
long double log2l(long double);
|
||||||
|
double logb(double);
|
||||||
|
float logbf(float);
|
||||||
|
long double logbl(long double);
|
||||||
|
long lrint(double);
|
||||||
|
long lrintf(float);
|
||||||
|
long lrintl(long double);
|
||||||
|
long lround(double);
|
||||||
|
long lroundf(float);
|
||||||
|
long lroundl(long double);
|
||||||
double modf(double, double *);
|
double modf(double, double *);
|
||||||
|
float modff(float, float *);
|
||||||
|
long double modfl(long double, long double *);
|
||||||
|
double nearbyint(double);
|
||||||
|
float nearbyintf(float);
|
||||||
|
long double nearbyintl(long double);
|
||||||
|
double nan(const char *);
|
||||||
|
float nanf(const char *);
|
||||||
|
long double nanl(const char *);
|
||||||
|
double nextafter(double, double);
|
||||||
|
float nextafterf(float, float);
|
||||||
|
long double nextafterl(long double, long double);
|
||||||
|
double nexttoward(double, long double);
|
||||||
|
float nexttowardf(float, long double);
|
||||||
|
long double nexttowardl(long double, long double);
|
||||||
double pow(double, double);
|
double pow(double, double);
|
||||||
|
float powf(float, float);
|
||||||
|
long double powl(long double, long double);
|
||||||
|
double remainder(double, double);
|
||||||
|
float remainderf(float, float);
|
||||||
|
long double remainderl(long double, long double);
|
||||||
|
double remquo(double, double, int *);
|
||||||
|
float remquof(float, float, int *);
|
||||||
|
long double remquol(long double, long double, int *);
|
||||||
|
double rint(double);
|
||||||
|
float rintf(float);
|
||||||
|
long double rintl(long double);
|
||||||
|
double round(double);
|
||||||
|
float roundf(float);
|
||||||
|
long double roundl(long double);
|
||||||
|
double scalbln(double, long);
|
||||||
|
float scalblnf(float, long);
|
||||||
|
long double scalblnl(long double, long);
|
||||||
|
double scalbn(double, int);
|
||||||
|
float scalbnf(float, int);
|
||||||
|
long double scalbnl(long double, int);
|
||||||
|
double sin(double);
|
||||||
|
float sinf(float);
|
||||||
|
long double sinl(long double);
|
||||||
|
double sinh(double);
|
||||||
|
float sinhf(float);
|
||||||
|
long double sinhl(long double);
|
||||||
|
double sqrt(double);
|
||||||
|
float sqrtf(float);
|
||||||
|
long double sqrtl(long double);
|
||||||
|
double tan(double);
|
||||||
|
float tanf(float);
|
||||||
|
long double tanl(long double);
|
||||||
|
double tanh(double);
|
||||||
|
float tanhf(float);
|
||||||
|
long double tanhl(long double);
|
||||||
|
double tgamma(double);
|
||||||
|
float tgammaf(float);
|
||||||
|
long double tgammal(long double);
|
||||||
|
double trunc(double);
|
||||||
|
float truncf(float);
|
||||||
|
long double truncl(long double);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -277,9 +277,18 @@
|
||||||
#define sbAlertCaution 0x0054
|
#define sbAlertCaution 0x0054
|
||||||
#define sbScreenBlanking 0x0060
|
#define sbScreenBlanking 0x0060
|
||||||
#define sbScreenUnblanking 0x0061
|
#define sbScreenUnblanking 0x0061
|
||||||
|
#define sbBeginningLongOperation 0x0070
|
||||||
#define sbYouHaveMail 0x0100
|
#define sbYouHaveMail 0x0100
|
||||||
#define sbErrorWindowBase 0x0E00 /* uses $0Exx */
|
#define sbErrorWindowBase 0x0E00 /* uses $0Exx */
|
||||||
#define sbErrorWindowOther 0x0EFF
|
#define sbErrorWindowOther 0x0EFF
|
||||||
|
#define sbFileTransferred 0x0F80
|
||||||
|
#define sbRealtimeMessage 0x0F81
|
||||||
|
#define sbConnectedToService 0x1000
|
||||||
|
#define sbDisconnectedFromService 0x1001
|
||||||
|
#define sbEnteredRealtimeChat 0x1002
|
||||||
|
#define sbLeftRealtimeChat 0x1003
|
||||||
|
#define sbFeatureEnabled 0x1010
|
||||||
|
#define sbFeatureDisabled 0x1011
|
||||||
|
|
||||||
/* StringToText constants */
|
/* StringToText constants */
|
||||||
#define fAllowMouseText 0x8000
|
#define fAllowMouseText 0x8000
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#define resConverter 0x0800
|
#define resConverter 0x0800
|
||||||
#define resMemAttr 0xC31C /* Flags passed to the NewHandle Memory Manager call */
|
#define resMemAttr 0xC31C /* Flags passed to the NewHandle Memory Manager call */
|
||||||
#define systemMap 0x0001
|
#define systemMap 0x0001
|
||||||
|
#define fileReadWrite 0x0001
|
||||||
#define mapChanged 0x0002
|
#define mapChanged 0x0002
|
||||||
#define romMap 0x0004
|
#define romMap 0x0004
|
||||||
#define resNameOffset 0x10000 /* type holding names */
|
#define resNameOffset 0x10000 /* type holding names */
|
||||||
|
|
|
@ -14,6 +14,11 @@
|
||||||
*
|
*
|
||||||
* Thanks to Doug Gwyn for the new va_start & va_arg declarations.
|
* Thanks to Doug Gwyn for the new va_start & va_arg declarations.
|
||||||
*
|
*
|
||||||
|
*****************************************************************
|
||||||
|
*
|
||||||
|
* Modified October 2021 for better standards conformance.
|
||||||
|
* This version will only work with ORCA/C 2.2.0 B6 or later.
|
||||||
|
*
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
#ifndef __stdarg__
|
#ifndef __stdarg__
|
||||||
|
@ -25,12 +30,13 @@ typedef char *__va_list[2];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef __va_list va_list;
|
typedef __va_list va_list;
|
||||||
#define va_end(a) __va_end(a)
|
#define va_end(ap) __record_va_info(ap)
|
||||||
#define va_start(ap,LastFixedParm) ((void) ((ap)[0] = (ap)[1] = (char *) (&LastFixedParm + 1)))
|
#define va_start(ap,LastFixedParm) ((void) ((ap)[0] = (char *)__orcac_va_info[1], (ap)[1] = (char *)&__orcac_va_info))
|
||||||
#define va_arg(ap,type) _Generic(*(type *)0, \
|
#define va_arg(ap,type) _Generic(*(type *)0, \
|
||||||
double: (type)((long double *)((ap)[0] += sizeof(long double)))[-1], \
|
double: (type)((long double *)((ap)[0] += sizeof(long double)))[-1], \
|
||||||
default: ((type *)((ap)[0] += sizeof(type)))[-1])
|
default: ((type *)((ap)[0] += sizeof(type)))[-1])
|
||||||
|
#define va_copy(dest,src) ((void)((dest)[0]=(src)[0],(dest)[1]=(src)[1]))
|
||||||
|
|
||||||
void __va_end(va_list);
|
void __record_va_info(va_list);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -61,7 +61,7 @@ typedef struct __file {
|
||||||
*_end; /* end of the file buffer */
|
*_end; /* end of the file buffer */
|
||||||
unsigned long _size, /* size of the file buffer */
|
unsigned long _size, /* size of the file buffer */
|
||||||
_cnt; /* # chars that can be read/written to buffer */
|
_cnt; /* # chars that can be read/written to buffer */
|
||||||
int _pbk; /* put back buffer */
|
int _pbk[2]; /* put back buffer */
|
||||||
unsigned int _flag, /* buffer flags */
|
unsigned int _flag, /* buffer flags */
|
||||||
_file; /* GS/OS file ID */
|
_file; /* GS/OS file ID */
|
||||||
} FILE;
|
} FILE;
|
||||||
|
@ -80,10 +80,14 @@ typedef struct __file {
|
||||||
#define _IOERR 0x0100 /* has an error occurred? */
|
#define _IOERR 0x0100 /* has an error occurred? */
|
||||||
#define _IOTEXT 0x0200 /* is this file a text file? */
|
#define _IOTEXT 0x0200 /* is this file a text file? */
|
||||||
#define _IOTEMPFILE 0x0400 /* was this file created by tmpfile()? */
|
#define _IOTEMPFILE 0x0400 /* was this file created by tmpfile()? */
|
||||||
|
#define _IOAPPEND 0x0800 /* is this file open in append mode? */
|
||||||
|
|
||||||
extern FILE *stderr; /* standard I/O files */
|
extern FILE *stderr; /* standard I/O files */
|
||||||
extern FILE *stdin;
|
extern FILE *stdin;
|
||||||
extern FILE *stdout;
|
extern FILE *stdout;
|
||||||
|
#define stderr stderr
|
||||||
|
#define stdin stdin
|
||||||
|
#define stdout stdout
|
||||||
|
|
||||||
#define L_tmpnam 26 /* size of a temp name */
|
#define L_tmpnam 26 /* size of a temp name */
|
||||||
#define TMP_MAX 10000 /* # of unique temp names */
|
#define TMP_MAX 10000 /* # of unique temp names */
|
||||||
|
@ -99,16 +103,6 @@ extern FILE *stdout;
|
||||||
|
|
||||||
typedef long fpos_t;
|
typedef long fpos_t;
|
||||||
|
|
||||||
/*
|
|
||||||
* Function declared as a macro
|
|
||||||
*/
|
|
||||||
|
|
||||||
void rewind(FILE *);
|
|
||||||
#define rewind(stream) (__fseek((stream),0L,SEEK_SET))
|
|
||||||
|
|
||||||
/* Private function used in the above macro (not to be used otherwise) */
|
|
||||||
int __fseek(FILE *, long, int);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function declarations
|
* Function declarations
|
||||||
*/
|
*/
|
||||||
|
@ -134,7 +128,9 @@ long int ftell(FILE *);
|
||||||
size_t fwrite(const void *, size_t, size_t, FILE *);
|
size_t fwrite(const void *, size_t, size_t, FILE *);
|
||||||
int getc(FILE *);
|
int getc(FILE *);
|
||||||
int getchar(void);
|
int getchar(void);
|
||||||
|
#if !defined(__KeepNamespacePure__) || __STDC_VERSION__ < 201112L
|
||||||
char *gets(char *);
|
char *gets(char *);
|
||||||
|
#endif
|
||||||
void perror(const char *);
|
void perror(const char *);
|
||||||
int printf(const char *, ...);
|
int printf(const char *, ...);
|
||||||
int putc(int, FILE *);
|
int putc(int, FILE *);
|
||||||
|
@ -142,6 +138,7 @@ int putchar(int);
|
||||||
int puts(const char *);
|
int puts(const char *);
|
||||||
int remove(const char *);
|
int remove(const char *);
|
||||||
int rename(const char *, const char *);
|
int rename(const char *, const char *);
|
||||||
|
void rewind(FILE *);
|
||||||
int scanf(const char *, ...);
|
int scanf(const char *, ...);
|
||||||
void setbuf(FILE *, char *);
|
void setbuf(FILE *, char *);
|
||||||
int setvbuf(FILE *, char *, int, size_t);
|
int setvbuf(FILE *, char *, int, size_t);
|
||||||
|
|
|
@ -66,12 +66,15 @@ long long llabs(long long);
|
||||||
lldiv_t lldiv(long long, long long);
|
lldiv_t lldiv(long long, long long);
|
||||||
#endif
|
#endif
|
||||||
void *malloc(size_t);
|
void *malloc(size_t);
|
||||||
|
int mblen(const char *, size_t);
|
||||||
void qsort(void *, size_t, size_t, int (*__compar)(const void *, const void *));
|
void qsort(void *, size_t, size_t, int (*__compar)(const void *, const void *));
|
||||||
void quick_exit(int);
|
void quick_exit(int);
|
||||||
int rand(void);
|
int rand(void);
|
||||||
void *realloc(void *, size_t);
|
void *realloc(void *, size_t);
|
||||||
void srand(unsigned);
|
void srand(unsigned);
|
||||||
double strtod(const char *, char **);
|
double strtod(const char *, char **);
|
||||||
|
float strtof(const char *, char **);
|
||||||
|
long double strtold(const char *, char **);
|
||||||
long strtol(const char *, char **, int);
|
long strtol(const char *, char **, int);
|
||||||
unsigned long strtoul(const char *, char **, int);
|
unsigned long strtoul(const char *, char **, int);
|
||||||
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
|
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
|
||||||
|
|
|
@ -23,7 +23,7 @@ typedef unsigned long size_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __KeepNamespacePure__
|
#ifndef __KeepNamespacePure__
|
||||||
char *c2pstr(char *);
|
char *c2pstr(const char *);
|
||||||
#endif
|
#endif
|
||||||
void *memchr(const void *, int, size_t);
|
void *memchr(const void *, int, size_t);
|
||||||
int memcmp(const void *, const void *, size_t);
|
int memcmp(const void *, const void *, size_t);
|
||||||
|
@ -31,11 +31,12 @@ void *memcpy(void *, const void *, size_t);
|
||||||
void *memmove(void *, const void *, size_t);
|
void *memmove(void *, const void *, size_t);
|
||||||
void *memset(void *, int, size_t);
|
void *memset(void *, int, size_t);
|
||||||
#ifndef __KeepNamespacePure__
|
#ifndef __KeepNamespacePure__
|
||||||
char *p2cstr(char *);
|
char *p2cstr(const char *);
|
||||||
#endif
|
#endif
|
||||||
char *strcat(char *, const char *);
|
char *strcat(char *, const char *);
|
||||||
char *strchr(const char *, int);
|
char *strchr(const char *, int);
|
||||||
int strcmp(const char *, const char *);
|
int strcmp(const char *, const char *);
|
||||||
|
int strcoll(const char *, const char *);
|
||||||
char *strcpy(char *, const char *);
|
char *strcpy(char *, const char *);
|
||||||
size_t strcspn(const char *, const char *);
|
size_t strcspn(const char *, const char *);
|
||||||
char *strerror(int);
|
char *strerror(int);
|
||||||
|
@ -45,15 +46,17 @@ int strncmp(const char *, const char *, size_t);
|
||||||
char *strncpy(char *, const char *, size_t);
|
char *strncpy(char *, const char *, size_t);
|
||||||
char *strpbrk(const char *, const char *);
|
char *strpbrk(const char *, const char *);
|
||||||
#ifndef __KeepNamespacePure__
|
#ifndef __KeepNamespacePure__
|
||||||
int strpos(char *, char);
|
int strpos(const char *, char);
|
||||||
#endif
|
#endif
|
||||||
char *strrchr(const char *, int);
|
char *strrchr(const char *, int);
|
||||||
#ifndef __KeepNamespacePure__
|
#ifndef __KeepNamespacePure__
|
||||||
char *strrpbrk(char *, char *);
|
char *strrpbrk(const char *, const char *);
|
||||||
int strrpos(char *, char);
|
int strrpos(const char *, char);
|
||||||
#endif
|
#endif
|
||||||
size_t strspn(const char *, const char *);
|
size_t strspn(const char *, const char *);
|
||||||
char *strstr(const char *, const char *);
|
char *strstr(const char *, const char *);
|
||||||
char *strtok(char *, const char *);
|
char *strtok(char *, const char *);
|
||||||
|
size_t strxfrm(char *, const char *, size_t);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
104
ORCACDefs/tgmath.h
Normal file
104
ORCACDefs/tgmath.h
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* tgmath.h - type-generic math macros
|
||||||
|
*
|
||||||
|
* November 2021
|
||||||
|
* Stephen Heumann
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#ifndef __tgmath__
|
||||||
|
#define __tgmath__
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#define __tg_real_x(fn,x) _Generic((x), \
|
||||||
|
float: fn##f, \
|
||||||
|
long double: fn##l, \
|
||||||
|
default: fn)(x)
|
||||||
|
|
||||||
|
#define __tg_real_x_other(fn,x,other) _Generic((x), \
|
||||||
|
float: fn##f, \
|
||||||
|
long double: fn##l, \
|
||||||
|
default: fn)((x),(other))
|
||||||
|
|
||||||
|
#define __tg_real_x_y(fn,x,y) _Generic((x), \
|
||||||
|
float: _Generic((y), float: fn##f, long double: fn##l, default: fn), \
|
||||||
|
long double: fn##l, \
|
||||||
|
default: _Generic((y), long double: fn##l, default: fn))((x),(y))
|
||||||
|
|
||||||
|
#define __tg_real_x_y_other(fn,x,y,other) _Generic((x), \
|
||||||
|
float: _Generic((y), float: fn##f, long double: fn##l, default: fn), \
|
||||||
|
long double: fn##l, \
|
||||||
|
default: _Generic((y), long double: fn##l, default: fn))((x),(y),(other))
|
||||||
|
|
||||||
|
#define __tg_real_x_y_z(fn,x,y,z) _Generic((x), \
|
||||||
|
float: _Generic((y), \
|
||||||
|
float: _Generic((z), float: fn##f, long double: fn##l, default: fn), \
|
||||||
|
long double: fn##l, \
|
||||||
|
default: _Generic((z), long double: fn##l, default: fn)), \
|
||||||
|
long double: fn##l, \
|
||||||
|
default: _Generic((y), \
|
||||||
|
long double: fn##l, \
|
||||||
|
default: _Generic((z), long double: fn##l, default: fn)))((x),(y),(z))
|
||||||
|
|
||||||
|
#define __tg_x(fn,x) __tg_real_x(fn,(x))
|
||||||
|
#define __tg_x_y(fn,x,y) __tg_real_x_y(fn,(x),(y))
|
||||||
|
|
||||||
|
#define acos(x) __tg_x(acos,(x))
|
||||||
|
#define acosh(x) __tg_x(acosh,(x))
|
||||||
|
#define asin(x) __tg_x(asin,(x))
|
||||||
|
#define asinh(x) __tg_x(asinh,(x))
|
||||||
|
#define atan(x) __tg_x(atan,(x))
|
||||||
|
#define atanh(x) __tg_x(atanh,(x))
|
||||||
|
#define atan2(y,x) __tg_real_x_y(atan2,(y),(x))
|
||||||
|
#define cbrt(x) __tg_real_x(cbrt,(x))
|
||||||
|
#define ceil(x) __tg_real_x(ceil,(x))
|
||||||
|
#define cos(x) __tg_x(cos,(x))
|
||||||
|
#define cosh(x) __tg_x(cosh,(x))
|
||||||
|
#define copysign(x,y) __tg_real_x_y(copysign,(x),(y))
|
||||||
|
#define erf(x) __tg_real_x(erf,(x))
|
||||||
|
#define erfc(x) __tg_real_x(erfc,(x))
|
||||||
|
#define exp(x) __tg_x(exp,(x))
|
||||||
|
#define exp2(x) __tg_real_x(exp2,(x))
|
||||||
|
#define expm1(x) __tg_real_x(expm1,(x))
|
||||||
|
#define fabs(x) __tg_real_x(fabs,(x))
|
||||||
|
#define fdim(x,y) __tg_real_x_y(fdim,(x),(y))
|
||||||
|
#define fma(x,y,z) __tg_real_x_y_z(fma,(x),(y),(z))
|
||||||
|
#define fmax(x,y) __tg_real_x_y(fmax,(x),(y))
|
||||||
|
#define fmin(x,y) __tg_real_x_y(fmin,(x),(y))
|
||||||
|
#define floor(x) __tg_real_x(floor,(x))
|
||||||
|
#define fmod(x,y) __tg_real_x_y(fmod,(x),(y))
|
||||||
|
#define frexp(x,nptr) __tg_real_x_other(frexp,(x),(nptr))
|
||||||
|
#define hypot(x,y) __tg_real_x_y(hypot,(x),(y))
|
||||||
|
#define ilogb(x) __tg_real_x(ilogb,(x))
|
||||||
|
#define ldexp(x,n) __tg_real_x_other(ldexp,(x),(n))
|
||||||
|
#define lgamma(x) __tg_real_x(lgamma,(x))
|
||||||
|
#define llrint(x) __tg_real_x(llrint,(x))
|
||||||
|
#define llround(x) __tg_real_x(llround,(x))
|
||||||
|
#define log(x) __tg_x(log,(x))
|
||||||
|
#define log10(x) __tg_real_x(log10,(x))
|
||||||
|
#define log1p(x) __tg_real_x(log1p,(x))
|
||||||
|
#define log2(x) __tg_real_x(log2,(x))
|
||||||
|
#define logb(x) __tg_real_x(logb,(x))
|
||||||
|
#define lrint(x) __tg_real_x(lrint,(x))
|
||||||
|
#define lround(x) __tg_real_x(lround,(x))
|
||||||
|
#define nearbyint(x) __tg_real_x(nearbyint,(x))
|
||||||
|
#define nextafter(x,y) __tg_real_x_y(nextafter,(x),(y))
|
||||||
|
#define nexttoward(x,y) __tg_real_x_y(nexttoward,(x),(y))
|
||||||
|
#define pow(x,y) __tg_x_y(pow,(x),(y))
|
||||||
|
#define remainder(x,y) __tg_real_x_y(remainder,(x),(y))
|
||||||
|
#define remquo(x,y,quo) __tg_real_x_y_other(remquo,(x),(y),(quo))
|
||||||
|
#define rint(x) __tg_real_x(rint,(x))
|
||||||
|
#define round(x) __tg_real_x(round,(x))
|
||||||
|
#define scalbn(x,n) __tg_real_x_other(scalbn,(x),(n))
|
||||||
|
#define scalbln(x,n) __tg_real_x_other(scalbln,(x),(n))
|
||||||
|
#define sin(x) __tg_x(sin,(x))
|
||||||
|
#define sinh(x) __tg_x(sinh,(x))
|
||||||
|
#define sqrt(x) __tg_x(sqrt,(x))
|
||||||
|
#define tan(x) __tg_x(tan,(x))
|
||||||
|
#define tanh(x) __tg_x(tanh,(x))
|
||||||
|
#define tgamma(x) __tg_real_x(tgamma,(x))
|
||||||
|
#define trunc(x) __tg_real_x(trunc,(x))
|
||||||
|
|
||||||
|
#endif
|
|
@ -28,12 +28,22 @@ struct tm {
|
||||||
int tm_isdst;
|
int tm_isdst;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef __struct_timespec__
|
||||||
|
#define __struct_timespec__
|
||||||
|
struct timespec {
|
||||||
|
time_t tv_sec;
|
||||||
|
long tv_nsec;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
clock_t __clocks_per_sec(void);
|
clock_t __clocks_per_sec(void);
|
||||||
#ifndef __KeepNamespacePure__
|
#ifndef __KeepNamespacePure__
|
||||||
#define CLK_TCK (__clocks_per_sec())
|
#define CLK_TCK (__clocks_per_sec())
|
||||||
#endif
|
#endif
|
||||||
#define CLOCKS_PER_SEC (__clocks_per_sec())
|
#define CLOCKS_PER_SEC (__clocks_per_sec())
|
||||||
|
|
||||||
|
#define TIME_UTC 1
|
||||||
|
|
||||||
#ifndef NULL
|
#ifndef NULL
|
||||||
#define NULL (void *) 0L
|
#define NULL (void *) 0L
|
||||||
#endif
|
#endif
|
||||||
|
@ -43,6 +53,8 @@ clock_t __clocks_per_sec(void);
|
||||||
typedef unsigned long size_t;
|
typedef unsigned long size_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern int __useTimeTool;
|
||||||
|
|
||||||
char *asctime(const struct tm *);
|
char *asctime(const struct tm *);
|
||||||
clock_t clock(void);
|
clock_t clock(void);
|
||||||
char *ctime(const time_t *);
|
char *ctime(const time_t *);
|
||||||
|
@ -50,6 +62,8 @@ double difftime(time_t, time_t);
|
||||||
struct tm *gmtime(const time_t *);
|
struct tm *gmtime(const time_t *);
|
||||||
struct tm *localtime(const time_t *);
|
struct tm *localtime(const time_t *);
|
||||||
time_t mktime(struct tm *);
|
time_t mktime(struct tm *);
|
||||||
|
size_t strftime(char *, size_t, const char *, const struct tm *);
|
||||||
time_t time(time_t *);
|
time_t time(time_t *);
|
||||||
|
int timespec_get(struct timespec *, int);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
28
ORCACDefs/uchar.h
Normal file
28
ORCACDefs/uchar.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* uchar.h - Unicode utilities
|
||||||
|
*
|
||||||
|
* October 2021
|
||||||
|
* Stephen Heumann
|
||||||
|
*
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#ifndef __uchar__
|
||||||
|
#define __uchar__
|
||||||
|
|
||||||
|
typedef unsigned long mbstate_t;
|
||||||
|
|
||||||
|
#ifndef __size_t__
|
||||||
|
#define __size_t__ 1
|
||||||
|
typedef unsigned long size_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef unsigned short char16_t;
|
||||||
|
typedef unsigned long char32_t;
|
||||||
|
|
||||||
|
size_t c16rtomb(char *, char16_t, mbstate_t *);
|
||||||
|
size_t c32rtomb(char *, char32_t, mbstate_t *);
|
||||||
|
size_t mbrtoc16(char16_t *, const char *, size_t, mbstate_t *);
|
||||||
|
size_t mbrtoc32(char32_t *, const char *, size_t, mbstate_t *);
|
||||||
|
|
||||||
|
#endif
|
|
@ -66,6 +66,7 @@
|
||||||
#define tmControlMenu 0x00040000L
|
#define tmControlMenu 0x00040000L
|
||||||
#define tmMultiClick 0x00080000L
|
#define tmMultiClick 0x00080000L
|
||||||
#define tmIdleEvents 0x00100000L
|
#define tmIdleEvents 0x00100000L
|
||||||
|
#define tmNoGetNextEvent 0x00200000L
|
||||||
|
|
||||||
/* TaskMaster Codes */
|
/* TaskMaster Codes */
|
||||||
#define wNoHit 0x0000 /* retained for back compatibility */
|
#define wNoHit 0x0000 /* retained for back compatibility */
|
||||||
|
|
50
ObjOut.asm
50
ObjOut.asm
|
@ -144,23 +144,18 @@ Out start CodeGen
|
||||||
*
|
*
|
||||||
OutByte private CodeGen
|
OutByte private CodeGen
|
||||||
|
|
||||||
lda objLen if objLen+segDisp = buffSize then
|
lda objLen if objLen+segDisp >= buffSize then
|
||||||
clc
|
clc
|
||||||
adc segDisp
|
adc segDisp
|
||||||
lda objLen+2
|
lda objLen+2
|
||||||
adc segDisp+2
|
adc segDisp+2
|
||||||
and #$FFFE
|
|
||||||
beq lb2
|
beq lb2
|
||||||
phx PurgeObjBuffer;
|
and minusBuffSize+2
|
||||||
jsl PurgeObjBuffer
|
beq lb2
|
||||||
|
phx MakeSpaceInObjBuffer;
|
||||||
|
jsl MakeSpaceInObjBuffer
|
||||||
plx
|
plx
|
||||||
lda objLen check for segment overflow
|
|
||||||
clc
|
clc
|
||||||
adc segDisp
|
|
||||||
lda objLen+2
|
|
||||||
adc segDisp+2
|
|
||||||
and #$FFFE
|
|
||||||
bne lb2a
|
|
||||||
lb2 anop carry must be clear
|
lb2 anop carry must be clear
|
||||||
lda objPtr+2 p := pointer(ord4(objPtr)+segDisp);
|
lda objPtr+2 p := pointer(ord4(objPtr)+segDisp);
|
||||||
adc segDisp+2
|
adc segDisp+2
|
||||||
|
@ -183,13 +178,6 @@ lb2 anop carry must be clear
|
||||||
adc #4
|
adc #4
|
||||||
tcs
|
tcs
|
||||||
rts
|
rts
|
||||||
|
|
||||||
lb2a lda #$8000 handle a segment overflow
|
|
||||||
sta segDisp
|
|
||||||
stz segDisp+2
|
|
||||||
ph2 #112
|
|
||||||
jsl Error
|
|
||||||
rts
|
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
@ -203,25 +191,20 @@ lb2a lda #$8000 handle a segment overflow
|
||||||
*
|
*
|
||||||
OutWord private CodeGen
|
OutWord private CodeGen
|
||||||
|
|
||||||
lda objLen if objLen+segDisp+1 = buffSize then
|
lda objLen if objLen+segDisp+1 >= buffSize then
|
||||||
sec
|
sec
|
||||||
adc segDisp
|
adc segDisp
|
||||||
lda objLen+2
|
lda objLen+2
|
||||||
adc segDisp+2
|
adc segDisp+2
|
||||||
and #$FFFE
|
|
||||||
beq lb2
|
beq lb2
|
||||||
phx PurgeObjBuffer;
|
and minusBuffSize+2
|
||||||
jsl PurgeObjBuffer
|
beq lb2
|
||||||
|
phx MakeSpaceInObjBuffer;
|
||||||
|
jsl MakeSpaceInObjBuffer
|
||||||
plx
|
plx
|
||||||
lda objLen check for segment overflow
|
clc
|
||||||
sec
|
lb2 anop carry must be clear
|
||||||
adc segDisp
|
lda objPtr+2 p := pointer(ord4(objPtr)+segDisp);
|
||||||
lda objLen+2
|
|
||||||
adc segDisp+2
|
|
||||||
and #$FFFE
|
|
||||||
bne lb3
|
|
||||||
lb2 anop carry must be clear
|
|
||||||
lda objPtr+2 p := pointer(ord4(objPtr)+segDisp);
|
|
||||||
adc segDisp+2
|
adc segDisp+2
|
||||||
pha
|
pha
|
||||||
lda objPtr
|
lda objPtr
|
||||||
|
@ -240,11 +223,4 @@ lb2 anop carry must be clear
|
||||||
adc #4
|
adc #4
|
||||||
tcs
|
tcs
|
||||||
rts
|
rts
|
||||||
|
|
||||||
lb3 ph2 #112 flag segment overflow error
|
|
||||||
jsl Error
|
|
||||||
lda #$8000
|
|
||||||
sta segDisp
|
|
||||||
stz segDisp+2
|
|
||||||
rts
|
|
||||||
end
|
end
|
||||||
|
|
53
ObjOut.pas
53
ObjOut.pas
|
@ -138,9 +138,8 @@ procedure Purge;
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
const
|
const
|
||||||
{NOTE: OutByte and Outword assume }
|
initialBuffSize = $10000; {initial size of the obj buffer}
|
||||||
{ buffSize is 128K }
|
{NOTE: must be a power of two >= 64K}
|
||||||
buffSize = 131072; {size of the obj buffer}
|
|
||||||
maxCBuffLen = 191; {length of the constant buffer}
|
maxCBuffLen = 191; {length of the constant buffer}
|
||||||
OBJ = $B1; {object file type}
|
OBJ = $B1; {object file type}
|
||||||
|
|
||||||
|
@ -217,9 +216,9 @@ var
|
||||||
|
|
||||||
objLen: longint; {# bytes used in obj buffer}
|
objLen: longint; {# bytes used in obj buffer}
|
||||||
objHandle: handle; {handle of the obj buffer}
|
objHandle: handle; {handle of the obj buffer}
|
||||||
objPtr: ptr; {pointer to the next spot in the obj buffer}
|
objPtr: ptr; {points to first byte in current segment}
|
||||||
|
minusBuffSize: longint; {size of obj buffer, negated}
|
||||||
|
|
||||||
segStart: ptr; {points to first byte in current segment}
|
|
||||||
spoolRefnum: integer; {reference number for open file}
|
spoolRefnum: integer; {reference number for open file}
|
||||||
|
|
||||||
{---------------------------------------------------------------}
|
{---------------------------------------------------------------}
|
||||||
|
@ -276,7 +275,7 @@ var
|
||||||
|
|
||||||
begin {InitSpoolFile}
|
begin {InitSpoolFile}
|
||||||
if memoryCompile then {make sure this is a disk-based compile}
|
if memoryCompile then {make sure this is a disk-based compile}
|
||||||
TermError(11);
|
TermError(3);
|
||||||
dsRec.pCount := 1; {destroy any old file}
|
dsRec.pCount := 1; {destroy any old file}
|
||||||
dsRec.pathname := @objFile.theString;
|
dsRec.pathname := @objFile.theString;
|
||||||
DestroyGS(dsRec);
|
DestroyGS(dsRec);
|
||||||
|
@ -303,7 +302,7 @@ begin {PurgeObjBuffer}
|
||||||
if spoolRefnum = 0 then {make sure the spool file exists}
|
if spoolRefnum = 0 then {make sure the spool file exists}
|
||||||
InitSpoolFile;
|
InitSpoolFile;
|
||||||
sPtr := objHandle^; {determine size of completed segments}
|
sPtr := objHandle^; {determine size of completed segments}
|
||||||
len := ord4(segStart) - ord4(sPtr);
|
len := ord4(objPtr) - ord4(sPtr);
|
||||||
if len <> 0 then begin
|
if len <> 0 then begin
|
||||||
wrRec.pcount := 4; {write completed segments}
|
wrRec.pcount := 4; {write completed segments}
|
||||||
wrRec.refnum := spoolRefnum;
|
wrRec.refnum := spoolRefnum;
|
||||||
|
@ -313,13 +312,38 @@ if len <> 0 then begin
|
||||||
if ToolError <> 0 then {check for write errors}
|
if ToolError <> 0 then {check for write errors}
|
||||||
TermError(9);
|
TermError(9);
|
||||||
objLen := 0; {adjust file pointers}
|
objLen := 0; {adjust file pointers}
|
||||||
BlockMove(segStart, sPtr, segDisp);
|
BlockMove(objPtr, sPtr, segDisp);
|
||||||
objPtr := sPtr;
|
objPtr := sPtr;
|
||||||
segStart := sPtr;
|
|
||||||
end; {if}
|
end; {if}
|
||||||
end; {PurgeObjBuffer}
|
end; {PurgeObjBuffer}
|
||||||
|
|
||||||
|
|
||||||
|
procedure MakeSpaceInObjBuffer;
|
||||||
|
|
||||||
|
{ Make space in the object buffer (at least two bytes) by }
|
||||||
|
{ purging or expanding it. }
|
||||||
|
|
||||||
|
var
|
||||||
|
segOffset: longint; {offset into buffer of current segment}
|
||||||
|
|
||||||
|
begin {MakeSpaceInObjBuffer}
|
||||||
|
segOffset := ord4(objPtr) - ord4(objHandle^);
|
||||||
|
|
||||||
|
if (segOffset >= 2) and not memoryCompile then
|
||||||
|
PurgeObjBuffer
|
||||||
|
else begin
|
||||||
|
{resize the buffer}
|
||||||
|
minusBuffSize := minusBuffSize * 2;
|
||||||
|
HUnLock(objHandle);
|
||||||
|
SetHandleSize(-minusBuffSize, objHandle);
|
||||||
|
if ToolError <> 0 then
|
||||||
|
TermError(5);
|
||||||
|
HLock(objHandle);
|
||||||
|
objPtr := ptr(ord4(objHandle^) + segOffset);
|
||||||
|
end; {if}
|
||||||
|
end; {MakeSpaceInObjBuffer}
|
||||||
|
|
||||||
|
|
||||||
{---------------------------------------------------------------}
|
{---------------------------------------------------------------}
|
||||||
|
|
||||||
procedure CloseObj;
|
procedure CloseObj;
|
||||||
|
@ -439,10 +463,9 @@ longPtr := pointer(objPtr); {set the block count}
|
||||||
longPtr^ := segDisp;
|
longPtr^ := segDisp;
|
||||||
objLen := objLen + segDisp; {update the length of the obj file}
|
objLen := objLen + segDisp; {update the length of the obj file}
|
||||||
objPtr := pointer(ord4(objHandle^)+objLen); {set objPtr}
|
objPtr := pointer(ord4(objHandle^)+objLen); {set objPtr}
|
||||||
segStart := objPtr;
|
segDisp := 0;
|
||||||
if objLen = buffSize then
|
currentSegment := defaultSegment; {revert to default segment name & kind}
|
||||||
PurgeObjBuffer;
|
segmentKind := defaultSegmentKind;
|
||||||
currentSegment := defaultSegment; {revert to default segment name}
|
|
||||||
end; {CloseSeg}
|
end; {CloseSeg}
|
||||||
|
|
||||||
|
|
||||||
|
@ -526,7 +549,6 @@ procedure OpenSeg;
|
||||||
|
|
||||||
begin {OpenSeg}
|
begin {OpenSeg}
|
||||||
segDisp := 0;
|
segDisp := 0;
|
||||||
segStart := objPtr;
|
|
||||||
end; {OpenSeg}
|
end; {OpenSeg}
|
||||||
|
|
||||||
|
|
||||||
|
@ -559,12 +581,13 @@ if memoryCompile then begin
|
||||||
end; {if}
|
end; {if}
|
||||||
|
|
||||||
{allocate memory for an initial buffer}
|
{allocate memory for an initial buffer}
|
||||||
objHandle := pointer(NewHandle(buffSize, userID, $8000, nil));
|
objHandle := pointer(NewHandle(initialBuffSize, userID, $8000, nil));
|
||||||
|
|
||||||
{set up the buffer variables}
|
{set up the buffer variables}
|
||||||
if ToolError = 0 then begin
|
if ToolError = 0 then begin
|
||||||
objLen := 0;
|
objLen := 0;
|
||||||
objPtr := objHandle^;
|
objPtr := objHandle^;
|
||||||
|
minusBuffSize := -initialBuffSize;
|
||||||
end {if}
|
end {if}
|
||||||
else
|
else
|
||||||
TermError(5);
|
TermError(5);
|
||||||
|
|
2415
Parser.pas
2415
Parser.pas
File diff suppressed because it is too large
Load Diff
14
Printf.pas
14
Printf.pas
|
@ -52,7 +52,7 @@ const
|
||||||
feature_ll = true;
|
feature_ll = true;
|
||||||
feature_s_long = false;
|
feature_s_long = false;
|
||||||
feature_n_size = true;
|
feature_n_size = true;
|
||||||
feature_scanf_ld = false;
|
feature_scanf_ld = true;
|
||||||
|
|
||||||
type
|
type
|
||||||
length_modifier = (default, h, hh, l, ll, j, z, t, ld);
|
length_modifier = (default, h, hh, l, ll, j, z, t, ld);
|
||||||
|
@ -136,7 +136,7 @@ var
|
||||||
WriteLine;
|
WriteLine;
|
||||||
if s <> nil then begin
|
if s <> nil then begin
|
||||||
Write(' > "');
|
Write(' > "');
|
||||||
for i := 1 to s^.length do begin
|
for i := 1 to s^.length-1 do begin
|
||||||
ch := s^.str[i];
|
ch := s^.str[i];
|
||||||
if ch in [' '..'~'] then begin
|
if ch in [' '..'~'] then begin
|
||||||
if ch in ['"','\','?'] then
|
if ch in ['"','\','?'] then
|
||||||
|
@ -167,13 +167,13 @@ var
|
||||||
Write(' ');
|
Write(' ');
|
||||||
if offset = 0 then
|
if offset = 0 then
|
||||||
if s <> nil then begin
|
if s <> nil then begin
|
||||||
offset := s^.length;
|
offset := s^.length-1;
|
||||||
write(' ');
|
write(' ');
|
||||||
end; {if}
|
end; {if}
|
||||||
if offset > 0 then begin
|
if s <> nil then begin
|
||||||
if s <> nil then begin
|
if offset > 0 then begin
|
||||||
if offset > s^.length then
|
if offset > s^.length-1 then
|
||||||
offset := s^.length;
|
offset := s^.length-1;
|
||||||
for i := 1 to offset do begin
|
for i := 1 to offset do begin
|
||||||
ch := s^.str[i];
|
ch := s^.str[i];
|
||||||
if ch in [' '..'~'] then begin
|
if ch in [' '..'~'] then begin
|
||||||
|
|
|
@ -49,4 +49,4 @@ Alternatively, you can keep the LF line endings in your working copy of the Git
|
||||||
|
|
||||||
[udl]: http://ftp.gno.org/pub/apple2/gs.specific/gno/file.convert/udl.114.shk
|
[udl]: http://ftp.gno.org/pub/apple2/gs.specific/gno/file.convert/udl.114.shk
|
||||||
|
|
||||||
In addition to converting the line endings, you will also have to set the files to the appropriate file types before building ORCA/C on a IIGS. The included `settypes` script (for use under the ORCA shell) does this for the sources to the ORCA/C compiler itself, although it does not currently cover the test cases and headers.
|
In addition to converting the line endings, you will also have to set the files to the appropriate file types before building ORCA/C on a IIGS. The included `settypes` script (for use under the ORCA shell) can be used to do this.
|
||||||
|
|
439
Scanner.asm
439
Scanner.asm
|
@ -1,5 +1,305 @@
|
||||||
mcopy scanner.macros
|
mcopy scanner.macros
|
||||||
datachk off
|
datachk off
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
* ConvertHexFloat - Parse a hexadecimal floating-point constant
|
||||||
|
*
|
||||||
|
* Inputs:
|
||||||
|
* str - pointer to the string (p-string)
|
||||||
|
*
|
||||||
|
* Outputs:
|
||||||
|
* Returns the extended value (or a NAN on error).
|
||||||
|
*
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
ConvertHexFloat start scanner
|
||||||
|
|
||||||
|
subroutine (4:str),26
|
||||||
|
end_idx equ 0 index one past end of string
|
||||||
|
got_period equ end_idx+2 flag: have we encountered a period?
|
||||||
|
full equ got_period+2 flag: is mantissa full?
|
||||||
|
mantissa equ full+2 mantissa
|
||||||
|
extrabits equ mantissa+8 extra bits that do not fit in mantissa
|
||||||
|
exp_adjust equ extrabits+2 exponent adjustment
|
||||||
|
negate_exp equ exp_adjust+2 flag: is exponent negative?
|
||||||
|
exp equ negate_exp+2 exponent
|
||||||
|
nonzero equ exp+2 flag: is mantissa non-zero?
|
||||||
|
got_digit equ nonzero+2 flag: got any digit yet?
|
||||||
|
|
||||||
|
stz got_period no period yet
|
||||||
|
stz full not full yet
|
||||||
|
stz negate_exp assume positive exponent
|
||||||
|
stz got_digit no digit yet
|
||||||
|
stz exp exponent value = 0
|
||||||
|
stz mantissa mantissa = 0.0
|
||||||
|
stz mantissa+2
|
||||||
|
stz mantissa+4
|
||||||
|
stz mantissa+6
|
||||||
|
stz extrabits extrabits = 0
|
||||||
|
lda #63 exponent adjustment = 63
|
||||||
|
sta exp_adjust
|
||||||
|
|
||||||
|
lda [str] end_idx = string length + 1
|
||||||
|
and #$00FF
|
||||||
|
inc a
|
||||||
|
sta end_idx
|
||||||
|
ldy #1 string index = 1
|
||||||
|
|
||||||
|
jsr nextch check for 0x or 0X prefix
|
||||||
|
cmp #'0'
|
||||||
|
beq check_x
|
||||||
|
brl error
|
||||||
|
check_x jsr nextch
|
||||||
|
and #$df
|
||||||
|
cmp #'X'
|
||||||
|
beq digitlp
|
||||||
|
brl error
|
||||||
|
|
||||||
|
digitlp jsr nextch get a character
|
||||||
|
ldx got_period if there was no period yet
|
||||||
|
bne check_p
|
||||||
|
cmp #'.' if character is '.'
|
||||||
|
bne check_p
|
||||||
|
dec got_period flag that we got a period
|
||||||
|
bra digitlp loop for another digit
|
||||||
|
check_p cmp #'p' if character is 'p' or 'P'
|
||||||
|
beq normal mantissa is done: normalize it
|
||||||
|
cmp #'P'
|
||||||
|
beq normal
|
||||||
|
sta got_digit flag that we (presumably) got a digit
|
||||||
|
jsr hexdigit must be a hex digit: get value
|
||||||
|
ldx full if mantissa is full
|
||||||
|
beq donibble
|
||||||
|
ora extrabits record extra bits for rounding
|
||||||
|
sta extrabits
|
||||||
|
lda got_period if we are not past the period
|
||||||
|
bne digitlp
|
||||||
|
lda #4 exp_adjust += 4
|
||||||
|
clc
|
||||||
|
adc exp_adjust
|
||||||
|
; bvs error no overflow with p-string input
|
||||||
|
sta exp_adjust
|
||||||
|
bra digitlp loop for another digit
|
||||||
|
|
||||||
|
donibble xba get nibble value in high bits
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
ldx #4 for each bit in nibble:
|
||||||
|
bitloop bit mantissa+6 if mantissa is now full
|
||||||
|
bpl notfull
|
||||||
|
inc full full = true
|
||||||
|
sta extrabits record next bit(s) for rounding
|
||||||
|
lda got_period if we are not past the period
|
||||||
|
bne digitlp
|
||||||
|
txa exp_adjust += number of extra bits
|
||||||
|
clc
|
||||||
|
adc exp_adjust
|
||||||
|
sta exp_adjust
|
||||||
|
bra digitlp loop for another digit
|
||||||
|
notfull asl a shift bit into mantissa
|
||||||
|
rol mantissa
|
||||||
|
rol mantissa+2
|
||||||
|
rol mantissa+4
|
||||||
|
rol mantissa+6
|
||||||
|
bit got_period if we are past the period
|
||||||
|
bpl nextbit
|
||||||
|
dec exp_adjust exp_adjust-- (no overflow w/ p-str)
|
||||||
|
nextbit dex
|
||||||
|
bne bitloop
|
||||||
|
bra digitlp
|
||||||
|
|
||||||
|
normal lda got_digit check that there was a mantissa digit
|
||||||
|
bne chkzero
|
||||||
|
brl error
|
||||||
|
chkzero lda mantissa check if mantissa is nonzero
|
||||||
|
ora mantissa+2
|
||||||
|
ora mantissa+4
|
||||||
|
ora mantissa+6
|
||||||
|
sta nonzero set nonzero flag as appropriate
|
||||||
|
beq do_exp if mantissa is nonzero, normalize:
|
||||||
|
lda mantissa+6 if high bit of mantissa is not 1:
|
||||||
|
bmi do_exp do
|
||||||
|
normallp dec exp_adjust exp_adjust--
|
||||||
|
asl mantissa shift mantissa left one bit
|
||||||
|
rol mantissa+2
|
||||||
|
rol mantissa+4
|
||||||
|
rol mantissa+6
|
||||||
|
bpl normallp while high bit of mantissa is not 1
|
||||||
|
|
||||||
|
do_exp jsr nextch get next character
|
||||||
|
cmp #'+' if it is '+'
|
||||||
|
bne chkminus
|
||||||
|
jsr nextch ignore it and get next char
|
||||||
|
bra exploop
|
||||||
|
chkminus cmp #'-' else if it is '-'
|
||||||
|
bne exploop
|
||||||
|
jsr nextch get next character
|
||||||
|
inc negate_exp flag that exponent is negative
|
||||||
|
exploop jsr decdigit for each exponent digit
|
||||||
|
asl exp exp = exp*10 + digit
|
||||||
|
pei exp
|
||||||
|
bcs bigexp
|
||||||
|
bmi bigexp
|
||||||
|
asl exp
|
||||||
|
asl exp
|
||||||
|
bcs bigexp
|
||||||
|
bmi bigexp
|
||||||
|
adc 1,s
|
||||||
|
bvs bigexp
|
||||||
|
clc
|
||||||
|
adc exp
|
||||||
|
bvs bigexp
|
||||||
|
sta exp
|
||||||
|
pla
|
||||||
|
jsr nextch
|
||||||
|
bpl exploop
|
||||||
|
bra neg_exp
|
||||||
|
bigexp pla
|
||||||
|
lda #$7fff if exponent value overflows
|
||||||
|
sta exp exp = INT_MAX
|
||||||
|
bigexplp jsr nextch
|
||||||
|
bpl bigexplp
|
||||||
|
neg_exp lda negate_exp if exponent is negative
|
||||||
|
beq finalexp
|
||||||
|
lda exp negate exp
|
||||||
|
eor #$ffff
|
||||||
|
inc a
|
||||||
|
sta exp
|
||||||
|
finalexp lda exp add in exponent adjustment
|
||||||
|
clc
|
||||||
|
adc exp_adjust
|
||||||
|
bvc expdone if addition overflows
|
||||||
|
lda #$7fff positive exponent -> INT_MAX
|
||||||
|
ldx negate_exp
|
||||||
|
beq expdone
|
||||||
|
inc a negative exponent -> INT_MIN
|
||||||
|
expdone ldx nonzero if value is zero
|
||||||
|
bne bias
|
||||||
|
txa exponent field = 0
|
||||||
|
bra storeexp
|
||||||
|
|
||||||
|
bias clc else
|
||||||
|
adc #16383 compute biased exp. [-16385..49150]
|
||||||
|
storeexp sta exp
|
||||||
|
cmp #32767 if it is [0..32766], it is valid
|
||||||
|
blt round
|
||||||
|
cmp #32767+16383+1 if it is larger, generate an infinity
|
||||||
|
blt inf otherwise, denormalize:
|
||||||
|
denormlp lsr mantissa+6 while biased exponent is negative:
|
||||||
|
ror mantissa+4 shift mantissa left one bit
|
||||||
|
ror mantissa+2
|
||||||
|
ror mantissa
|
||||||
|
ror extrabits adjust extrabits
|
||||||
|
bcc dn_next
|
||||||
|
lda extrabits
|
||||||
|
ora #1
|
||||||
|
sta extrabits
|
||||||
|
dn_next inc exp exp++
|
||||||
|
bmi denormlp
|
||||||
|
|
||||||
|
round lda extrabits implement SANE/IEEE round-to-nearest:
|
||||||
|
cmp #$8000 if less than halfway to next number
|
||||||
|
blt done return value as-is
|
||||||
|
bne roundup if more than halfway to next: round up
|
||||||
|
lda mantissa if exactly halfway to next number
|
||||||
|
lsr a if least significant bit is 0
|
||||||
|
bcc done return value as-is
|
||||||
|
roundup inc mantissa otherwise, round up to next number:
|
||||||
|
bne done increment mantissa
|
||||||
|
inc mantissa+2
|
||||||
|
bne done
|
||||||
|
inc mantissa+4
|
||||||
|
bne done
|
||||||
|
inc mantissa+6
|
||||||
|
bne done
|
||||||
|
lda #$8000 if mantissa overflowed:
|
||||||
|
sta mantissa+6 mantissa = 1.0
|
||||||
|
inc exp exp++ (could generate an infinity)
|
||||||
|
|
||||||
|
done jsr nextch if we have not consumed the full input
|
||||||
|
bpl error flag an error
|
||||||
|
lda mantissa done: store return value
|
||||||
|
sta >retval
|
||||||
|
lda mantissa+2
|
||||||
|
sta >retval+2
|
||||||
|
lda mantissa+4
|
||||||
|
sta >retval+4
|
||||||
|
lda mantissa+6
|
||||||
|
sta >retval+6
|
||||||
|
lda exp
|
||||||
|
sta >retval+8
|
||||||
|
bra ret
|
||||||
|
|
||||||
|
inf lda #32767 infinity: exponent field = 32767
|
||||||
|
sta >retval+8 mantissa = 1.0
|
||||||
|
inc a
|
||||||
|
sta >retval+6
|
||||||
|
asl a
|
||||||
|
sta >retval+4
|
||||||
|
sta >retval+2
|
||||||
|
sta >retval+0
|
||||||
|
bra ret
|
||||||
|
|
||||||
|
error lda #32767 bad input: return NANASCBIN
|
||||||
|
sta >retval+8
|
||||||
|
lda #$C011
|
||||||
|
sta >retval+6
|
||||||
|
lda #0
|
||||||
|
sta >retval+4
|
||||||
|
sta >retval+2
|
||||||
|
sta >retval
|
||||||
|
|
||||||
|
ret lda #retval
|
||||||
|
sta str
|
||||||
|
lda #^retval
|
||||||
|
sta str+2
|
||||||
|
|
||||||
|
return 4:str
|
||||||
|
|
||||||
|
;get next character of string, or -1 if none (nz flags also set based on value)
|
||||||
|
nextch cpy end_idx
|
||||||
|
bge no_ch
|
||||||
|
lda [str],y
|
||||||
|
iny
|
||||||
|
and #$00FF
|
||||||
|
rts
|
||||||
|
no_ch lda #-1
|
||||||
|
rts
|
||||||
|
|
||||||
|
;get value of A, taken as a hex digit
|
||||||
|
;branches to error if it is not a valid digit
|
||||||
|
hexdigit cmp #'0'
|
||||||
|
blt baddigit
|
||||||
|
cmp #'9'+1
|
||||||
|
bge letter
|
||||||
|
and #$000F
|
||||||
|
rts
|
||||||
|
letter and #$df
|
||||||
|
cmp #'A'
|
||||||
|
blt baddigit
|
||||||
|
cmp #'F'+1
|
||||||
|
bge baddigit
|
||||||
|
and #$000F
|
||||||
|
adc #9
|
||||||
|
rts
|
||||||
|
|
||||||
|
;get value of A, taken as a decimal digit
|
||||||
|
;branches to error if it is not a valid digit
|
||||||
|
decdigit cmp #'0'
|
||||||
|
blt baddigit
|
||||||
|
cmp #'9'+1
|
||||||
|
bge baddigit
|
||||||
|
and #$000F
|
||||||
|
rts
|
||||||
|
baddigit pla
|
||||||
|
brl error
|
||||||
|
|
||||||
|
retval ds 10
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
* Convertsl - Convert a string to a long integer
|
* Convertsl - Convert a string to a long integer
|
||||||
|
@ -112,16 +412,16 @@ lb2 inc disp next character
|
||||||
*
|
*
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
KeyPress start
|
KeyPress start scanner
|
||||||
|
|
||||||
KeyPressGS kpRec
|
KeyPressGS kpRec
|
||||||
lda kpAvailable
|
lda >kpAvailable
|
||||||
beq rts
|
beq rts
|
||||||
ReadKeyGS rkRec
|
ReadKeyGS rkRec
|
||||||
lda rkKey
|
lda >rkKey
|
||||||
cmp #'.'
|
cmp #'.'
|
||||||
bne lb1
|
bne lb1
|
||||||
lda rkModifiers
|
lda >rkModifiers
|
||||||
and #$0100
|
and #$0100
|
||||||
beq lb1
|
beq lb1
|
||||||
ph2 #4
|
ph2 #4
|
||||||
|
@ -146,6 +446,7 @@ rkModifiers ds 2
|
||||||
*
|
*
|
||||||
* Outputs:
|
* Outputs:
|
||||||
* ch - character read
|
* ch - character read
|
||||||
|
* currentChPtr - pointer to ch in source file
|
||||||
*
|
*
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
|
@ -164,8 +465,9 @@ cch equ 13
|
||||||
enum (illegal,ch_special,ch_dash,ch_plus,ch_lt,ch_gt,ch_eq,ch_exc),0
|
enum (illegal,ch_special,ch_dash,ch_plus,ch_lt,ch_gt,ch_eq,ch_exc),0
|
||||||
enum (ch_and,ch_bar,ch_dot,ch_white,ch_eol,ch_eof,ch_char,ch_string)
|
enum (ch_and,ch_bar,ch_dot,ch_white,ch_eol,ch_eof,ch_char,ch_string)
|
||||||
enum (ch_asterisk,ch_slash,ch_percent,ch_carot,ch_pound,ch_colon)
|
enum (ch_asterisk,ch_slash,ch_percent,ch_carot,ch_pound,ch_colon)
|
||||||
enum (ch_backslash,letter,digit)
|
enum (ch_backslash,ch_other,letter,digit)
|
||||||
|
|
||||||
|
! begin {NextCh}
|
||||||
tsc create stack frame
|
tsc create stack frame
|
||||||
sec
|
sec
|
||||||
sbc #stackFrameSize
|
sbc #stackFrameSize
|
||||||
|
@ -192,21 +494,24 @@ pf1 dey
|
||||||
pf2 sty lastWasReturn
|
pf2 sty lastWasReturn
|
||||||
! 1:
|
! 1:
|
||||||
lab1 anop
|
lab1 anop
|
||||||
|
! currentChPtr := chPtr;
|
||||||
! if chPtr = eofPtr then begin {flag end of file if we're there}
|
! if chPtr = eofPtr then begin {flag end of file if we're there}
|
||||||
lda chPtr
|
lda chPtr
|
||||||
|
sta currentChPtr
|
||||||
|
ldx chPtr+2
|
||||||
|
stx currentChPtr+2
|
||||||
cmp eofPtr
|
cmp eofPtr
|
||||||
bne la1
|
bne la1
|
||||||
lda chPtr+2
|
cpx eofPtr+2
|
||||||
cmp eofPtr+2
|
|
||||||
beq la2
|
beq la2
|
||||||
la1 brl lb5
|
la1 brl lb5
|
||||||
la2 anop
|
la2 anop
|
||||||
! if not lastWasReturn then begin
|
! if not lastWasReturn then begin
|
||||||
! lastWasReturn := true;
|
! lastWasReturn := true;
|
||||||
! needWriteLine := true;
|
! needWriteLine := true;
|
||||||
! ch := chr(eolChar);
|
! ch := chr(eolChar);
|
||||||
! goto le2;
|
! goto le2;
|
||||||
! end; {if}
|
! end; {if}
|
||||||
lda lastWasReturn
|
lda lastWasReturn
|
||||||
bne la3
|
bne la3
|
||||||
lda #1
|
lda #1
|
||||||
|
@ -215,8 +520,10 @@ la2 anop
|
||||||
lda #eolChar
|
lda #eolChar
|
||||||
sta ch
|
sta ch
|
||||||
brl le2
|
brl le2
|
||||||
|
! CheckConditionals;
|
||||||
|
la3 jsl CheckConditionals
|
||||||
! ch := chr(eofChar);
|
! ch := chr(eofChar);
|
||||||
la3 stz ch
|
stz ch
|
||||||
|
|
||||||
! if needWriteLine then begin {do eol processing}
|
! if needWriteLine then begin {do eol processing}
|
||||||
! WriteLine;
|
! WriteLine;
|
||||||
|
@ -228,7 +535,7 @@ la3 stz ch
|
||||||
beq lb1
|
beq lb1
|
||||||
jsl WriteLine
|
jsl WriteLine
|
||||||
stz wroteLine
|
stz wroteLine
|
||||||
inc lineNumber
|
inc4 lineNumber
|
||||||
move4 chPtr,firstPtr
|
move4 chPtr,firstPtr
|
||||||
lb1 anop
|
lb1 anop
|
||||||
|
|
||||||
|
@ -243,19 +550,26 @@ lb2 anop
|
||||||
brl le2
|
brl le2
|
||||||
! else begin
|
! else begin
|
||||||
lb3 anop
|
lb3 anop
|
||||||
! {purge the current source file}
|
! if not doingFakeFile then begin
|
||||||
! with ffDCBGS do begin
|
lda doingFakeFile
|
||||||
! pCount := 5;
|
bne lb3a
|
||||||
|
! {purge the current source file}
|
||||||
|
! with ffDCBGS do begin
|
||||||
|
! pCount := 5;
|
||||||
lda #5
|
lda #5
|
||||||
sta ffDCBGS
|
sta ffDCBGS
|
||||||
! action := 7;
|
! action := 7;
|
||||||
lda #7
|
lda #7
|
||||||
sta ffDCBGS+2
|
sta ffDCBGS+2
|
||||||
! name := @includeFileGS.theString
|
! name := @includeFileGS.theString
|
||||||
lla ffDCBGS+12,includeFileGS+2
|
lla ffDCBGS+12,includeFileGS+2
|
||||||
! end; {with}
|
! end; {with}
|
||||||
! FastFileGS(ffDCBGS);
|
! FastFileGS(ffDCBGS);
|
||||||
FastFileGS ffDCBGS
|
FastFileGS ffDCBGS
|
||||||
|
! end; {if}
|
||||||
|
lb3a anop
|
||||||
|
! doingFakeFile := false;
|
||||||
|
stz doingFakeFile
|
||||||
! fp := fileList; {open the file that included this one}
|
! fp := fileList; {open the file that included this one}
|
||||||
move4 fileList,fp
|
move4 fileList,fp
|
||||||
! fileList := fp^.next;
|
! fileList := fp^.next;
|
||||||
|
@ -277,10 +591,17 @@ lb4 lda [p1],Y
|
||||||
dey
|
dey
|
||||||
bpl lb4
|
bpl lb4
|
||||||
long M
|
long M
|
||||||
|
! changedSourceFile := true;
|
||||||
|
lda #1
|
||||||
|
sta changedSourceFile
|
||||||
! lineNumber := fp^.lineNumber;
|
! lineNumber := fp^.lineNumber;
|
||||||
ldy #4+maxPath+4+maxPath+4
|
ldy #4+maxPath+4+maxPath+4
|
||||||
lda [fp],Y
|
lda [fp],Y
|
||||||
sta lineNumber
|
sta lineNumber
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda [fp],Y
|
||||||
|
sta lineNumber+2
|
||||||
! ReadFile;
|
! ReadFile;
|
||||||
jsl ReadFile
|
jsl ReadFile
|
||||||
! eofPtr := pointer(ord4(bofPtr) + ffDCBGS.fileLength);
|
! eofPtr := pointer(ord4(bofPtr) + ffDCBGS.fileLength);
|
||||||
|
@ -288,7 +609,7 @@ lb4 lda [p1],Y
|
||||||
! chPtr := pointer(ord4(bofPtr) + fp^.disp);
|
! chPtr := pointer(ord4(bofPtr) + fp^.disp);
|
||||||
! includeChPtr := chPtr;
|
! includeChPtr := chPtr;
|
||||||
! firstPtr := chPtr;
|
! firstPtr := chPtr;
|
||||||
ldy #4+maxPath+4+maxPath+4+2
|
ldy #4+maxPath+4+maxPath+4+4
|
||||||
clc
|
clc
|
||||||
lda bofPtr
|
lda bofPtr
|
||||||
adc [fp],Y
|
adc [fp],Y
|
||||||
|
@ -309,15 +630,21 @@ lb4 lda [p1],Y
|
||||||
jsl ~Dispose
|
jsl ~Dispose
|
||||||
! includeCount := includeCount + 1;
|
! includeCount := includeCount + 1;
|
||||||
inc includeCount
|
inc includeCount
|
||||||
|
! if inhibitHeader then
|
||||||
|
lda inhibitHeader
|
||||||
|
beq lb4a
|
||||||
|
! TermHeader;
|
||||||
|
jsl TermHeader
|
||||||
! goto 1;
|
! goto 1;
|
||||||
brl lab1
|
lb4a brl lab1
|
||||||
! end; {if}
|
! end; {if}
|
||||||
! end {if}
|
! end {if}
|
||||||
|
|
||||||
! else begin
|
! else begin
|
||||||
lb5 anop
|
lb5 anop
|
||||||
! ch := chr(chPtr^); {fetch the character}
|
! ch := chr(chPtr^); {fetch the character}
|
||||||
move4 chPtr,p1
|
sta p1
|
||||||
|
stx p1+2
|
||||||
lda [p1]
|
lda [p1]
|
||||||
and #$00FF
|
and #$00FF
|
||||||
sta ch
|
sta ch
|
||||||
|
@ -332,7 +659,7 @@ lb5 anop
|
||||||
beq lb6
|
beq lb6
|
||||||
jsl WriteLine
|
jsl WriteLine
|
||||||
stz wroteLine
|
stz wroteLine
|
||||||
inc lineNumber
|
inc4 lineNumber
|
||||||
move4 chPtr,firstPtr
|
move4 chPtr,firstPtr
|
||||||
lb6 anop
|
lb6 anop
|
||||||
! needWriteLine := charKinds[ord(ch)] = ch_eol;
|
! needWriteLine := charKinds[ord(ch)] = ch_eol;
|
||||||
|
@ -418,11 +745,16 @@ lc2 anop
|
||||||
lda chPtr+2
|
lda chPtr+2
|
||||||
cmp eofPtr+2
|
cmp eofPtr+2
|
||||||
jeq lc5
|
jeq lc5
|
||||||
! else if (cch = '/') and (chPtr^ = return) then begin
|
! else if (cch = '/') then begin
|
||||||
lc2a lda cch
|
lc2a lda cch
|
||||||
cmp #'/'
|
cmp #'/'
|
||||||
bne lc2b
|
bne lc2b
|
||||||
! if charKinds[ord(ch)] = ch_eol then
|
! if (charKinds[ord(chPtr^)] = ch_eol)
|
||||||
|
! and (ptr(ord4(chPtr)-1)^ <> '\')
|
||||||
|
! and ((ptr(ord4(chPtr)-1)^ <> '/')
|
||||||
|
! or (ptr(ord4(chPtr)-2)^ <> '?')
|
||||||
|
! or (ptr(ord4(chPtr)-3)^ <> '?'))
|
||||||
|
! then
|
||||||
! done := true
|
! done := true
|
||||||
! else
|
! else
|
||||||
! chPtr := pointer(ord4(chPtr)+1);
|
! chPtr := pointer(ord4(chPtr)+1);
|
||||||
|
@ -433,8 +765,19 @@ lc2a lda cch
|
||||||
tax
|
tax
|
||||||
lda charKinds,X
|
lda charKinds,X
|
||||||
cmp #ch_eol
|
cmp #ch_eol
|
||||||
jeq lc5
|
bne lc2aa
|
||||||
inc4 chPtr
|
dec4 p1
|
||||||
|
lda [p1]
|
||||||
|
and #$00FF
|
||||||
|
cmp #'\'
|
||||||
|
beq lc2aa
|
||||||
|
cmp #'/'
|
||||||
|
jne lc5
|
||||||
|
sub4 p1,#2
|
||||||
|
lda [p1]
|
||||||
|
cmp #'??'
|
||||||
|
jne lc5
|
||||||
|
lc2aa inc4 chPtr
|
||||||
bra lc2
|
bra lc2
|
||||||
! end {else if}
|
! end {else if}
|
||||||
! else begin
|
! else begin
|
||||||
|
@ -456,7 +799,7 @@ lc2b move4 chPtr,p1
|
||||||
bne lc3
|
bne lc3
|
||||||
jsl WriteLine
|
jsl WriteLine
|
||||||
stz wroteLine
|
stz wroteLine
|
||||||
inc lineNumber
|
inc4 lineNumber
|
||||||
add4 chPtr,#1,firstPtr
|
add4 chPtr,#1,firstPtr
|
||||||
lc3 anop
|
lc3 anop
|
||||||
! chPtr := pointer(ord4(chPtr)+1);
|
! chPtr := pointer(ord4(chPtr)+1);
|
||||||
|
@ -570,7 +913,7 @@ le1 sta ch
|
||||||
! goto 2;
|
! goto 2;
|
||||||
brl lab2
|
brl lab2
|
||||||
! end; {if}
|
! end; {if}
|
||||||
! end; {if}
|
! end; {else if}
|
||||||
! end; {else}
|
! end; {else}
|
||||||
le2 anop
|
le2 anop
|
||||||
pld
|
pld
|
||||||
|
@ -608,22 +951,24 @@ db1 sta p1
|
||||||
and #$00FF
|
and #$00FF
|
||||||
cmp #$07
|
cmp #$07
|
||||||
bne db2
|
bne db2
|
||||||
! debugType := break
|
! debugType := break;
|
||||||
lda #break
|
lda #break
|
||||||
sta debugType
|
sta debugType
|
||||||
|
! chPtr := pointer(ord4(chPtr) + 1);
|
||||||
|
! end {else if}
|
||||||
bra db3
|
bra db3
|
||||||
! else if ord(chPtr^) = $06 then
|
! else if ord(chPtr^) = $06 then begin
|
||||||
db2 cmp #$06
|
db2 cmp #$06
|
||||||
bne db4
|
bne db4
|
||||||
! debugType := autoGo;
|
! debugType := autoGo;
|
||||||
lda #autoGo
|
lda #autoGo
|
||||||
sta debugType
|
sta debugType
|
||||||
! chPtr := pointer(ord4(chPtr) + 1);
|
! chPtr := pointer(ord4(chPtr) + 1);
|
||||||
db3 inc4 chPtr
|
db3 inc4 chPtr
|
||||||
! end {if}
|
! end {else if}
|
||||||
bra db5
|
bra db5
|
||||||
! else
|
! else
|
||||||
! debugType := stop;
|
! debugType := stop;
|
||||||
db4 stz debugType
|
db4 stz debugType
|
||||||
! end; {DebugCheck}
|
! end; {DebugCheck}
|
||||||
db5 rts
|
db5 rts
|
||||||
|
@ -639,7 +984,7 @@ db5 rts
|
||||||
*
|
*
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
SetDateTime private
|
SetDateTime private scanner
|
||||||
|
|
||||||
pha get the date/time
|
pha get the date/time
|
||||||
pha
|
pha
|
||||||
|
@ -649,13 +994,13 @@ SetDateTime private
|
||||||
lda 1,S set the minutes
|
lda 1,S set the minutes
|
||||||
xba
|
xba
|
||||||
jsr convert
|
jsr convert
|
||||||
sta time+5
|
sta >time+5
|
||||||
pla set the seconds
|
pla set the seconds
|
||||||
jsr convert
|
jsr convert
|
||||||
sta time+8
|
sta >time+8
|
||||||
lda 1,S set the hour
|
lda 1,S set the hour
|
||||||
jsr convert
|
jsr convert
|
||||||
sta time+2
|
sta >time+2
|
||||||
pla set the year
|
pla set the year
|
||||||
xba
|
xba
|
||||||
and #$00FF
|
and #$00FF
|
||||||
|
@ -668,10 +1013,10 @@ yearloop sec
|
||||||
yeardone clc
|
yeardone clc
|
||||||
adc #100
|
adc #100
|
||||||
jsr convert
|
jsr convert
|
||||||
sta date+11
|
sta >date+11
|
||||||
tya
|
tya
|
||||||
jsr convert
|
jsr convert
|
||||||
sta date+9
|
sta >date+9
|
||||||
lda 1,S set the day
|
lda 1,S set the day
|
||||||
inc A
|
inc A
|
||||||
jsr convert
|
jsr convert
|
||||||
|
@ -680,17 +1025,17 @@ yeardone clc
|
||||||
bne dateOK
|
bne dateOK
|
||||||
lda #' '
|
lda #' '
|
||||||
dateOK long M
|
dateOK long M
|
||||||
sta date+6
|
sta >date+6
|
||||||
pla set the month
|
pla set the month
|
||||||
xba
|
xba
|
||||||
and #$00FF
|
and #$00FF
|
||||||
asl A
|
asl A
|
||||||
asl A
|
asl A
|
||||||
tax
|
tax
|
||||||
lda month,X
|
lda >month,X
|
||||||
sta date+2
|
sta >date+2
|
||||||
lda month+1,X
|
lda >month+1,X
|
||||||
sta date+3
|
sta >date+3
|
||||||
pla
|
pla
|
||||||
lla timeStr,time set the addresses
|
lla timeStr,time set the addresses
|
||||||
lla dateStr,date
|
lla dateStr,date
|
||||||
|
|
|
@ -636,3 +636,48 @@
|
||||||
.f
|
.f
|
||||||
mnote "Missing closing '}'",16
|
mnote "Missing closing '}'",16
|
||||||
mend
|
mend
|
||||||
|
macro
|
||||||
|
&l sub4 &m1,&m2,&m3
|
||||||
|
lclb &yistwo
|
||||||
|
lclc &c
|
||||||
|
&l ~setm
|
||||||
|
aif c:&m3,.a
|
||||||
|
&c amid "&m2",1,1
|
||||||
|
aif "&c"<>"#",.a
|
||||||
|
&c amid "&m1",1,1
|
||||||
|
aif "&c"="{",.a
|
||||||
|
aif "&c"="[",.a
|
||||||
|
&c amid "&m2",2,l:&m2-1
|
||||||
|
aif &c>=65536,.a
|
||||||
|
sec
|
||||||
|
~lda &m1
|
||||||
|
~op sbc,&m2
|
||||||
|
~sta &m1
|
||||||
|
bcs ~&SYSCNT
|
||||||
|
~op.h dec,&m1
|
||||||
|
~&SYSCNT anop
|
||||||
|
ago .c
|
||||||
|
.a
|
||||||
|
aif c:&m3,.b
|
||||||
|
lclc &m3
|
||||||
|
&m3 setc &m1
|
||||||
|
.b
|
||||||
|
sec
|
||||||
|
~lda &m1
|
||||||
|
~op sbc,&m2
|
||||||
|
~sta &m3
|
||||||
|
~lda.h &m1
|
||||||
|
~op.h sbc,&m2
|
||||||
|
~sta.h &m3
|
||||||
|
.c
|
||||||
|
~restm
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&l dec4 &a
|
||||||
|
&l ~setm
|
||||||
|
lda &a
|
||||||
|
bne ~&SYSCNT
|
||||||
|
dec 2+&a
|
||||||
|
~&SYSCNT dec &a
|
||||||
|
~restm
|
||||||
|
mend
|
||||||
|
|
2072
Scanner.pas
2072
Scanner.pas
File diff suppressed because it is too large
Load Diff
21
Symbol.asm
21
Symbol.asm
|
@ -9,11 +9,12 @@
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
ClearTable private cc
|
ClearTable private cc
|
||||||
tableSize equ 7026 sizeof(symbolTable)
|
hashSize2 equ 1753 # hash buckets * 2 - 1
|
||||||
|
sizeofBuckets equ 4*(hashSize2+1) sizeof(symbolTable.buckets)
|
||||||
|
|
||||||
subroutine (4:table),0
|
subroutine (4:table),0
|
||||||
|
|
||||||
ldy #tableSize-2
|
ldy #sizeofBuckets-2
|
||||||
lda #0
|
lda #0
|
||||||
lb1 sta [table],Y
|
lb1 sta [table],Y
|
||||||
dey
|
dey
|
||||||
|
@ -22,3 +23,19 @@ lb1 sta [table],Y
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
* SaveBF - save a value to a bit-field
|
||||||
|
*
|
||||||
|
* Inputs:
|
||||||
|
* addr - address to copy to
|
||||||
|
* bitdisp - displacement past the address
|
||||||
|
* bitsize - number of bits
|
||||||
|
* val - value to copy
|
||||||
|
*
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
SaveBF private cc
|
||||||
|
jml ~SaveBF call ~SaveBF in ORCALib
|
||||||
|
end
|
||||||
|
|
1106
Symbol.pas
1106
Symbol.pas
File diff suppressed because it is too large
Load Diff
173
Table.asm
173
Table.asm
|
@ -19,7 +19,7 @@ charKinds start character set
|
||||||
enum (illegal,ch_special,ch_dash,ch_plus,ch_lt,ch_gt,ch_eq,ch_exc),0
|
enum (illegal,ch_special,ch_dash,ch_plus,ch_lt,ch_gt,ch_eq,ch_exc),0
|
||||||
enum (ch_and,ch_bar,ch_dot,ch_white,ch_eol,ch_eof,ch_char,ch_string)
|
enum (ch_and,ch_bar,ch_dot,ch_white,ch_eol,ch_eof,ch_char,ch_string)
|
||||||
enum (ch_asterisk,ch_slash,ch_percent,ch_carot,ch_pound,ch_colon)
|
enum (ch_asterisk,ch_slash,ch_percent,ch_carot,ch_pound,ch_colon)
|
||||||
enum (ch_backslash,letter,digit)
|
enum (ch_backslash,ch_other,letter,digit)
|
||||||
|
|
||||||
! STANDARD
|
! STANDARD
|
||||||
dc i'ch_eof' nul
|
dc i'ch_eof' nul
|
||||||
|
@ -57,8 +57,8 @@ charKinds start character set
|
||||||
dc i'ch_white' space
|
dc i'ch_white' space
|
||||||
dc i'ch_exc' !
|
dc i'ch_exc' !
|
||||||
dc i'ch_string' "
|
dc i'ch_string' "
|
||||||
dc i'illegal' #
|
dc i'ch_pound' #
|
||||||
dc i'illegal' $
|
dc i'ch_other' $
|
||||||
dc i'ch_percent' %
|
dc i'ch_percent' %
|
||||||
dc i'ch_and' &
|
dc i'ch_and' &
|
||||||
dc i'ch_char' '
|
dc i'ch_char' '
|
||||||
|
@ -86,7 +86,7 @@ charKinds start character set
|
||||||
dc i'ch_eq' =
|
dc i'ch_eq' =
|
||||||
dc i'ch_gt' >
|
dc i'ch_gt' >
|
||||||
dc i'ch_special' ?
|
dc i'ch_special' ?
|
||||||
dc i'illegal' @
|
dc i'ch_other' @
|
||||||
dc i'letter' A
|
dc i'letter' A
|
||||||
dc i'letter' B
|
dc i'letter' B
|
||||||
dc i'letter' C
|
dc i'letter' C
|
||||||
|
@ -118,7 +118,7 @@ charKinds start character set
|
||||||
dc i'ch_special' ]
|
dc i'ch_special' ]
|
||||||
dc i'ch_carot' ^
|
dc i'ch_carot' ^
|
||||||
dc i'letter' _
|
dc i'letter' _
|
||||||
dc i'illegal' `
|
dc i'ch_other' `
|
||||||
dc i'letter' a
|
dc i'letter' a
|
||||||
dc i'letter' b
|
dc i'letter' b
|
||||||
dc i'letter' c
|
dc i'letter' c
|
||||||
|
@ -183,24 +183,24 @@ charKinds start character set
|
||||||
dc i'letter' gs
|
dc i'letter' gs
|
||||||
dc i'letter' rs
|
dc i'letter' rs
|
||||||
dc i'letter' us
|
dc i'letter' us
|
||||||
dc i'illegal' space
|
dc i'ch_other' space
|
||||||
dc i'illegal' !
|
dc i'ch_other' !
|
||||||
dc i'illegal' "
|
dc i'ch_other' "
|
||||||
dc i'illegal' #
|
dc i'ch_other' #
|
||||||
dc i'illegal' $
|
dc i'ch_other' $
|
||||||
dc i'illegal' %
|
dc i'ch_other' %
|
||||||
dc i'illegal' &
|
dc i'ch_other' &
|
||||||
dc i'letter' '
|
dc i'letter' '
|
||||||
dc i'illegal' (
|
dc i'ch_other' (
|
||||||
dc i'illegal' )
|
dc i'ch_other' )
|
||||||
dc i'illegal' *
|
dc i'ch_other' *
|
||||||
dc i'illegal' +
|
dc i'ch_other' +
|
||||||
dc i'illegal' ,
|
dc i'ch_other' ,
|
||||||
dc i'ch_special' -
|
dc i'ch_special' -
|
||||||
dc i'letter' .
|
dc i'letter' .
|
||||||
dc i'letter' /
|
dc i'letter' /
|
||||||
dc i'illegal' 0
|
dc i'ch_other' 0
|
||||||
dc i'illegal' 1
|
dc i'ch_other' 1
|
||||||
dc i'ch_special' 2
|
dc i'ch_special' 2
|
||||||
dc i'ch_special' 3
|
dc i'ch_special' 3
|
||||||
dc i'letter' 4
|
dc i'letter' 4
|
||||||
|
@ -209,76 +209,76 @@ charKinds start character set
|
||||||
dc i'letter' 7
|
dc i'letter' 7
|
||||||
dc i'letter' 8
|
dc i'letter' 8
|
||||||
dc i'letter' 9
|
dc i'letter' 9
|
||||||
dc i'illegal' :
|
dc i'ch_other' :
|
||||||
dc i'letter' ;
|
dc i'letter' ;
|
||||||
dc i'letter' <
|
dc i'letter' <
|
||||||
dc i'letter' =
|
dc i'letter' =
|
||||||
dc i'letter' >
|
dc i'letter' >
|
||||||
dc i'letter' ?
|
dc i'letter' ?
|
||||||
dc i'illegal' @
|
dc i'ch_other' @
|
||||||
dc i'illegal' A
|
dc i'ch_other' A
|
||||||
dc i'illegal' B
|
dc i'ch_other' B
|
||||||
dc i'illegal' C
|
dc i'ch_other' C
|
||||||
dc i'letter' D
|
dc i'letter' D
|
||||||
dc i'illegal' E
|
dc i'ch_other' E
|
||||||
dc i'letter' F
|
dc i'letter' F
|
||||||
dc i'ch_special' G
|
dc i'ch_special' G
|
||||||
dc i'ch_special' H
|
dc i'ch_special' H
|
||||||
dc i'illegal' I
|
dc i'ch_other' I
|
||||||
dc i'ch_white' J
|
dc i'ch_white' J
|
||||||
dc i'letter' K
|
dc i'letter' K
|
||||||
dc i'letter' L
|
dc i'letter' L
|
||||||
dc i'letter' M
|
dc i'letter' M
|
||||||
dc i'letter' N
|
dc i'letter' N
|
||||||
dc i'letter' O
|
dc i'letter' O
|
||||||
dc i'illegal' P
|
dc i'ch_other' P
|
||||||
dc i'illegal' Q
|
dc i'ch_other' Q
|
||||||
dc i'illegal' R
|
dc i'ch_other' R
|
||||||
dc i'illegal' S
|
dc i'ch_other' S
|
||||||
dc i'illegal' T
|
dc i'ch_other' T
|
||||||
dc i'illegal' U
|
dc i'ch_other' U
|
||||||
dc i'ch_special' V
|
dc i'ch_special' V
|
||||||
dc i'illegal' W
|
dc i'ch_other' W
|
||||||
dc i'letter' X
|
dc i'letter' X
|
||||||
dc i'illegal' Y
|
dc i'letter' Y
|
||||||
dc i'illegal' Z
|
dc i'ch_other' Z
|
||||||
dc i'illegal' [
|
dc i'ch_other' [
|
||||||
dc i'illegal' \
|
dc i'ch_other' \
|
||||||
dc i'illegal' ]
|
dc i'ch_other' ]
|
||||||
dc i'letter' ^
|
dc i'letter' ^
|
||||||
dc i'letter' _
|
dc i'letter' _
|
||||||
dc i'illegal' `
|
dc i'ch_other' `
|
||||||
dc i'illegal' a
|
dc i'ch_other' a
|
||||||
dc i'illegal' b
|
dc i'ch_other' b
|
||||||
dc i'illegal' c
|
dc i'ch_other' c
|
||||||
dc i'illegal' d
|
dc i'ch_other' d
|
||||||
dc i'illegal' e
|
dc i'letter' e
|
||||||
dc i'illegal' f
|
dc i'letter' f
|
||||||
dc i'illegal' g
|
dc i'letter' g
|
||||||
dc i'illegal' h
|
dc i'letter' h
|
||||||
dc i'illegal' i
|
dc i'letter' i
|
||||||
dc i'illegal' j
|
dc i'letter' j
|
||||||
dc i'illegal' k
|
dc i'letter' k
|
||||||
dc i'illegal' l
|
dc i'letter' l
|
||||||
dc i'illegal' m
|
dc i'letter' m
|
||||||
dc i'illegal' n
|
dc i'letter' n
|
||||||
dc i'illegal' o
|
dc i'letter' o
|
||||||
dc i'illegal' p
|
dc i'ch_other' p
|
||||||
dc i'illegal' q
|
dc i'letter' q
|
||||||
dc i'illegal' r
|
dc i'letter' r
|
||||||
dc i'illegal' s
|
dc i'letter' s
|
||||||
dc i'illegal' t
|
dc i'letter' t
|
||||||
dc i'illegal' u
|
dc i'letter' u
|
||||||
dc i'illegal' v
|
dc i'ch_other' v
|
||||||
dc i'illegal' w
|
dc i'ch_other' w
|
||||||
dc i'illegal' x
|
dc i'ch_other' x
|
||||||
dc i'illegal' y
|
dc i'ch_other' y
|
||||||
dc i'illegal' z
|
dc i'ch_other' z
|
||||||
dc i'illegal' {
|
dc i'ch_other' {
|
||||||
dc i'illegal' |
|
dc i'ch_other' |
|
||||||
dc i'illegal' }
|
dc i'ch_other' }
|
||||||
dc i'illegal' ~
|
dc i'ch_other' ~
|
||||||
dc i'illegal' rub
|
dc i'ch_other' rub
|
||||||
end
|
end
|
||||||
|
|
||||||
charSym start single character symbols
|
charSym start single character symbols
|
||||||
|
@ -286,7 +286,7 @@ charSym start single character symbols
|
||||||
! constants
|
! constants
|
||||||
enum (intconst,uintconst,longconst,ulongconst,longlongconst)
|
enum (intconst,uintconst,longconst,ulongconst,longlongconst)
|
||||||
enum (ulonglongconst,floatconst,doubleconst,extendedconst,compconst)
|
enum (ulonglongconst,floatconst,doubleconst,extendedconst,compconst)
|
||||||
enum (charconst,scharconst,ucharconst,stringconst)
|
enum (charconst,scharconst,ucharconst,ushortconst,stringconst)
|
||||||
! reserved words
|
! reserved words
|
||||||
enum (_Alignassy,_Alignofsy,_Atomicsy,_Boolsy,_Complexsy)
|
enum (_Alignassy,_Alignofsy,_Atomicsy,_Boolsy,_Complexsy)
|
||||||
enum (_Genericsy,_Imaginarysy,_Noreturnsy,_Static_assertsy,_Thread_localsy)
|
enum (_Genericsy,_Imaginarysy,_Noreturnsy,_Static_assertsy,_Thread_localsy)
|
||||||
|
@ -308,11 +308,14 @@ charSym start single character symbols
|
||||||
enum (lteqop,gteqop,eqeqop,exceqop,andandop)
|
enum (lteqop,gteqop,eqeqop,exceqop,andandop)
|
||||||
enum (barbarop,pluseqop,minuseqop,asteriskeqop,slasheqop)
|
enum (barbarop,pluseqop,minuseqop,asteriskeqop,slasheqop)
|
||||||
enum (percenteqop,ltlteqop,gtgteqop,andeqop,caroteqop)
|
enum (percenteqop,ltlteqop,gtgteqop,andeqop,caroteqop)
|
||||||
enum (bareqop,poundpoundop)
|
enum (bareqop,poundpoundop,dotdotdotsy)
|
||||||
|
enum (ppnumber) preprocessing number
|
||||||
|
enum (otherch) other non-whitespace char
|
||||||
enum (eolsy,eofsy) control characters
|
enum (eolsy,eofsy) control characters
|
||||||
enum (typedef) user types
|
enum (typedef) user types
|
||||||
enum (uminus,uand,uasterisk) converted operations
|
! converted operations
|
||||||
enum (parameteroper,castoper,opplusplus,opminusminus)
|
enum (uminus,uplus,uand,uasterisk)
|
||||||
|
enum (parameteroper,castoper,opplusplus,opminusminus,compoundliteral)
|
||||||
enum (macroParm) macro language
|
enum (macroParm) macro language
|
||||||
|
|
||||||
dc i'0,0,0,0,0,0,0,0' nul-bel
|
dc i'0,0,0,0,0,0,0,0' nul-bel
|
||||||
|
@ -366,6 +369,7 @@ icp start in-coming priority for expression
|
||||||
dc i1'200' charconst
|
dc i1'200' charconst
|
||||||
dc i1'200' scharconst
|
dc i1'200' scharconst
|
||||||
dc i1'200' ucharconst
|
dc i1'200' ucharconst
|
||||||
|
dc i1'200' ushortconst
|
||||||
dc i1'200' stringconst
|
dc i1'200' stringconst
|
||||||
dc i1'200' _Alignassy
|
dc i1'200' _Alignassy
|
||||||
dc i1'16' _Alignofsy
|
dc i1'16' _Alignofsy
|
||||||
|
@ -463,16 +467,21 @@ icp start in-coming priority for expression
|
||||||
dc i1'3' caroteqop
|
dc i1'3' caroteqop
|
||||||
dc i1'3' bareqop
|
dc i1'3' bareqop
|
||||||
dc i1'200' poundpoundop
|
dc i1'200' poundpoundop
|
||||||
|
dc i1'200' dotdotdotsy
|
||||||
|
dc i1'200' ppnumber
|
||||||
|
dc i1'200' otherch
|
||||||
dc i1'200' eolsy
|
dc i1'200' eolsy
|
||||||
dc i1'200' eofsy
|
dc i1'200' eofsy
|
||||||
dc i1'200' typedef
|
dc i1'200' typedef
|
||||||
dc i1'16' uminus
|
dc i1'16' uminus
|
||||||
|
dc i1'16' uplus
|
||||||
dc i1'16' uand
|
dc i1'16' uand
|
||||||
dc i1'16' uasterisk
|
dc i1'16' uasterisk
|
||||||
dc i1'200' parameteroper
|
dc i1'200' parameteroper
|
||||||
dc i1'16' castoper
|
dc i1'16' castoper
|
||||||
dc i1'16' opplusplus
|
dc i1'16' opplusplus
|
||||||
dc i1'16' opminusminus
|
dc i1'16' opminusminus
|
||||||
|
dc i1'200' compoundliteral
|
||||||
dc i1'200' macroParm
|
dc i1'200' macroParm
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -539,6 +548,7 @@ isp start in stack priority for expression
|
||||||
dc i1'0' charconst
|
dc i1'0' charconst
|
||||||
dc i1'0' scharconst
|
dc i1'0' scharconst
|
||||||
dc i1'0' ucharconst
|
dc i1'0' ucharconst
|
||||||
|
dc i1'0' ushortconst
|
||||||
dc i1'0' stringconst
|
dc i1'0' stringconst
|
||||||
dc i1'0' _Alignassy
|
dc i1'0' _Alignassy
|
||||||
dc i1'16' _Alignofsy
|
dc i1'16' _Alignofsy
|
||||||
|
@ -636,16 +646,21 @@ isp start in stack priority for expression
|
||||||
dc i1'2' caroteqop
|
dc i1'2' caroteqop
|
||||||
dc i1'2' bareqop
|
dc i1'2' bareqop
|
||||||
dc i1'0' poundpoundop
|
dc i1'0' poundpoundop
|
||||||
|
dc i1'0' dotdotdotsy
|
||||||
|
dc i1'0' ppnumber
|
||||||
|
dc i1'0' otherch
|
||||||
dc i1'0' eolsy
|
dc i1'0' eolsy
|
||||||
dc i1'0' eofsy
|
dc i1'0' eofsy
|
||||||
dc i1'0' typedef
|
dc i1'0' typedef
|
||||||
dc i1'16' uminus
|
dc i1'16' uminus
|
||||||
|
dc i1'16' uplus
|
||||||
dc i1'16' uand
|
dc i1'16' uand
|
||||||
dc i1'16' uasterisk
|
dc i1'16' uasterisk
|
||||||
dc i1'0' parameteroper
|
dc i1'0' parameteroper
|
||||||
dc i1'16' castoper
|
dc i1'16' castoper
|
||||||
dc i1'16' opplusplus
|
dc i1'16' opplusplus
|
||||||
dc i1'16' opminusminus
|
dc i1'16' opminusminus
|
||||||
|
dc i1'0' compoundliteral
|
||||||
dc i1'0' macroParm
|
dc i1'0' macroParm
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -912,7 +927,7 @@ wordHash start reserved word hash table
|
||||||
! constants
|
! constants
|
||||||
enum (intconst,uintconst,longconst,ulongconst,longlongconst)
|
enum (intconst,uintconst,longconst,ulongconst,longlongconst)
|
||||||
enum (ulonglongconst,floatconst,doubleconst,extendedconst,compconst)
|
enum (ulonglongconst,floatconst,doubleconst,extendedconst,compconst)
|
||||||
enum (charconst,scharconst,ucharconst,stringconst)
|
enum (charconst,scharconst,ucharconst,ushortconst,stringconst)
|
||||||
! reserved words
|
! reserved words
|
||||||
enum (_Alignassy,_Alignofsy,_Atomicsy,_Boolsy,_Complexsy)
|
enum (_Alignassy,_Alignofsy,_Atomicsy,_Boolsy,_Complexsy)
|
||||||
enum (_Genericsy,_Imaginarysy,_Noreturnsy,_Static_assertsy,_Thread_localsy)
|
enum (_Genericsy,_Imaginarysy,_Noreturnsy,_Static_assertsy,_Thread_localsy)
|
||||||
|
@ -932,6 +947,14 @@ wordHash start reserved word hash table
|
||||||
dc i'shortsy,typedefsy,unionsy,voidsy,whilesy,succwhilesy'
|
dc i'shortsy,typedefsy,unionsy,voidsy,whilesy,succwhilesy'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
stdcVersion start __STDC_VERSION__ values
|
||||||
|
|
||||||
|
dc i4'199409' c95
|
||||||
|
dc i4'199901' c99
|
||||||
|
dc i4'201112' c11
|
||||||
|
dc i4'201710' c17
|
||||||
|
end
|
||||||
|
|
||||||
macRomanToUCS start
|
macRomanToUCS start
|
||||||
dc i2'$00C4, $00C5, $00C7, $00C9, $00D1, $00D6, $00DC, $00E1'
|
dc i2'$00C4, $00C5, $00C7, $00C9, $00D1, $00D6, $00DC, $00E1'
|
||||||
dc i2'$00E0, $00E2, $00E4, $00E3, $00E5, $00E7, $00E9, $00E8'
|
dc i2'$00E0, $00E2, $00E4, $00E3, $00E5, $00E7, $00E9, $00E8'
|
||||||
|
|
|
@ -22,6 +22,7 @@ var
|
||||||
charSym: array[minChar..maxChar] of tokenEnum; {symbols for single char symbols}
|
charSym: array[minChar..maxChar] of tokenEnum; {symbols for single char symbols}
|
||||||
reservedWords: array[_Alignassy..whilesy] of string[14]; {reserved word strings}
|
reservedWords: array[_Alignassy..whilesy] of string[14]; {reserved word strings}
|
||||||
wordHash: array[0..25] of tokenEnum; {for hashing reserved words}
|
wordHash: array[0..25] of tokenEnum; {for hashing reserved words}
|
||||||
|
stdcVersion: array[c95..c17] of longint; {__STDC_VERSION__ values}
|
||||||
|
|
||||||
{from ASM.PAS}
|
{from ASM.PAS}
|
||||||
{------------}
|
{------------}
|
||||||
|
|
12
Tech.Support
Normal file
12
Tech.Support
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
As with all Byte Works programs, if you have questions or are
|
||||||
|
experiencing problems, we want to hear from you. You can contact us
|
||||||
|
through the channels below.
|
||||||
|
|
||||||
|
E-mail: support@byteworks.us
|
||||||
|
|
||||||
|
Web Site: https://www.byteworks.us
|
||||||
|
|
||||||
|
ORCA/C is now maintained on GitHub by community members. Bug reports
|
||||||
|
or support requests can be submitted on its issues page:
|
||||||
|
|
||||||
|
https://github.com/byteworksinc/ORCA-C/issues
|
|
@ -6,18 +6,18 @@
|
||||||
|
|
||||||
struct foo {
|
struct foo {
|
||||||
int i;
|
int i;
|
||||||
const j;
|
int const j;
|
||||||
volatile k;
|
volatile int k;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
main ()
|
int main (void)
|
||||||
|
|
||||||
{
|
{
|
||||||
int i,j;
|
int i,j;
|
||||||
|
|
||||||
j = 4;
|
j = 4;
|
||||||
i = (const) j;
|
i = (const int) j;
|
||||||
i = (volatile) j;
|
i = (int volatile) j;
|
||||||
|
|
||||||
printf ("Passed Conformance Test 11.4.2.1\n");
|
printf ("Passed Conformance Test 11.4.2.1\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,11 @@
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
int printf(const char *, ...);
|
||||||
|
|
||||||
extended e1 [800];
|
extended e1 [800];
|
||||||
|
|
||||||
main ()
|
int main (void)
|
||||||
{
|
{
|
||||||
int i [10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
int i [10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||||
int *i1 = i;
|
int *i1 = i;
|
||||||
|
@ -28,7 +30,7 @@ main ()
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
|
||||||
printf ("Passed Conformance Test 13.1.0.1\n");
|
printf ("Passed Conformance Test 13.1.0.1\n");
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
printf ("Failed Conformance Test 13.1.0.1\n");
|
printf ("Failed Conformance Test 13.1.0.1\n");
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
main ()
|
int printf(const char *, ...);
|
||||||
|
|
||||||
|
int main (void)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
char ch;
|
char ch;
|
||||||
|
@ -141,7 +143,7 @@ main ()
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("Passed Conformance Test 14.1.0.1\n");
|
printf ("Passed Conformance Test 14.1.0.1\n");
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
printf ("Failed Conformance Test 14.1.0.1\n");
|
printf ("Failed Conformance Test 14.1.0.1\n");
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
main ()
|
int printf(const char *, ...);
|
||||||
|
|
||||||
|
int main (void)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
char ch;
|
char ch;
|
||||||
|
@ -54,7 +56,7 @@ main ()
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
|
||||||
printf ("Passed Conformance Test 14.2.0.1\n");
|
printf ("Passed Conformance Test 14.2.0.1\n");
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
printf ("Failed Conformance Test 14.2.0.1\n");
|
printf ("Failed Conformance Test 14.2.0.1\n");
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user