Q. How can I use shared libraries from x86m2?
Q. How can I use libvga from x86m2?
Q. How can I get better optimization when compiling withx86m2?
Q. How do I enable pentium U/V slot optimization?
Q. How can I get even better optimization when compiling?

Q. How can I use shared libraries from x86m2?

A. Probably best to use GNU Modula-2 which works well with shared libraries. For example using gm2 you can convert Modula-2 modules into python modules fairly easily.


Q. How can I use libvga from x86m2?

A. Here is a copy of libvga.def

DEFINITION MODULE libvga ;

(*
    Title      : libvga
    Description: Provides a Modula-2 interface to the GNU/Linux vga C
                 user library. This definition module only provides basic
                 primitives.
*)

EXPORT UNQUALIFIED GraphicsMode,
                   vga_setmode, vga_hasmode,
                   vga_clear, vga_flip,
                   vga_getxdim, vga_getydim,
                   vga_screenon, vga_screenoff,
                   vga_getpixel, vga_drawpixel, vga_drawline, vga_setcolor,
                   vga_getch ;

TYPE
   GraphicsMode = (Text,
                   G320x200x16,
                   G640x200x16,
                   G640x350x16,
                   G640x480x16,
                   G320x200x256,
                   G320x240x256,
                   G320x400x256,
                   G360x480x256,
                   G640x480x2,
                   G640x480x256,
                   G800x600x256,
                   G1024x768x256,
                   G640x480x32K,
                   G640x480x64K,
                   G800x600x32K,
                   G800x600x64K,
                   G1024x768x32K,
                   G1024x768x64K,
                   G640x480x16M,
                   G800x600x16M,
                   G1024x768x16M,
                   G320x200x32K,
                   G320x200x64K,
                   G320x200x16M) ;


PROCEDURE vga_setmode (m: GraphicsMode) ;
PROCEDURE vga_hasmode (m: GraphicsMode) : BOOLEAN ;
PROCEDURE vga_clear ;
PROCEDURE vga_flip ;
PROCEDURE vga_getxdim () : CARDINAL ;
PROCEDURE vga_getydim () : CARDINAL ;
PROCEDURE vga_screenon ;
PROCEDURE vga_screenoff ;
PROCEDURE vga_getpixel (x, y: CARDINAL) : CARDINAL ;
PROCEDURE vga_drawpixel (x, y: CARDINAL) ;
PROCEDURE vga_drawline (x1, y1, x2, y2: CARDINAL) ;
PROCEDURE vga_setcolor (colour: CARDINAL) ;
PROCEDURE vga_getch () : CHAR ;

END libvga.

our test program follows:

MODULE gtest ;

IMPORT StdIO ;
FROM libvga IMPORT GraphicsMode,
                    vga_setmode, vga_clear, vga_screenon, vga_screenoff, vga_drawline,
                    vga_getxdim, vga_getydim, vga_getch ;


VAR
   ch: CHAR ;
BEGIN
   vga_setmode(G320x200x16) ;
   vga_screenoff ;
   vga_drawline(1, 1, vga_getxdim(), 1);
   vga_drawline(vga_getxdim(), 1, vga_getxdim(), vga_getydim());
   vga_screenon ;
   ch := vga_getch() ;
   vga_setmode(Text)
END gtest.

we compile gtest.mod via:

x86m2 -g gtest
x86m2 -o gtest -M "/usr/share/x86m2/libs /usr/lib ." -g -l -lm gtest

note that you will need x86m2-4.3 (which is currently not formally released, but if you are desperate you can check out the GNUModula2.html#GM2 development download via CVS).

Note that the module you are linking must be the final argument to x86m2.


Q. How can I get better optimization when compiling withx86m2?

A. Use the -O -Odynamic flag
If that is not good enough see below


Q. How do I enable pentium U/V slot optimization?

try: -O -Odynamic -Oi586 -O2 for pentium I
try: -O -Odynamic -Oi686 -O2 for pentium II
If this is still not good enough try increasing -O2 to -O3 to -O4 etc (though this will cause compile time to rise).

Note that the line number debugging information produced by -g might not be correct as instruction sequences are reordered.


Q. How can I get even better optimization when compiling?

A. it might be worth examining gm2 which uses the x86m2 front end and the gcc back end.