// HEXNUM           Number Conversion

// This program will convert the positive number expressed
// by 3 digits in hexadecimal stored as quad words beginning
// at H1 into a value in register r20 for inspection.
        .data                     // Declare storage
        .align  8                 // Desired alignment
H1:     data8   0x3,0xa,0x2       // Interpret as "3a2"
        .text                     // Section for code
        .align  32                // Desired alignment
        .global main              // These three lines
        .proc   main              //  mark the mandatory
main:                             //   'main' program entry
        .body                     // Now we really begin...
first:  mov     r20 = 0;;         // r20 = value computed
        addl	r14 = @gprel(H1),gp;;  // Point to storage
        ld8     r21 = [r14];;     //       for 1st hex digit
        shladd  r20 = r20,4,r21;; // Value = 16*prev + next
        add     r14 = 8,r14;;     // Advance input pointer
        ld8     r21 = [r14];;     //  to 2nd hex digit
        shladd  r20 = r20,4,r21;; // Value = 16*prev + next
        add     r14 = 8,r14;;     // Advance input pointer
        ld8     r21 = [r14];;     //  to 3rd hex digit
        shladd  r20 = r20,4,r21;; // Value = 16*prev + next
                                  // We could continue...
done:   mov     r8 = 0;;          // Signal all is normal
        br.ret.sptk.many b0;;     // Back to command line
        .endp   main              // Mark end of procedure