

Task

Given a character value in your language, print its code   (could be ASCII code, Unicode code, or whatever your language uses).



Example

The character   'a'   (lowercase letter A)   has a code of 97 in ASCII   (as well as Unicode, as ASCII forms the beginning of Unicode).

Conversely, given a code, print out the corresponding character.




*        Character codes EBCDIC    15/02/2017
CHARCODE CSECT
         USING  CHARCODE,R13       base register
         B      72(R15)            skip savearea
         DC     17F'0'             savearea
         STM    R14,R12,12(R13)    prolog
         ST     R13,4(R15)         " <-
         ST     R15,8(R13)         " ->
         LR     R13,R15            " addressability
* Character to Decimal
         SR     R1,R1              r1=0
         IC     R1,=C'a'           insert character 'a'
         XDECO  R1,PG
         XPRNT  PG,L'PG            print -> 129
* Hexadecimal to character
         SR     R1,R1              r1=0
         IC     R1,=X'81'          insert character X'81'
         STC    R1,CHAR            store character r1
         XPRNT  CHAR,L'CHAR        print -> 'a'
* Decimal to character
         LH     R1,=H'129'         r1=129
         STC    R1,CHAR            store character r1
         XPRNT  CHAR,L'CHAR        print -> 'a'
*
         XDUMP  CHAR,L'CHAR        dump -> X'81'
*
RETURN   L      R13,4(0,R13)       epilog 
         LM     R14,R12,12(R13)    " restore
         XR     R15,R15            " rc=0
         BR     R14                exit
PG       DS     CL12
CHAR     DS     CL1 
         YREGS
         END    CHARCODE