Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Use the MI to Work with Pointers in ILE RPG

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Use the MI to Work with Pointers in ILE RPG

    ** This thread discusses the article: Use the MI to Work with Pointers in ILE RPG **
    ** This thread discusses the Content article: Use the MI to Work with Pointers in ILE RPG **
    0

  • #2
    ** This thread discusses the article: Use the MI to Work with Pointers in ILE RPG **
    Originally posted by efnkay View Post
    Wow...Nice post. I've dug into MI instruction coding on several occasions but hadn't ever really broken the ice with it. Getting to the point, you've expressed the finer points of using and exploiting pointers! (Sorry couldn't help myself.)
    Thank you, efnkay.
    Working with MI instructions is always an interesting experience. The instructions might reveal some underlying behaviors of the OS at the SLIC layer. But it is sad that there are not enough documentation and resources on MI instructions. And the limited documentation DOES contains errors. For example, there isn't a system builtin named _PROPB (Propagate bytes), the right name might be __memset. Thus, I'm grateful for peoples who have shared their MI knowledge with curious programmers like me. And I myself also want to share what I've learned and tested about MI instructions to others.
    Thank you again.

    Comment


    • #3
      ** This thread discusses the article: Use the MI to Work with Pointers in ILE RPG **
      While I agree that some of the MI built-in names implied by the documentation is wrong (and have informed IBM of that), _PROPB isn't one of them. What makes you think _PROPB isn't available?

      Comment


      • #4
        _PROPB doesn't work on V5R2

        ** This thread discusses the article: Use the MI to Work with Pointers in ILE RPG **
        Originally posted by BVining View Post
        While I agree that some of the MI built-in names implied by the documentation is wrong (and have informed IBM of that), _PROPB isn't one of them. What makes you think _PROPB isn't available?
        Hi, Bruce.

        Thank you for your comment. I used to work on a V5R2 machine where _PROPB isn't available. I've tested the following 3 programs (2 in ILE RPG, 1 in ILE C) respectively under V5R2 and V5R4. The result is that built-in name __memset works on both V5R2 and V5R4, but built-in name _PROPB works only on V5R4.

        *) ILE RPG program bv1.rpgle
        @code
        /**
        * @file bv1.rpgle
        *
        * use built-in name '_PROPB';
        * can be compiled and works fine on V5R4;
        * cannot get compiled under V5R2 with the following error:
        * @code
        * Definition not found for symbol '_PROPB'.
        * @endcode
        */
        h dftactgrp(*no)

        d propb pr * extproc('_PROPB')
        d tgt_str * value
        d src_byte 1a value
        d count 10u 0 value

        d str s 16a inz(*all'abc')
        d

        /free

        propb(%addr(str) : x'F2' : 8);
        dsply 'result' '' str;

        *inlr = *on;
        /end-free
        @endcode

        *) ILE RPG program bv2.rpgle
        @code
        /**
        * @file bv2.rpgle
        *
        * use built-in name __memset;
        *
        * can get compiled either on V5R2 or on V5R4.
        */
        h dftactgrp(*no)

        d propb pr * extproc('__memset')
        d tgt_str * value
        d src_byte 1a value
        d count 10u 0 value

        d str s 16a inz(*all'abc')
        d

        /free

        propb(%addr(str) : x'F2' : 8);
        dsply 'result' '' str;

        *inlr = *on;
        /end-free
        @endcode

        *) ILE C program bvc.c
        @code
        /**
        * @file bvc.c
        *
        * Can be compiled and works fine on V5R4.
        * When compiling bvc.c under V5R2, one will get the following error:
        @code
        Builtin function _PROPB is unrecognized.
        Definition not found for symbol '_PROPB'.
        @endcode
        */

        # include

        # pragma linkage(_PROPB, builtin, nowiden)
        void *_PROPB(void *, int c, int n);

        int main() {

        char str[] = {"abcABCabcABCabcA"};

        printf("%s
        ", _PROPB(str, 0xF2, 8));
        return 0;
        }
        @endcode

        Additionally, the reason why I thought that '__memset' might be the real built-in name of instruction PROPB is __memset's prototype declared in QSYSINC/H(STRING):
        @code
        #pragma linkage( __memset, builtin )
        void *__memset ( void *, int, size_t );
        @endcode
        which reveals the following facts:
        - first, __memset is a system builtin;
        - second, __memset has exactly the same prototype and functionality with what IBM documented instruction PROPB.

        Now, I still think that __memset MIGHT be the right built-in name of instruction PROPB at least on V5R2. Since it is not reasonable to provide two instructions/system built-ins with the same functionality.

        Thank you again and expect for your further advices!

        Junlei Li

        Comment

        Working...
        X