Re: [Oberon] PO2013 - Show Heap Blocks
Out.printf(), with VARIADIC arguments, in Oberon??? And that %d%) bothers me, for some reason... --- joerg.straube@iaeth.ch wrote: From: Jörg <joerg.straube@iaeth.ch> To: ETH Oberon and related systems <oberon@lists.inf.ethz.ch> Subject: Re: [Oberon] PO2013 - Show Heap Blocks Date: Fri, 19 Jun 2020 10:37:08 +0200 Tomas The following line will give you the stats as well: Out.printf(“Heap space used: %d bytes (=%d%)\n“, Kernel.allocated, Kernel.allocated * 100 DIV (Kernel.heapLim - Kernel.heapOrg), ““); That‘s basically what System.Watch does. br Jörg
Am 19.06.2020 um 10:12 schrieb Tomas Kral <thomas.kral@email.cz>:
Hi,
This is my understanding so far, it stats the heap. It also shows free block last to the limit, because heap ends 16 bytes earlier, so is not MOD 32.
MODULE Heap; (*TK 14.6.2020 show heap blocks*) IMPORT S := SYSTEM, Kernel, Out;
VAR heapOrg, MemLim, heapLim: INTEGER;
PROCEDURE Scan*; VAR p, q, mark, tag, size, used, free: LONGINT; BEGIN p := heapOrg; used := 0; free := 0; Out.Hex(heapOrg); Out.Ln; (*60000H 4-bit colour display*) Out.Hex(heapLim); Out.Ln; (*9FEF0H*) REPEAT S.GET(p+4, mark); q := p; (*mark: 0 used, -1 freed, >0 marked*) IF mark = -1 THEN S.GET(p, size) ELSE S.GET(p, tag); S.GET(tag, size); (*size := p - q*) END ; IF (size MOD 32 # 0) & (size MOD 64 # 0) & (size MOD 128 # 0) & (size MOD 256 # 0) THEN Out.Hex(p); Out.Hex(size); Out.Hex(mark); Out.Ln (*free block to 9FEF0H*) END ; IF mark > 0 THEN INC(used, size) (*none after kernel scan*) ELSIF mark = 0 THEN INC(used, size) ELSIF mark = -1 THEN INC(free, size) END ; INC(p, size) UNTIL p >= heapLim(*-30000H*) ; Out.Int(used, 8); (*value*) Out.Int(used*100 DIV free, 3); (*percentage*) Out.Hex(free+used); Out.Ln (*3FEF0 = 9FEF0H-60000H, or less if fragmented*) END Scan;
PROCEDURE Lists*; VAR p, list0, list1, list2, list3: INTEGER; BEGIN p := S.ADR(Kernel.MemLim); S.GET(p+8, list0); S.GET(p+12, list1); S.GET(p+16, list2); S.GET(p+20, list3); Out.Hex(list3); Out.Hex(list2); Out.Hex(list1); Out.Hex(list0); Out.Ln END Lists;
BEGIN S.GET(12, MemLim); S.GET(24, heapOrg); heapLim := MemLim END Heap.
Heap.Scan Heap.Lists
-- Tomas Kral <thomas.kral@email.cz> -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
John Seems like variadic but it is not. printf() has fix 4 arguments as I found out that this is enough for most cases. the first is the string with formatting commands, then two INTEGERs and one string (for a filename or so) If after a % there is a number, d, h or s it’s interpreted as argument else it’s just a %. br Jörg
Am 19.06.2020 um 16:56 schrieb John R. Strohm <strohm@airmail.net>:
Out.printf(), with VARIADIC arguments, in Oberon???
And that %d%) bothers me, for some reason...
--- joerg.straube@iaeth.ch wrote:
From: Jörg <joerg.straube@iaeth.ch> To: ETH Oberon and related systems <oberon@lists.inf.ethz.ch> Subject: Re: [Oberon] PO2013 - Show Heap Blocks Date: Fri, 19 Jun 2020 10:37:08 +0200
Tomas
The following line will give you the stats as well: Out.printf(“Heap space used: %d bytes (=%d%)\n“, Kernel.allocated, Kernel.allocated * 100 DIV (Kernel.heapLim - Kernel.heapOrg), ““);
That‘s basically what System.Watch does.
br Jörg
Am 19.06.2020 um 10:12 schrieb Tomas Kral <thomas.kral@email.cz>:
Hi,
This is my understanding so far, it stats the heap. It also shows free block last to the limit, because heap ends 16 bytes earlier, so is not MOD 32.
MODULE Heap; (*TK 14.6.2020 show heap blocks*) IMPORT S := SYSTEM, Kernel, Out;
VAR heapOrg, MemLim, heapLim: INTEGER;
PROCEDURE Scan*; VAR p, q, mark, tag, size, used, free: LONGINT; BEGIN p := heapOrg; used := 0; free := 0; Out.Hex(heapOrg); Out.Ln; (*60000H 4-bit colour display*) Out.Hex(heapLim); Out.Ln; (*9FEF0H*) REPEAT S.GET(p+4, mark); q := p; (*mark: 0 used, -1 freed, >0 marked*) IF mark = -1 THEN S.GET(p, size) ELSE S.GET(p, tag); S.GET(tag, size); (*size := p - q*) END ; IF (size MOD 32 # 0) & (size MOD 64 # 0) & (size MOD 128 # 0) & (size MOD 256 # 0) THEN Out.Hex(p); Out.Hex(size); Out.Hex(mark); Out.Ln (*free block to 9FEF0H*) END ; IF mark > 0 THEN INC(used, size) (*none after kernel scan*) ELSIF mark = 0 THEN INC(used, size) ELSIF mark = -1 THEN INC(free, size) END ; INC(p, size) UNTIL p >= heapLim(*-30000H*) ; Out.Int(used, 8); (*value*) Out.Int(used*100 DIV free, 3); (*percentage*) Out.Hex(free+used); Out.Ln (*3FEF0 = 9FEF0H-60000H, or less if fragmented*) END Scan;
PROCEDURE Lists*; VAR p, list0, list1, list2, list3: INTEGER; BEGIN p := S.ADR(Kernel.MemLim); S.GET(p+8, list0); S.GET(p+12, list1); S.GET(p+16, list2); S.GET(p+20, list3); Out.Hex(list3); Out.Hex(list2); Out.Hex(list1); Out.Hex(list0); Out.Ln END Lists;
BEGIN S.GET(12, MemLim); S.GET(24, heapOrg); heapLim := MemLim END Heap.
Heap.Scan Heap.Lists
-- Tomas Kral <thomas.kral@email.cz> -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
John In case you're interested, here the code: PROCEDURE printf*(s: ARRAY OF CHAR; i1, i2: INTEGER; str: ARRAY OF CHAR); (* supported format %[length]type, type = d, i, x or s, and escape characters \n, \t *) VAR n, j, len, par, x: INTEGER; ch, nxCh: CHAR; imm: BOOLEAN; BEGIN imm := immediate; immediate := FALSE; par := 1; n := 0; ch := s[0]; WHILE (ch # 0X) & (n < LEN(s)) DO j := n+1; nxCh := s[j]; IF ch = "%" THEN (* handle format *) len := 0; WHILE ("0" <= nxCh) & (nxCh <= "9") DO len := len * 10 + ORD(nxCh) - ORD("0"); INC(j); nxCh := s[j] END; IF nxCh = "s" THEN String(str); INC(j) ELSIF (nxCh # "d") & (nxCh # "i") & (nxCh # "x") THEN Char("%") ELSE x := i2; IF par = 1 THEN x := i1 END; INC(par); IF nxCh = "x" THEN Hex(x) ELSE (* i, d *) Int(x, len) END; INC(j) END ELSIF ch = "\" THEN (* handle escape characters *) IF nxCh = "n" THEN Ln; INC(j) ELSIF nxCh = "t" THEN Char(9X); INC(j) ELSE Char("\") END ELSE Char(ch) END; n := j; ch := s[n] END; immediate := imm END printf; Am 19.06.20, 17:23 schrieb "Joerg" <joerg.straube@iaeth.ch>: John Seems like variadic but it is not. printf() has fix 4 arguments as I found out that this is enough for most cases. the first is the string with formatting commands, then two INTEGERs and one string (for a filename or so) If after a % there is a number, d, h or s it’s interpreted as argument else it’s just a %. br Jörg > Am 19.06.2020 um 16:56 schrieb John R. Strohm <strohm@airmail.net>: > > Out.printf(), with VARIADIC arguments, in Oberon??? > > And that %d%) bothers me, for some reason... > > --- joerg.straube@iaeth.ch wrote: > > From: Jörg <joerg.straube@iaeth.ch> > To: ETH Oberon and related systems <oberon@lists.inf.ethz.ch> > Subject: Re: [Oberon] PO2013 - Show Heap Blocks > Date: Fri, 19 Jun 2020 10:37:08 +0200 > > Tomas > > The following line will give you the stats as well: > Out.printf(“Heap space used: %d bytes (=%d%)\n“, > Kernel.allocated, > Kernel.allocated * 100 DIV (Kernel.heapLim - Kernel.heapOrg), ““); > > That‘s basically what System.Watch does. > > br > Jörg > > >> Am 19.06.2020 um 10:12 schrieb Tomas Kral <thomas.kral@email.cz>: >> >> Hi, >> >> This is my understanding so far, it stats the heap. >> It also shows free block last to the limit, because heap ends 16 bytes >> earlier, so is not MOD 32. >> >> MODULE Heap; (*TK 14.6.2020 show heap blocks*) >> IMPORT S := SYSTEM, Kernel, Out; >> >> VAR heapOrg, MemLim, heapLim: INTEGER; >> >> PROCEDURE Scan*; >> VAR p, q, mark, tag, size, used, free: LONGINT; >> BEGIN p := heapOrg; used := 0; free := 0; >> Out.Hex(heapOrg); Out.Ln; (*60000H 4-bit colour display*) >> Out.Hex(heapLim); Out.Ln; (*9FEF0H*) >> REPEAT S.GET(p+4, mark); q := p; (*mark: 0 used, -1 freed, >0 marked*) >> IF mark = -1 THEN S.GET(p, size) >> ELSE S.GET(p, tag); S.GET(tag, size); (*size := p - q*) END ; >> IF (size MOD 32 # 0) & (size MOD 64 # 0) & (size MOD 128 # 0) & (size MOD 256 # 0) THEN >> Out.Hex(p); Out.Hex(size); Out.Hex(mark); Out.Ln (*free block to 9FEF0H*) >> END ; >> IF mark > 0 THEN INC(used, size) (*none after kernel scan*) >> ELSIF mark = 0 THEN INC(used, size) >> ELSIF mark = -1 THEN INC(free, size) END ; >> INC(p, size) >> UNTIL p >= heapLim(*-30000H*) ; >> Out.Int(used, 8); (*value*) Out.Int(used*100 DIV free, 3); (*percentage*) >> Out.Hex(free+used); Out.Ln (*3FEF0 = 9FEF0H-60000H, or less if fragmented*) >> END Scan; >> >> PROCEDURE Lists*; >> VAR p, list0, list1, list2, list3: INTEGER; >> BEGIN >> p := S.ADR(Kernel.MemLim); >> S.GET(p+8, list0); >> S.GET(p+12, list1); >> S.GET(p+16, list2); >> S.GET(p+20, list3); >> Out.Hex(list3); Out.Hex(list2); Out.Hex(list1); Out.Hex(list0); Out.Ln >> END Lists; >> >> BEGIN S.GET(12, MemLim); S.GET(24, heapOrg); heapLim := MemLim >> END Heap. >> >> Heap.Scan >> Heap.Lists >> >> >> -- >> Tomas Kral <thomas.kral@email.cz> >> -- >> Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems >> https://lists.inf.ethz.ch/mailman/listinfo/oberon > > -- > Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems > https://lists.inf.ethz.ch/mailman/listinfo/oberon > > > -- > Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems > https://lists.inf.ethz.ch/mailman/listinfo/oberon
Joerg: nice! Did you also implement #include ? It would be very useful for importing the .h files into Oberon modules. Being able to #define the constant addresses and other constants in the sysdef.h and then #include'ing it in low level modules would help to elegantly clean the mess which low level Oberon modules are right now. I am looking forward to see the implementation! Wojtek ________________________________________ From: Oberon [oberon-bounces@lists.inf.ethz.ch] on behalf of Jörg [joerg.straube@iaeth.ch] Sent: Friday, June 19, 2020 11:43 AM To: ETH Oberon and related systems Subject: [EXTERNAL] Re: [Oberon] PO2013 - Show Heap Blocks John In case you're interested, here the code: PROCEDURE printf*(s: ARRAY OF CHAR; i1, i2: INTEGER; str: ARRAY OF CHAR); (* supported format %[length]type, type = d, i, x or s, and escape characters \n, \t *) VAR n, j, len, par, x: INTEGER; ch, nxCh: CHAR; imm: BOOLEAN; BEGIN imm := immediate; immediate := FALSE; par := 1; n := 0; ch := s[0]; WHILE (ch # 0X) & (n < LEN(s)) DO j := n+1; nxCh := s[j]; IF ch = "%" THEN (* handle format *) len := 0; WHILE ("0" <= nxCh) & (nxCh <= "9") DO len := len * 10 + ORD(nxCh) - ORD("0"); INC(j); nxCh := s[j] END; IF nxCh = "s" THEN String(str); INC(j) ELSIF (nxCh # "d") & (nxCh # "i") & (nxCh # "x") THEN Char("%") ELSE x := i2; IF par = 1 THEN x := i1 END; INC(par); IF nxCh = "x" THEN Hex(x) ELSE (* i, d *) Int(x, len) END; INC(j) END ELSIF ch = "\" THEN (* handle escape characters *) IF nxCh = "n" THEN Ln; INC(j) ELSIF nxCh = "t" THEN Char(9X); INC(j) ELSE Char("\") END ELSE Char(ch) END; n := j; ch := s[n] END; immediate := imm END printf; Am 19.06.20, 17:23 schrieb "Joerg" <joerg.straube@iaeth.ch>: John Seems like variadic but it is not. printf() has fix 4 arguments as I found out that this is enough for most cases. the first is the string with formatting commands, then two INTEGERs and one string (for a filename or so) If after a % there is a number, d, h or s it’s interpreted as argument else it’s just a %. br Jörg > Am 19.06.2020 um 16:56 schrieb John R. Strohm <strohm@airmail.net>: > > Out.printf(), with VARIADIC arguments, in Oberon??? > > And that %d%) bothers me, for some reason... > > --- joerg.straube@iaeth.ch wrote: > > From: Jörg <joerg.straube@iaeth.ch> > To: ETH Oberon and related systems <oberon@lists.inf.ethz.ch> > Subject: Re: [Oberon] PO2013 - Show Heap Blocks > Date: Fri, 19 Jun 2020 10:37:08 +0200 > > Tomas > > The following line will give you the stats as well: > Out.printf(“Heap space used: %d bytes (=%d%)\n“, > Kernel.allocated, > Kernel.allocated * 100 DIV (Kernel.heapLim - Kernel.heapOrg), ““); > > That‘s basically what System.Watch does. > > br > Jörg
In Oberon you don’t need .h files nor #defines. .h and .c files are the C-way to separate imports from implementation. In Oberon, what is written in a .h file is simply marked with a *. The Oberon compiler does the rest: he generates .sym and .obj files in the background you don't have to bother. br Jörg
Am 19.06.2020 um 18:19 schrieb Skulski, Wojciech <skulski@pas.rochester.edu>:
Joerg:
nice!
Did you also implement #include ? It would be very useful for importing the .h files into Oberon modules. Being able to #define the constant addresses and other constants in the sysdef.h and then #include'ing it in low level modules would help to elegantly clean the mess which low level Oberon modules are right now.
I am looking forward to see the implementation!
Wojtek ________________________________________ From: Oberon [oberon-bounces@lists.inf.ethz.ch] on behalf of Jörg [joerg.straube@iaeth.ch] Sent: Friday, June 19, 2020 11:43 AM To: ETH Oberon and related systems Subject: [EXTERNAL] Re: [Oberon] PO2013 - Show Heap Blocks
John
In case you're interested, here the code:
PROCEDURE printf*(s: ARRAY OF CHAR; i1, i2: INTEGER; str: ARRAY OF CHAR); (* supported format %[length]type, type = d, i, x or s, and escape characters \n, \t *) VAR n, j, len, par, x: INTEGER; ch, nxCh: CHAR; imm: BOOLEAN; BEGIN imm := immediate; immediate := FALSE; par := 1; n := 0; ch := s[0]; WHILE (ch # 0X) & (n < LEN(s)) DO j := n+1; nxCh := s[j]; IF ch = "%" THEN (* handle format *) len := 0; WHILE ("0" <= nxCh) & (nxCh <= "9") DO len := len * 10 + ORD(nxCh) - ORD("0"); INC(j); nxCh := s[j] END; IF nxCh = "s" THEN String(str); INC(j) ELSIF (nxCh # "d") & (nxCh # "i") & (nxCh # "x") THEN Char("%") ELSE x := i2; IF par = 1 THEN x := i1 END; INC(par); IF nxCh = "x" THEN Hex(x) ELSE (* i, d *) Int(x, len) END; INC(j) END ELSIF ch = "\" THEN (* handle escape characters *) IF nxCh = "n" THEN Ln; INC(j) ELSIF nxCh = "t" THEN Char(9X); INC(j) ELSE Char("\") END ELSE Char(ch) END; n := j; ch := s[n] END; immediate := imm END printf;
Am 19.06.20, 17:23 schrieb "Joerg" <joerg.straube@iaeth.ch>:
John
Seems like variadic but it is not. printf() has fix 4 arguments as I found out that this is enough for most cases. the first is the string with formatting commands, then two INTEGERs and one string (for a filename or so)
If after a % there is a number, d, h or s it’s interpreted as argument else it’s just a %.
br Jörg
Am 19.06.2020 um 16:56 schrieb John R. Strohm <strohm@airmail.net>:
Out.printf(), with VARIADIC arguments, in Oberon???
And that %d%) bothers me, for some reason...
--- joerg.straube@iaeth.ch wrote:
From: Jörg <joerg.straube@iaeth.ch> To: ETH Oberon and related systems <oberon@lists.inf.ethz.ch> Subject: Re: [Oberon] PO2013 - Show Heap Blocks Date: Fri, 19 Jun 2020 10:37:08 +0200
Tomas
The following line will give you the stats as well: Out.printf(“Heap space used: %d bytes (=%d%)\n“, Kernel.allocated, Kernel.allocated * 100 DIV (Kernel.heapLim - Kernel.heapOrg), ““);
That‘s basically what System.Watch does.
br Jörg
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
It would be very useful for importing the .h files into Oberon modules. Being able to #define the constant addresses and other constants in the sysdef.h > and then #include'ing it in low level modules would help to elegantly clean the mess which low level Oberon modules are right now.
Please don't. Look how the low level modules are written in Astrobe. They are readable. For a better insight how external compilers can complicate things, join the tinygo slack channel. Better to invest time in writing a writer in Oberon than importing C. Could you give an example of the messy lowlevel modules your are mentioning? Greets, F.P. Vocnk Skulski, Wojciech schreef op 2020-06-19 18:19:
Joerg:
nice!
Did you also implement #include ? It would be very useful for importing the .h files into Oberon modules. Being able to #define the constant addresses and other constants in the sysdef.h and then #include'ing it in low level modules would help to elegantly clean the mess which low level Oberon modules are right now.
I am looking forward to see the implementation!
Wojtek ________________________________________ From: Oberon [oberon-bounces@lists.inf.ethz.ch] on behalf of Jörg [joerg.straube@iaeth.ch] Sent: Friday, June 19, 2020 11:43 AM To: ETH Oberon and related systems Subject: [EXTERNAL] Re: [Oberon] PO2013 - Show Heap Blocks
John
In case you're interested, here the code:
PROCEDURE printf*(s: ARRAY OF CHAR; i1, i2: INTEGER; str: ARRAY OF CHAR); (* supported format %[length]type, type = d, i, x or s, and escape characters \n, \t *) VAR n, j, len, par, x: INTEGER; ch, nxCh: CHAR; imm: BOOLEAN; BEGIN imm := immediate; immediate := FALSE; par := 1; n := 0; ch := s[0]; WHILE (ch # 0X) & (n < LEN(s)) DO j := n+1; nxCh := s[j]; IF ch = "%" THEN (* handle format *) len := 0; WHILE ("0" <= nxCh) & (nxCh <= "9") DO len := len * 10 + ORD(nxCh) - ORD("0"); INC(j); nxCh := s[j] END; IF nxCh = "s" THEN String(str); INC(j) ELSIF (nxCh # "d") & (nxCh # "i") & (nxCh # "x") THEN Char("%") ELSE x := i2; IF par = 1 THEN x := i1 END; INC(par); IF nxCh = "x" THEN Hex(x) ELSE (* i, d *) Int(x, len) END; INC(j) END ELSIF ch = "\" THEN (* handle escape characters *) IF nxCh = "n" THEN Ln; INC(j) ELSIF nxCh = "t" THEN Char(9X); INC(j) ELSE Char("\") END ELSE Char(ch) END; n := j; ch := s[n] END; immediate := imm END printf;
Am 19.06.20, 17:23 schrieb "Joerg" <joerg.straube@iaeth.ch>:
John
Seems like variadic but it is not. printf() has fix 4 arguments as I found out that this is enough for most cases. the first is the string with formatting commands, then two INTEGERs and one string (for a filename or so)
If after a % there is a number, d, h or s it’s interpreted as argument else it’s just a %.
br Jörg
> Am 19.06.2020 um 16:56 schrieb John R. Strohm <strohm@airmail.net>: > > Out.printf(), with VARIADIC arguments, in Oberon??? > > And that %d%) bothers me, for some reason... > > --- joerg.straube@iaeth.ch wrote: > > From: Jörg <joerg.straube@iaeth.ch> > To: ETH Oberon and related systems <oberon@lists.inf.ethz.ch> > Subject: Re: [Oberon] PO2013 - Show Heap Blocks > Date: Fri, 19 Jun 2020 10:37:08 +0200 > > Tomas > > The following line will give you the stats as well: > Out.printf(“Heap space used: %d bytes (=%d%)\n“, > Kernel.allocated, > Kernel.allocated * 100 DIV (Kernel.heapLim - Kernel.heapOrg), ““); > > That‘s basically what System.Watch does. > > br > Jörg
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
Peter:
Please don't. My proposition was a tongue in cheek. But the goals/motivation are serious. While everyone seems to agree that it would be good to have a clean code base, then everyone is also unwilling to touch upon the 2013 Oberon System sources. It is a chicken and egg problem. This particular egg cannot hatch a strong and healthy chick. But it cannot get improved either for some strange reason.
Look how the low level modules are written in Astrobe. They are readable. Astrobe is different by design, thank goodness.
Better to invest time in writing a writer in Oberon than importing C. Importing C was a little joke.
Could you give an example of the messy lowlevel modules your are mentioning?
I will e-mail you a detailed account to your private e-mail, since the list is hesitant of attachments. Half joking I have proposed the Hercules project to maybe help a little bit. Here is the description from my web page. ------------------------- Hercules: The Oberon Source Code Cleaner and Sanitizer Synopsis. Any software system can benefit from following programming rules, such as neat formatting, consistent naming conventions, avoidance of tricky uncommented code, informative comments, and avoiding numerical constants written directly into the source code. In the C world the programming rules are routinely enforced by both the development tools and by the elders of the tribe, to a great benefit of the C community. I can only wish that the same was true with Oberon. Hercules is the name of the proposed automatic cleanup tool to help achieve better code quality. It will be an Oberon module which will take some other module, factor out all the verbatim numerical constants, and replace them with symbolic names. The list of both the names and their numerical values will be named SysDef.Mod. Such a definition module, whose goal is similar to a C header file, will become a part of the Oberon System interface definition. Its main role will be factoring out hardware, firmware, and software interface addresses, which are holding values such as display resolution, refresh rate, serial link speed, etc. We can start with a single such definition module. At present, the FPGA Oberon System is simple enough that one file will be sufficient. More such definition modules can be introduced in the future, factoring out interfaces of various hardware or firmware subsystems. Hercules will act as a prefilter. As soon as a new or a modified Oberon source gets published on the web, we will be able to apply Hercules to it and then adopt the cleaned up code. Since this issue persists for the whole Oberon history, this tool may also be named Sisyphus. I am not yet sure which name is better. It is much needed anyway.
Wojtek An approach with one file - although the intention is good - is NOT good. In big contrast to C includes (.h files) - where your idea might stem from - compiled Oberon modules have strongly enforced version keys. The consequence of having ONE file, is, whenever you add some new constant to it, you have to recompile ALL sources, link the inner core, basically re-build the whole Oberon system, only because you added eg LF* = 0AX to your constant collection. Such an approach destroys the whole Oberon idea of separate compilation. Whenever the constants are so important that you want to export them, you anyhow have to give them a name. When the constants are internal to a module, you might name them or you might not. Because it‘s internal the scope and meaning of this constant is very local and not of importance to the rest of the system. Your base idea is okay, but please not in ONE file. Group the constants by area. Eg move all ASCII constants to Input.Mod. It is really strange that all modules working with ASCII redefine the constants over and over again instead of just importing them from one central place namely, Input.Mod (I did that and defined also ASCII codes of the arrow keys, I can move the caret with the keys and not only the mouse) Group all memory related constants to Kernel.Mod, group all your file system related constants to Files.Mod, group all your timer related functions to either Kernel.Mod or write a new module Timer.Mod. But please don‘t use ONE file, where all your constants are in. I grouped all Wiznet related constants to W5500.Mod, I grouped all IP related constants in IP.Mod and so on. And if you need them you just write IMPORT Kernel, W5500, IP; and use them IP.AnyPort or W5500.InterruptMask... br Jörg
Am 19.06.2020 um 22:18 schrieb Skulski, Wojciech <skulski@pas.rochester.edu>:
Peter:
Please don't. My proposition was a tongue in cheek. But the goals/motivation are serious. While everyone seems to agree that it would be good to have a clean code base, then everyone is also unwilling to touch upon the 2013 Oberon System sources. It is a chicken and egg problem. This particular egg cannot hatch a strong and healthy chick. But it cannot get improved either for some strange reason.
Look how the low level modules are written in Astrobe. They are readable. Astrobe is different by design, thank goodness.
Better to invest time in writing a writer in Oberon than importing C. Importing C was a little joke.
Could you give an example of the messy lowlevel modules your are mentioning?
I will e-mail you a detailed account to your private e-mail, since the list is hesitant of attachments.
Half joking I have proposed the Hercules project to maybe help a little bit. Here is the description from my web page.
------------------------- Hercules: The Oberon Source Code Cleaner and Sanitizer
Synopsis. Any software system can benefit from following programming rules, such as neat formatting, consistent naming conventions, avoidance of tricky uncommented code, informative comments, and avoiding numerical constants written directly into the source code. In the C world the programming rules are routinely enforced by both the development tools and by the elders of the tribe, to a great benefit of the C community. I can only wish that the same was true with Oberon.
Hercules is the name of the proposed automatic cleanup tool to help achieve better code quality. It will be an Oberon module which will take some other module, factor out all the verbatim numerical constants, and replace them with symbolic names. The list of both the names and their numerical values will be named SysDef.Mod. Such a definition module, whose goal is similar to a C header file, will become a part of the Oberon System interface definition. Its main role will be factoring out hardware, firmware, and software interface addresses, which are holding values such as display resolution, refresh rate, serial link speed, etc. We can start with a single such definition module. At present, the FPGA Oberon System is simple enough that one file will be sufficient. More such definition modules can be introduced in the future, factoring out interfaces of various hardware or firmware subsystems.
Hercules will act as a prefilter. As soon as a new or a modified Oberon source gets published on the web, we will be able to apply Hercules to it and then adopt the cleaned up code. Since this issue persists for the whole Oberon history, this tool may also be named Sisyphus. I am not yet sure which name is better. It is much needed anyway. -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
-----Original Message----- From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of Jörg Sent: Saturday, 20 June 2020 6:35 AM To: ETH Oberon and related systems Subject: Re: [Oberon] Cleaning up low level modules (a pipe dream)
Your base idea is okay, but please not in ONE file. Group the constants by area. Eg move all ASCII constants to Input.Mod. It is really strange that all modules working with ASCII redefine the constants over and over again instead of just importing them from one central place namely, Input.Mod (I did that and defined also ASCII codes of the arrow keys, I can move the caret with the keys and not only the mouse)
Good idea. However, it would seem strange to me to have to IMPORT Input.Mod into Output.Mod, say, just to be able to access the ASCII constants. Is there any good reason not to have a common file e.g. ASCII.Mod which contains just the ASCII constants. ASCII is then imported into Input and Output and anything else that needs to access them? One possible reason might be that the keycodes you mention, say, are only relevant to Input so why import them into Output as well? If this were an issue it might be preferable to have another common file e.g. Keys.Mod and only have the actual codes from the ASCII table in ASCII.Mod. This is nothing new. The time spent trying to dream up 'new ideas' might be better spent studying history. So many of these sorts of problems were identified and solved many years ago. I just had a look in my Logitech Modula-2/86 Users Guide dated December 1984 and, what do you know, that has an ASCII module. There is no excuse not to try to learn from the lessons of the past now that so much of it is documented and available on the Internet. For example, a later version of the Logitech manual I am talking about can be downloaded from: http://bitsavers.trailing-edge.com/pdf/logitech/modula-2/Modula-2_86_Ver_2.0... Regards, Chris Chris Burrows CFB Software http://www.astrobe.com/RISC5
You‘re right ASCII.Mod is a valid place. As Input.Mod is part of the outer core and hence is already in memory anyhow, I didn‘t want to create a new file. But most probably, I extend the outer core by the ASCII module. Jörg
Am 19.06.2020 um 23:43 schrieb Chris Burrows <chris@cfbsoftware.com>:
-----Original Message----- From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of Jörg Sent: Saturday, 20 June 2020 6:35 AM To: ETH Oberon and related systems Subject: Re: [Oberon] Cleaning up low level modules (a pipe dream)
Your base idea is okay, but please not in ONE file. Group the constants by area. Eg move all ASCII constants to Input.Mod. It is really strange that all modules working with ASCII redefine the constants over and over again instead of just importing them from one central place namely, Input.Mod (I did that and defined also ASCII codes of the arrow keys, I can move the caret with the keys and not only the mouse)
Good idea. However, it would seem strange to me to have to IMPORT Input.Mod into Output.Mod, say, just to be able to access the ASCII constants. Is there any good reason not to have a common file e.g. ASCII.Mod which contains just the ASCII constants. ASCII is then imported into Input and Output and anything else that needs to access them?
One possible reason might be that the keycodes you mention, say, are only relevant to Input so why import them into Output as well? If this were an issue it might be preferable to have another common file e.g. Keys.Mod and only have the actual codes from the ASCII table in ASCII.Mod.
This is nothing new. The time spent trying to dream up 'new ideas' might be better spent studying history. So many of these sorts of problems were identified and solved many years ago. I just had a look in my Logitech Modula-2/86 Users Guide dated December 1984 and, what do you know, that has an ASCII module.
There is no excuse not to try to learn from the lessons of the past now that so much of it is documented and available on the Internet. For example, a later version of the Logitech manual I am talking about can be downloaded from:
http://bitsavers.trailing-edge.com/pdf/logitech/modula-2/Modula-2_86_Ver_2.0...
Regards, Chris
Chris Burrows CFB Software http://www.astrobe.com/RISC5
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
It's very early in the morning here. I'm hoping that I'm still asleep and just having a nightmare ;-) Chris Burrows CFB Software http://www.astrobe.com/RISC5
-----Original Message----- From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of Joerg Sent: Saturday, 20 June 2020 12:53 AM To: ETH Oberon and related systems Subject: Re: [Oberon] PO2013 - Show Heap Blocks
John
Seems like variadic but it is not. printf() has fix 4 arguments as I found out that this is enough for most cases. the first is the string with formatting commands, then two INTEGERs and one string (for a filename or so)
If after a % there is a number, d, h or s it s interpreted as argument else it s just a %.
br J rg
Am 19.06.2020 um 16:56 schrieb John R. Strohm <strohm@airmail.net>:
?Out.printf(), with VARIADIC arguments, in Oberon???
And that %d%) bothers me, for some reason...
--- joerg.straube@iaeth.ch wrote:
From: J rg <joerg.straube@iaeth.ch> To: ETH Oberon and related systems <oberon@lists.inf.ethz.ch> Subject: Re: [Oberon] PO2013 - Show Heap Blocks Date: Fri, 19 Jun 2020 10:37:08 +0200
Tomas
The following line will give you the stats as well: Out.printf( Heap space used: %d bytes (=%d%)\n , Kernel.allocated, Kernel.allocated * 100 DIV (Kernel.heapLim - Kernel.heapOrg), );
That s basically what System.Watch does.
br J rg
Am 19.06.2020 um 10:12 schrieb Tomas Kral <thomas.kral@email.cz>:
?Hi,
This is my understanding so far, it stats the heap. It also shows free block last to the limit, because heap ends 16 bytes earlier, so is not MOD 32.
MODULE Heap; (*TK 14.6.2020 show heap blocks*) IMPORT S := SYSTEM, Kernel, Out;
VAR heapOrg, MemLim, heapLim: INTEGER;
PROCEDURE Scan*; VAR p, q, mark, tag, size, used, free: LONGINT; BEGIN p := heapOrg; used := 0; free := 0; Out.Hex(heapOrg); Out.Ln; (*60000H 4-bit colour display*) Out.Hex(heapLim); Out.Ln; (*9FEF0H*) REPEAT S.GET(p+4, mark); q := p; (*mark: 0 used, -1 freed, >0 marked*) IF mark = -1 THEN S.GET(p, size) ELSE S.GET(p, tag); S.GET(tag, size); (*size := p - q*) END ; IF (size MOD 32 # 0) & (size MOD 64 # 0) & (size MOD 128 # 0) & (size MOD 256 # 0) THEN Out.Hex(p); Out.Hex(size); Out.Hex(mark); Out.Ln (*free block to 9FEF0H*) END ; IF mark > 0 THEN INC(used, size) (*none after kernel scan*) ELSIF mark = 0 THEN INC(used, size) ELSIF mark = -1 THEN INC(free, size) END ; INC(p, size) UNTIL p >= heapLim(*-30000H*) ; Out.Int(used, 8); (*value*) Out.Int(used*100 DIV free, 3); (*percentage*) Out.Hex(free+used); Out.Ln (*3FEF0 = 9FEF0H-60000H, or less if fragmented*) END Scan;
PROCEDURE Lists*; VAR p, list0, list1, list2, list3: INTEGER; BEGIN p := S.ADR(Kernel.MemLim); S.GET(p+8, list0); S.GET(p+12, list1); S.GET(p+16, list2); S.GET(p+20, list3); Out.Hex(list3); Out.Hex(list2); Out.Hex(list1); Out.Hex(list0); Out.Ln END Lists;
BEGIN S.GET(12, MemLim); S.GET(24, heapOrg); heapLim := MemLim END Heap.
Heap.Scan Heap.Lists
-- Tomas Kral <thomas.kral@email.cz> -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
participants (7)
-
Chris Burrows -
Frans-Pieter Vonck -
Joerg -
John R. Strohm -
JR -
Jörg -
Skulski, Wojciech