[Oberon] Communicating with aliens

Joerg joerg.straube at iaeth.ch
Tue Jan 12 11:31:53 CET 2016


Hi Chris, Paul

Good you mention the topic „errors". Here some errors I found and improvements I did to Project Oberon

1) Here my improved version of the procedure „opcode" in the disassembler „ORTool“:

PROCEDURE opcode(w: LONGINT);
	VAR k, u, v, a, b, op: LONGINT;
	BEGIN
		k :=  w DIV 40000000H MOD 4;
		u :=  w DIV 20000000H MOD 2;
		v :=  w DIV 10000000H MOD 2;
		a :=  w DIV   1000000H MOD 10H;
		b :=  w DIV     100000H MOD 10H;
		op := w DIV      10000H MOD 10H;
		IF (k = 0) OR (k = 1) THEN
				Texts.WriteString(W, mnemo0[op]);
				IF u = 1 THEN Texts.Write(W, "'") END ;
				WriteReg(a);
				IF op = 0 THEN Texts.WriteString(W, "      ") ELSE WriteReg(b) END;       (* jr: MOV has no reg b *)
				IF k = 0 THEN WriteReg(w MOD 10H)
				ELSE
					w := w MOD 10000H; IF v = 1 THEN DEC(w, 10000H) END ;                (* jr: signed/unsigend handling *)
					Texts.WriteInt(W, w, 7)
				END
		ELSIF k = 2 THEN	(*LDR/STR*)
				IF u = 1 THEN Texts.WriteString(W, "ST") ELSE Texts.WriteString(W, "LD") END ;
				IF v = 1 THEN Texts.Write(W, "B") ELSE Texts.Write(W, "W") END;         (* jr: display Byte and Word access *)
				WriteReg(a); WriteReg(b);
				(* compiler assumes SIGNED offset. RISC5 extends "off" UNSIGNED to 24bit. Okay as memadr only uses 20 bit *)
				w := w MOD 100000H; IF w >= 80000H THEN DEC(w, 100000H) END;
				Texts.WriteInt(W, w, 8)
		ELSE	(*Branch instr*)
				Texts.Write(W, "B");
				IF v = 1 THEN Texts.Write(W, "L") END ;
				Texts.WriteString(W, mnemo1[a]);
				IF u = 0 THEN WriteReg(w MOD 10H)
				ELSE
					(* compiler assumes SIGNED offset. With memory < 1MB and word offset, even w modulo 18 bit would be okay *)
					w := w MOD 100000H;
					IF w >= 80000H THEN DEC(w, 100000H) END ;
					Texts.WriteInt(W, w, 8)
				END
		END
	END opcode;

- the signed/unsigned handling of immediate values in case 0 and 1 was wrong.
- I added the distinction of word/byte access in case 2. The opcodes are no longer LDR/STR but LDW/STW and LDB/STB.
- cosmetic: I skipped display of reg B on MOV as it’s not used.


2) As Project Oberon is running on several platforms now (FPGA, Windows, MacOS), it is a little unfortunate that Project Oberon has no standardized definitions of the key codes for the up, left, right and down keys. As I like to move around the caret with my keyboard instead of the mouse I ended up with there different versions (one per platform) of procedure Write in „TextFrames.Mod“
As example, here the version of the procedure Write in TextFrames.Mod for the MacOS X emulator.

PROCEDURE Write* (F: Frame; ch: CHAR; fnt: Fonts.Font; col, voff: INTEGER);
		VAR buf: Texts.Buffer;
	BEGIN (*F.hasCar*)
		IF ch = BS THEN	(*backspace*)
			IF F.carloc.pos > F.org THEN
				Texts.Delete(F.text, F.carloc.pos - 1, F.carloc.pos, DelBuf); SetCaret(F, F.carloc.pos - 1)
			END
		ELSIF ch = 3X THEN (*!c	copy*)
			IF F.hasSel THEN
				NEW(TBuf); Texts.OpenBuf(TBuf); Texts.Save(F.text, F.selbeg.pos, F.selend.pos, TBuf)
			END
		ELSIF ch = 16X THEN (*!v	paste*)
			NEW(buf); Texts.OpenBuf(buf); Texts.Copy(TBuf, buf); Texts.Insert(F.text, F.carloc.pos, buf);
			SetCaret(F, F.carloc.pos + buf.len)
		ELSIF ch = 18X THEN (*!x,	cut*)
			IF F.hasSel THEN
				NEW(TBuf); Texts.OpenBuf(TBuf); Texts.Delete(F.text, F.selbeg.pos, F.selend.pos, TBuf)
			END
		ELSIF ch = 11X THEN (* left *)
			IF F.carloc.pos > 0 THEN RemoveCaret(F); SetCaret(F, F.carloc.pos - 1) END
		ELSIF ch = 12X THEN (* right *)
			IF F.carloc.pos < F.text.len THEN RemoveCaret(F); SetCaret(F, F.carloc.pos + 1) END
		ELSIF ch = 13X THEN (* up *)
			RemoveCaret(F); SetCaret(F, Pos(F, F.X + F.carloc.x, F.Y + F.carloc.y + F.lsp))
		ELSIF ch = 14X THEN (* down *)
			RemoveCaret(F); SetCaret(F, Pos(F, F.X + F.carloc.x, F.Y + F.carloc.y - F.lsp))
		ELSIF (20X <= ch) & (ch <= DEL) OR (ch = CR) OR (ch = TAB) THEN
			KW.fnt := fnt; KW.col := col; KW.voff := voff; Texts.Write(KW, ch);
			Texts.Insert(F.text, F.carloc.pos, KW.buf);
			SetCaret(F, F.carloc.pos + 1)
		END
	END Write;

- As improvement, I see two possible solutions to this
  1) In the original Input.Mod there is an array for key code mapping. Define this as THE mapping all emulators have to follow it in their underlying keyboard routines.
  2) add constant definitions in Input.Mod (either fix or varying per platform) for the control keys BS / LF / DEL / CR / TAB / HT / ESC / Setstar / up / down / leftt / right. These constants could then be used in upper layer modules like TextFrames.Mod, Oberon.Mod or ORS.Mod
 I personally would prefer 2)

br
Jörg

> Am 12.01.2016 um 09:02 schrieb Chris Burrows <chris at cfbsoftware.com>:
> 
>> He releases a compiler and doesn't offer an error reporting system. 
> 
> Personally I prefer Wirth spends his time working on what he is good at i.e.
> developing the compiler, Verilog sources and Lola and let others like myself
> who are not so skilled in those areas to look after handling error reports,
> support issues etc. 
> 
> It is immportant to note that the well-documented, high quality, Project
> Oberon system is not your typical type of open source system. Unfortunately
> all too often all you get is pre-alpha quality source code that the
> developer (or more accurately 'hacker' - in the traditional sense of the
> word) cannot be bothered to test or document. Given the choice of the
> Cathedral or the Bizarre (sic) I'd go for the Cathedral approach any day.
> 
> In my experience in the last eight years of working with Wirth's Oberon-07
> compilers bugs are as scarce as hen's teeth. I have always found him (and
> Paul) to be very communicative and generous with their time whenever I have
> contacted them. 
> 
> However, in the unlikely event that you think you have discovered a bug and
> you prefer to use a different form of communication than email you are
> welcome to report it on the Astrobe forum and I'll see what I can do to
> help:
> 
> http://www.astrobe.com/forum/viewtopic.php?f=5&t=452
> 
> The last reported (and fixed) bug in our Cortex-M3/M4 Oberon-07 compilers
> was in June last year. As far as I remember only three bugs have been
> reported in this ETH mailing list since Project Oberon was released a couple
> of years ago and they have all since been fixed. Hence it would be difficult
> to justify the use of a formalised bug-reporting system. Chances are that
> such a system would be more complex than Project Oberon!
> 
> There is no comparison between Oberon and Delphi when it comes to quality. I
> have been using Delphi since v1.0 in Feb 199S. The initial release was very
> good but went rapidly downhill from about v4 onwards. Since then Delphi
> typically has had something like 500 bugs active at any one time so Borland
> / CodeGear / Embarcadero / Idera would not be able to manage them without a
> formalised system, 
> 
> Regards,
> Chris Burrows 
> 
> CFB Software
> http://www.astrobe.com
> 
> 
> 
> 
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20160112/96025895/attachment.html>


More information about the Oberon mailing list