/****************************************************************************** Example #31 -- SPARC floating point operations ******************************************************************************/ .global main .section ".text" .align 4 main: save %sp, -112, %sp set one, %l0 ! Put address of 1.0 into %l0 set ten, %l1 ! Put address of 10.0 into %l1 set zero, %l2 ! Put address of 0.0 into %l2 ldd [%l0], %f24 ! Constant (%f24/25) <== 1.0 ldd [%l1], %f26 ! Constant (%f26/27) <== 10.0 ldd [%l2], %f16 ! Total (%f16/17) <== 0.0 fmovs %f24, %f18 ! Value (%f18/19) <== 1.0 fmovs %f25, %f19 loop: fcmpd %f18, %f26 ! Compare Value to 10.0 nop fbg endloop ! If greater than or equal to 10.0, exit nop faddd %f16, %f18, %f16 ! Add Value to Total faddd %f18, %f24, %f18 ! Add 1.0 to Value ba loop nop endloop: call iu_registers ! Display contents of IU registers nop call fpu_registers ! Display contents of FPU registers nop call dp_registers ! Display FPU registers (as dp values) nop std %f16, [%sp+96] ! Transfer Total to memory, then back ld [%sp+100], %o2 ! into IU registers (for printf) ld [%sp+96], %o1 set fmt, %o0 call printf nop call fpu_registers ! Display contents of FPU registers nop ret restore .align 8 one: .double 0r1.0 ten: .double 0r10.0 zero: .double 0r0.0 fmt: .asciz "\nTotal: %6.2f\n" .align 4