/****************************************************************************** Example #16 -- SPARC internal subroutines ******************************************************************************/ .global main .section ".text" .align 4 main: save %sp, -96, %sp set pairA, %r24 ! Address of 8-byte operands (%r24) call addex ! Add 8-byte operands (sum in %r20, %r21) nop mov %r20, %r9 ! Print 8-byte sum, using format mov %r21, %r10 ! selected by "addex" call printf nop set pairB, %r24 ! Address of 8-byte operands (%r24) call addex ! Add 8-byte operands (sum in %r20, %r21) nop mov %r20, %r9 ! Print 8-byte sum, using format mov %r21, %r10 ! selected by "addex" call printf nop set pairC, %r24 ! Address of 8-byte operands (%r24) call addex ! Add 8-byte operands (sum in %r20, %r21) nop mov %r20, %r9 ! Print 8-byte sum, using format mov %r21, %r10 ! selected by "addex" call printf nop set main, %r8 set main+0x100, %r9 call memory nop ret restore .section ".data" .align 4 pairA: .word 0x026581a3, 0xd581ce20 .word 0x51a8c31d, 0xf9671104 pairB: .word 0x7fffffff, 0xffffffff .word 0x00000000, 0x00000002 pairC: .word 0xffffffff, 0xffffffff .word 0x00000000, 0x00000001 .section ".text" .align 4 addex: ld [%r24+0], %r16 ! Get upper 4 bytes of 1st item ld [%r24+4], %r17 ! Get lower 4 bytes of 1st item ld [%r24+8], %r18 ! Get upper 4 bytes of 2nd item ld [%r24+12], %r19 ! Get lower 4 bytes of 2nd item addcc %r17, %r19, %r21 ! Add lower 4 bytes of the operands addxcc %r16, %r18, %r20 ! Add upper 4 bytes of the operands bvs else ! Test for overflow nop set fmt1, %r8 ! No overflow (use format #1) ba endif nop else: set fmt2, %r8 ! Overflow (use format #2) endif: jmpl %r15+8, %r0 ! Return from internal subroutine nop .section ".data" .align 4 fmt1: .asciz "Sum: %08x%08x\n\n" fmt2: .asciz "Sum: %08x%08x (*** overflow ***)\n\n"