Translations of the current page:
MI (i5/OS Machine Interface) is a logical layer between i5/OS applications and the Licensed Internal Code (LIC) layer. The MI has two variats that share many common characteristics but take different approaches: the original MI (OMI) and the new MI (NMI). Here the term MI we refer to is the OMI.
What EMI (Extended i5/OS Machine Interface Language) is, and what EMI is not
Contents
To install MIC please refer to the readme file in the downloaded release package.
entry hello-main ext ; dcl sysptr pgm-world auto init("WORLD", type(pgm)) ; dcl dd msg char(32) auto ; dcl dd len bin(4) auto ; dcl spcptr msg-ptr auto init(msg) ; dcl ol argl-world(msg-ptr) arg ; brk 'INIT' ; cpyblap msg, 'Hello, ', ' ' ; addspp msg-ptr, msg-ptr, 7 ; callx pgm-world, argl-world, * ; brk 'SEND_MSG' ; triml len, msg, ' ' ; %sendmsg(msg, len) ; brk 'END' ; rtx * ; pend; /* eof - hello.mi */
dcl spcptr .world parm ; dcl ol pl-world(.world) parm ext ; entry * ext ; dcl dd world char(8) bas(.world) ; dcl dd words(0:3) char(8) init( *(0)'ILE RPG', 'COBOL', 'Java', 'MI' ) ; dcl dd buf char(8) auto ; dcl dd i bin(2) unsgnd def(buf) pos(7) ; matmdata buf, x'0000' ; div(s) i, 16384 ; cpyblap world, words(i), ' ' ; brk 'END' ; rtx * ; pend; /* eof - world.mi */
qsh > cd /home/ljl/tmp > mic -q*replace hello.emi mic: -- program HELLO is placed in library LSBIN
> MIC PGM(WORLD)
SRCPATH('/qsys.lib/srclib.lib/misrc.file/world.mbr')
OPTION(*REPLACE) /* replace existing program with the same name */
mic: -- program WORLD is placed in library LSBIN.
> CALL PGM(HELLO) Hello, COBOL > CALL PGM(HELLO) Hello, MI > CALL PGM(HELLO) Hello, ILE RPG > CALL PGM(HELLO) Hello, ILE RPG
Description of command parameters of CL command MIC.
Parameter Name | Description |
Program (PGM) | Library and name of created program object; the library name is default to *CURLIB |
Source path name (SRCPATH) | Source path name. See Comment 1, Comment2 |
Text description (TEXT) | Text description of created program object |
Output printer file (OUTPUT) | Printer file name used to generate compiler listing; default to *LIBL/QSYSPRT. See Commnent 3 |
Public authority (AUT) | Public authority; default to *ALL |
Include directories (INCDIR) | Include directories, up to 15; can be absolute path names or relative path names in stream file systems or the database file system in IFS (Integrated File System) path name format. See Comment 1. |
Compiler options (OPTION) | Compiler options, see Machine interface language syantax provided by IBM, Create Program (QPRCRTPG) API |
Comment 1. | MIC supports either stream source file and database file system source. When refer to a stream source file, specifiy the IFS path name of the stream source file for parameter SRCPATH. For example, /home/ljl/misrc/hello.emi. When refer to a database file system source, specify the path name in '/qsys.lib' format for paramter SRCPATH. For example, /qsys.lib/srclib.lib/misrc.file/world.emi. Note that when using database file system source on i5/OS, we can only store sources in source physical file. When applying DSPFD (Display File Description) command on a source physical file, the 'File type (FILETYPE)' attribute is '*SRC', while a data physical file's file type attribute is '*DATA'. |
Comment 2. | MIC supports either absolute path name or relative path name when locating a source file. Combining relative path name with a job's current working directory setting will befinit programmers a lot when specifying target source file path or paths of include directories. When working under QShell environment, the current working directory is always the place where we are. When working under CL environment, one can change his current working directory by CL commands CHDIR or CHGCURDIR, and view his current working directory setting by CL command DSPCURDIR. |
Comment 3. | To make MIC output compiler listing information, specify the *LIST option in CL command MIC's parameter OPTION. The compiler listing will be output to a spooled file with the name set to the printer file name specified in parameter OUTPUT. |
> mic -h Usage: mic [options] source-file-name Options: -v Verbose -V Show version information -h Show help information -o Name of created program object -t Text description -l Output printer file name -a Public authority -I Include path -q Compiler options -L Library name of created program object Report bugs to junleili-cn@users.sourceforge.net
Command options of QShell command mic
Option name | Description |
-h | Show help information |
-v | verbose, when specifying -q*list option, output compiler listing |
-V | Show version information |
-o program-name | Created program name; default to source file name |
-t text | Text description of created program |
-l printer-file | Printer file name used to generate compiler listing; default to *LIBL/QSYSPTR. |
-a public-authority | Public authority; default to *ALL |
-I include-path | Include directories, up to 15; can be absolute path names or relative path names of IFS or database file system. |
-q compiler-option | Compiler options, see Machine interface language syantax provided by IBM Create Program (QPRCRTPG) API |
-L library-name | Library name of created program object. If environment variable OUTPUTDIR is set, use the value of the OUTPUTDIR. If environment variable OUTPUTDIR is not set, use job's current library. |
Use relative path name for target source file or include directories
Assume that we have a database file system source file member, SRCLIB/MISRC(HELLO) which include another database file system source file member, SRCLIB/MISRC(UTIL_INC). To compile program HELLO, we might issue the following CL command
> CHGCURDIR DIR('/qsys.lib/srclib.lib/misrc.file') /* change job's current working directory */ Current directory changed. > MIC PGM(HELLO) SRCPATH(hello.mbr) /* specify relative path name */ TEXT('using relative path name') mic: -- program HELLO is placed in library *CURLIB.
Use database file system source and *STMF source at the same time
Assume that our target source file is a database source file member, SRCLIB/MISRC(HELLO). Source files included by SRCLIB/MISRC(HELLO) are placed under IFS directories /home/ljl/mi-inc and /home/ljl/mi-inc/sub-dir respectively. To compile program HELLO, we might issue the following CL command
> CHDIR DIR('/home/ljl/mi-src')
Current directory changed.
> MIC PGM(HELLO)
SRCPATH('/qsys.lib/srclib.lib/misrc.file/hello.mbr')
INCDIR('sub-dir')
OPTION(*REPLACE)
mic: -- program HELLO is placed in library *CURLIB.
Output compiler listing when compiling from QShell
To output compiler listing under QShell environment, -v option and -q*list option must be specified at the same time. For example
qsh > mic -v -q*replace -q*list hello.emi
Input source code from the standard input when invoking mic under QShell Environment
When invoked under QShell Environment without the source-file-name option, MIC reads source code from the stdin. If -o option is not specified, MIC uses a.out as the name of the created program object.
> mic << eof
>
> entry * ext;
>
> dcl dd msg char(32) auto init('happy birthday:)');
>
> dcl dd len bin(2) auto;
>
> triml len, msg, ' ';
>
> %sendmsg(msg, len);
>
> rtx *;
>
> pend;
>
> eof
mic: -- program A.OUT is placed in library LSBIN
$
> system "call a.out" # run program A.OUT
:
happy birthday:)
$
/* single-line comment */ /* multi-line comment ... ... */
MIC searches the following directories for compiler includes
In my open source project i5/OS Programmer's Toolkit, more than a half of the source code is written in MI. I have to appreciate Mr. Leif Svalgaard for his excellent articles about MI programming in the MI-400 list at midrange.com.
Other helpful web sites for me include:
I'm available at junleili-cn@users.sourceforge.net. Any comments and suggestions are always welcome :)