[Oberon] ORX.WriteFile

Chris Burrows chris at cfbsoftware.com
Thu Oct 17 22:12:10 CEST 2019


> -----Original Message-----
> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of
> Andreas Pirklbauer
> Sent: Friday, 18 October 2019 5:00 AM
> To: ETH Oberon and related systems
> Subject: [Oberon] ORX.WriteFile
> 
>     > There sure are loads of ways! The approach we used with Astrobe
> was to
>     > modify ORG so it always outputs a .mem text file directly from
> the code
>     > array if a Module* is being compiled:
>     >
>     > IF version = 0 THEN WriteHexFile(modid) END
>     >
>     > Regards,
>     > Chris Burrows
> 
> 
> Good idea! Below is one possible implementation of such an ORG.Close
> (and the diff), in case someone is interested. One could also add an
> option /m to ORP.Compile if one really wanted to.
> -ap
> 
> 

I used a different approach and isolated the additional code to a separate
procedure ORG.WriteHexFile. Easy to do as the global 'code' array contains
all the data you need:

  PROCEDURE WriteHexFile(VAR modid: ORS.Ident);
  VAR 
    name: ORS.Ident;
    i, fileSize: INTEGER;
    F: Files.File; R: Files.Rider;
  BEGIN
    ORB.MakeFileName(name, modid, ".mem"); (*write hex prom code file*)
    F := Files.New(name); Files.Set(R, F, 0);
    fileSize := ((pc DIV 512) + 1) * 512;
    FOR i := 0 TO pc - 1 DO
      WriteHex(R, code[i])
    END;
    FOR i := pc TO fileSize - 1 DO 
      WriteHex(R, 0)
    END;
    Files.Register(F);  
  END WriteHexFile;

Regards,
Chris




More information about the Oberon mailing list