[Oberon] FPGA - Bitmaps.Mod optimising

Tomas Kral thomas.kral at email.cz
Mon Sep 18 20:43:24 CEST 2017


I am thinking how to optimise this code snippet that is very frequent
in the bitmap module and its occurrences differ only in the set
operator used.

SYSTEM.GET(dst, pix);
SYSTEM.PUT(dst, SYSTEM.VAL(SET, LSL(wd, x MOD 32)) + pix);

IF x MOD 32 > 0 THEN
  SYSTEM.GET(dst+4, pix); wd := ASR(wd, -(x MOD 32));
  SYSTEM.PUT(dst+4, SYSTEM.VAL(SET, wd)*{0..x MOD 32-1} + pix)

I coded this procedure, unsure if efficient or optimal, certainly not
faster than inline code snippet above. Hopefully will at least produce
shorter code.  

(* Read two pix sets, shift & clip them according to x coordinate and w
width *)

PROCEDURE Read2Pix(x: INTEGER; VAR w, src: INTEGER; VAR pix1, pix2:
SET); VAR x0, w0: INTEGER;
  (* (pix * {maskleft*8..31} * {0..maskright*8-1}) *)

  w0 :=  w MOD 32; x0 := x MOD 32;

  SYSTEM.GET(src, pix2); INC(src, 4); DEC(w, 32);
  IF w < 0 THEN pix2 := pix2*{0..w0} END;
  pix1 := LSL(pix2, x0);
  IF x0 > 0 THEN pix2 := ASR(pix2, -x0)*{0..x0-1}
  ELSE pix2 := {}

END Read2Pix;

I have discovered I could perform shift operations on sets
directly without type conversion to INTEGER. Is it correct?

Tomas Kral <thomas.kral at email.cz>

More information about the Oberon mailing list