Menu

minimal GnuCOBOL configuration to start with using a C85 compiler for a small environment

2023-06-01
2023-10-13
  • Michael Sommer

    Michael Sommer - 2023-06-01

    OK.

    I now this is a unusual request, but I would like to run COBOL on a Micro Controller. The controller I have in mind does provide a C compiler based on LCC, as far as I understand C85.

    I do not want to compile on the MC, just run Programs.

    So all those nifty things like ncurses, BDB and such are out of question. I need to go as bare as GnuCOBOL could get.

    How would I start to compile a Program on windows and keep the C sources to figure out how to compile them for my target?

    please advice,

    Mike

     
    • Mickey White

      Mickey White - 2023-06-02

      compile options are your friend.

      -C translation only; convert COBOL to C 
      
      --save-temps[=<dir>] save intermediate files
             * default: current directory
      
       
    • Mickey White

      Mickey White - 2023-06-02

      The save all temps option would be best:

      D:\Old Hard Drive\Documents\Computer Stuff\TEMPS>cobc -x --save-temps call2ae.cbl
      
      D:\Old Hard Drive\Documents\Computer Stuff\TEMPS>ls -lrt | tail -10
      -rw-r--r-- 1 19012 19012        2494 Jun  1 19:44 call2ae.i
      -rw-r--r-- 1 19012 19012        1707 Jun  1 19:44 call2ae.c.l.h
      -rw-r--r-- 1 19012 19012         816 Jun  1 19:44 call2ae.c.h
      -rw-r--r-- 1 19012 19012        9851 Jun  1 19:44 call2ae.c
      -rw-r--r-- 1 19012 19012        7520 Jun  1 19:44 call2ae.o
      -rwxr-xr-x 1 19012 19012       54881 Jun  1 19:44 call2ae.exe
      
      D:\Old Hard Drive\Documents\Computer Stuff\TEMPS>
      
       

      Last edit: Mickey White 2023-06-02
    • Simon Sobisch

      Simon Sobisch - 2023-06-02

      The first thing you have to do is: get a cross compiler that compiles for this target.
      The second thing would be to get GMP for the micro controller, preferably pre-built, otherwise cross-compiled yourself. The last thing would be to generate a libcob by cross-compile.

      Once this runs on the controller, the rest is easy.

       

      Last edit: Simon Sobisch 2023-10-13
    • Simon Sobisch

      Simon Sobisch - 2023-06-02

      So do you have a "Windows to MC" cross-compiler ready?

      If not and it isn't readily available it will likely easier to setup WSL and use a cross-compiler there.
      In any case the MC would need to have at least a 32bit C library (or be able to use a static linked one into libcob).

      As you've mentioned - there is commonly no need to compile on the MC, but if you want to run it there you either have to get a working libgmp to be used by libcob or adjust GnuCOBOL to not use GMP (possible if for example you adjust it to do everything in PACKED-DECIMAL/native integer - which will limit the number of digits to 38/19, it likely would be most reasonable to just abort where GMP is used, then hack libcob to do the pieces you need, step by step]).

       
  • Michael Sommer

    Michael Sommer - 2023-06-03

    sadly this is a quite new MC so neither GCC or GMP is available. Libc is supported as of C85.

    So the only way I see is static linking anyways, this will be a interesting excurse

    Mike

     
    • Simon Sobisch

      Simon Sobisch - 2023-06-03

      As everything is wrapped within libcob you "only" would need to create that, linking in a static libc and libgmp.
      The first big issue is to get the necessary C cross compiler working, the second one is to use that for creating a static libgmp for that target.

       
    • Simon Sobisch

      Simon Sobisch - 2023-10-13

      Four months are "quite some time" for IT, so @msrobots:
      * Is there a C compiler, possibly GCC running on that controller?
      * Is there a prebuilt GMP available, if not can you compile that on the controller using the available C compiler?
      * Any progress/plans with this project?

       

Anonymous
Anonymous

Add attachments
Cancel