// IO_C         Test character I/O using C

        NL      = 0xa             // Newline character
        .global chrget,chrput     // External references
        .type   chrget,@function  //  and their
        .type   chrput,@function  //   types
        .text                     // Section for code
        .align  32                // Desired alignment
        .global main              // These three lines
        .proc   main              //  mark the mandatory
main:                             //   'main' program entry
        .prologue 12,r33          // rp, ar.pfs @r33+
        .save   ar.pfs,r34        // Previous function state
        alloc   r34 = ar.pfs,0,3,1,0  // 3 locals, 1 out
        .save   rp,r33            // Say where we store
        mov     r33 = b0          //  the return address
        .body                     // End of prologue
first:                            // Now we really begin...
        mov     r32 = r1;;        // Save gp across calls
        br.call.sptk.many b0=chrget;;  // Get one character
        mov     r1 = r32          // Restore gp
        mov     r35 = r8          // r36 = character to send
        br.call.sptk.many b0=chrput;;  // Put one character
        mov     r1 = r32          // Restore gp
        mov     r35 = NL          // r35 = newline to send
        br.call.sptk.many b0=chrput;;  // Put one character
        mov     r1 = r32          // Restore gp
done:   mov     r8 = 0            // Signal all is normal
        mov     ar.pfs = r34      // Restore previous state
        mov     b0 = r33          // Restore exit address
        br.ret.sptk.many b0;;     // Back to command line
        .endp   main              // Mark end of procedure