Re. [Oberon] http://www.oberon.ethz.ch/display.html

cglur at onwe.co.za cglur at onwe.co.za
Sat Jul 13 22:32:45 CEST 2002


Peter Easthope wrote:
> In http://www.oberon.ethz.ch/display.html
> I studied the description of SwitchTrident9xxx
> but still do not understand.  
> What exactly is the purpose of this procedure?
> What is accomplished in each of the three 
> statements? 
PROCEDURE SwitchTrident9xxx(bank: LONGINT);
BEGIN

>    curBank := bank; 
>    SYSTEM.PORTOUT(3D8H, CHR(bank)); 
>    SYSTEM.PORTOUT(3D9H, CHR(bank)) 
END SwitchTrident9xxx;

It is near impossible to analyse 'bottom up'.

If your 'given result' is 7 and known to be the sum of 2 natural numbers,
then there are several posibilities.   Working in the other direction:
given 3 plus 4 has a single answer.

So working in the one 'direction' give you a one-to-many descision
at each descision point; and in the opposite direction you usually have
a single reason at each 'point'.

As you know:
curBank := bank; assigns the LONGINT sized value, 'bank', to the
non local variable 'curBank'.   More than this you can't be sure of.
(was it 1+6 or 5+2 ?)

SYSTEM.PORTOUT(3D8H, CHR(bank));  I guess would mean:
 write the 8 least significant bits { using the CHR type/size conversion}
 of  bank to the device/register that has address 3D8H.

The hardware is such that the 3D8H and 3D9H hardware devices
have 8 bit inputs (which the CPU will output to), but the procedure's
argument is of size LONGINT (? 64 bits I guess), for reasons which you can't
know from the information available here.
SYSTEM.PORTOUT's 2nd argument apparently must be type CHR.
Hence the type conversion, to not have a syntax error.

As said the way to analyse is to 'know the "destination" first, and
then work towards it', rather than observing the ant walking and
trying to guess where he plans to go !!

So if you start from eg:
 set the BankSelectRegister to Bank;
 set the SpeedSelectRegister to Minimum;
  read the StatusRegister .... etc,
then it's easier (than trying reverse engineering) to translate this to:

  SYSTEM.PORTOUT(BankSelectRegister, CHR(bank));
  SYSTEM.PORTOUT(SpeedSelectRegister, Minimum);
  SYSTEM.PORTIN(StatusRegister, StatusByte);


-- Chris Glur.





More information about the Oberon mailing list