Topic
  • 1 reply
  • Latest Post - ‏2017-06-02T10:45:05Z by Visda
SystemAdmin
SystemAdmin
196 Posts

Pinned topic How should I use the __cu21 builtin function ?

‏2011-12-19T10:43:00Z |
Hello,

I wanted to use the builtin function __cu21 to convert UTF-16 to UTF-8 in a C program.
int __cu21(char *op1, unsigned long op1_len, unsigned short *op2, unsigned long op2_len,unsigned char mask);


At the end of the CU21 ASM instruction (CU21 R1,R2[,M3]), the contents of register R1+1 are decremented by the number of bytes placed at R1 location. This allows to know exactly the length of the UTF-8 sequence generated.

It seems that I can't get this length with C interface.
Moreover, I can't handle return code 1 (opt1 too small) without either parsing the buffer to know the length already converted or restarting the conversion from beggining.

Can someone explain me why __cu21 doesn't use prototype like iconv which allows to get the registers value at the end of ASM instruction ?

Thanks for your help.

Regards,
Updated on 2014-03-24T22:16:33Z at 2014-03-24T22:16:33Z by iron-man
  • Visda
    Visda
    37 Posts
    ACCEPTED ANSWER

    Re: How should I use the __cu21 builtin function ?

    ‏2017-06-02T10:45:05Z  
    • DaveyC
    • ‏2012-02-24T03:29:10Z
    Visda,

    I think this is another good example of why GENASM should be supported in all code, not just Metal/C.
    If it's good enough for gcc it should be good enough for xlc. In fact, xlc supports inline assembly in just
    about every platform other than z.
    David Crayford

    Hello, David,

     

    Glad to tell you that the inlined assembly statement is now accepted in z/OS XL C/C++.  To enable this feature ASM option should be specified at compile invocation.

    Here is a link to the V2R2 User's Guide describing this option:

     

    https://www.ibm.com/support/knowledgecenter/SSLTBW_2.2.0/com.ibm.zos.v2r2.cbcux01/asmcop.htm

     

    Thanks,

    Visda

  • Visda
    Visda
    37 Posts

    Re: How should I use the __cu21 builtin function ?

    ‏2012-02-23T17:35:53Z  
    Hello,

    Apologies for such late reply. Nevertheless your feedback is quite timely and very important to us.
    We in fact have the implementation you desire implemented for PL/1. Given your feedback we have decided to consider this implementation in the XL C/C++ compiler line.

    Thanks,
    Visda
  • DaveyC
    DaveyC
    62 Posts

    Re: How should I use the __cu21 builtin function ?

    ‏2012-02-24T03:29:10Z  
    • Visda
    • ‏2012-02-23T17:35:53Z
    Hello,

    Apologies for such late reply. Nevertheless your feedback is quite timely and very important to us.
    We in fact have the implementation you desire implemented for PL/1. Given your feedback we have decided to consider this implementation in the XL C/C++ compiler line.

    Thanks,
    Visda
    Visda,

    I think this is another good example of why GENASM should be supported in all code, not just Metal/C.
    If it's good enough for gcc it should be good enough for xlc. In fact, xlc supports inline assembly in just
    about every platform other than z.
    David Crayford
  • Visda
    Visda
    37 Posts

    Re: How should I use the __cu21 builtin function ?

    ‏2017-06-02T10:45:05Z  
    • DaveyC
    • ‏2012-02-24T03:29:10Z
    Visda,

    I think this is another good example of why GENASM should be supported in all code, not just Metal/C.
    If it's good enough for gcc it should be good enough for xlc. In fact, xlc supports inline assembly in just
    about every platform other than z.
    David Crayford

    Hello, David,

     

    Glad to tell you that the inlined assembly statement is now accepted in z/OS XL C/C++.  To enable this feature ASM option should be specified at compile invocation.

    Here is a link to the V2R2 User's Guide describing this option:

     

    https://www.ibm.com/support/knowledgecenter/SSLTBW_2.2.0/com.ibm.zos.v2r2.cbcux01/asmcop.htm

     

    Thanks,

    Visda