Topic
  • No replies
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
    29 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
    56 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