× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Dave

MI functions can be used much like C/C++ functions.

To whet your appetite, I found these MI functions listed-

Test Bit in String (TSTBTS) <http://publib.boulder.ibm.com/iseries/v5r1/ic2924/tstudio/tech_ref/mi/TSTBTS.htm>
Test Bits Under Mask (TSTBUM) <http://publib.boulder.ibm.com/iseries/v5r1/ic2924/tstudio/tech_ref/mi/TSTBUM.htm>


This stuff is documented largely under C/C++ programming in KnowledgeCenter - you can also find some info in the MIH source file in library QSYSINC - the member there for TSTBTS has the following prototypes:

int _TSTBTS ( void *, /* Pointer to bit string
unsigned ); /* Offset to bit to test
/* Left bit is 0 offset

int tstbts ( void *, /* Pointer to bit string
unsigned ); /* Offset to bit to test
/* Left bit is 0 offset

The first item is what is called a built-in - you just add an underscore before the MI name. You can call the function using either form, a built-in is usually a layer closer to the hardware.

In KnowledgeCenter, the documentation for each MI instruction is available. It's a bit arcane, of course. And even if there isn't a published H member for the instruction, you might still be able to use it as a built-in - so the TSTBUM might be available - I've not looked up what and how to use it.

A Google on these names might get you examples in RPG - and you can easily convert those to CL, what with the *BYVAL stuff we now have.

Have fun!

Vern

On 12/20/2016 12:37 AM, dlclark@xxxxxxxxxxxxxxxx wrote:
"MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx> wrote on 12/19/2016
09:21:38 PM:
If you use ILE CL (CLLE) vs. OPM CL (CLP), then you can use many MI
instructions directly "in-line" as built-in functions. This includes
the MI instructions for testing and setting individual bits, etc.
Although I am using CLLE and although I have coded assembler
programs for many years for mainframes, I have never used an MI
instruction on AS/400, iSeries, or IBM i. So, I wouldn't even know what
that looks like in-line in a CLLE program. Hints? I'm already converting
a byte to 8 bits the long way in a CL subroutine, but it seems painful to
do it this way. ;-)

...snip...

CHGVAR VAR(&CHAR) VALUE(%SST(&RCVR 9 1))
CALLSUBR SUBR(GET_BITS)
IF COND(&BIT_2_ON) THEN(CHGVAR &FILEATRB *LF)
ELSE CMD(CHGVAR &FILEATRB *PF)
IF COND(&BIT_4_ON) THEN(CHGVAR &FILETYPE *SRC)
ELSE CMD(CHGVAR &FILEATRB *DATA)

...snip...

SUBR SUBR(GET_BITS)
CHGVAR VAR(&BYTVALUE) VALUE(&CHAR)
CHGVAR VAR(&DECVALUE) VALUE(&HALFWORD)
CHGVAR VAR(&BIT_ADDR) VALUE(%ADDR(&BIT_7_ON))
DOFOR VAR(&BIT_POS) FROM(7) TO(0) BY(-1)
CHGVAR VAR(&TMPVALUE) VALUE(&DECVALUE / 2)
CHGVAR VAR(&BIT) VALUE(&DECVALUE - (&TMPVALUE * 2))
CHGVAR VAR(&BIT_ON) VALUE(&BIT *EQ 1)
CHGVAR VAR(&DECVALUE) VALUE(&DECVALUE / 2)
CHGVAR VAR(%OFFSET(&BIT_ADDR)) +
VALUE(%OFFSET(&BIT_ADDR) - 1)
ENDDO
ENDSUBR

Sincerely,

Dave Clark


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.