On Mon, 4 Apr 2011 06:31:49 -0400, Joe Owens wrote: >I have need to multiply a STCK duration, ie STCK2-STCK1 by a variable >factor, say from 5% to 1000%. >I would like the result to be a STCK duration too, suitable for STIMER >MICVL= >I suspect the best answer is to do FP arithmetic. I've never done this >before, and looking for some friendly advice. >Thanks in advance. >Joe Owens
You have some good answers for how to do it in fixed-point. The following are examples for doing it in floating point. Note: I have not assembled or tested these so likely there are errors: Given: PERCENT DS F Percentage to multiply by STCKDIFF DS FD (positive) difference between two STCK values RESULT DS FD Result will go here DBLWORD DS D Work area Using S/360 (hexadecimal) floating point: MVC DBLWORD(4),=X'4E000000' Exponent for PERCENT MVC DBLWORD+4(4),PERCENT Assumes "PERCENT" is a fullword LD FP0,DBLWORD Load PERCENT as hex-float AD FP0,=D'0' Normalize MVI DBLWORD,X'4D' EXPONENT for STCKTIME MVC DBLWORD+1(7),STCKDIFF Convert STCKDIFF to hex-float LD FP0,DBLWORD Load STCKDIFF as hex-float AD FP2,=D'0' Normalize MDR FP0,FP2 STCKDIFF*PERCENT DDR FP0,=D'100' STCKDIFF*PERCENT/100 AD FP0,=D'0.5' Round up AW FP0,=X'4E000000 00000000' Convert to fixed point STD FP0,DBLWORD Save result MVI DBLWORD,0 Remove exponent LM R0,R1,DBLWORD Load microseconds SLDL R0,12 Convert to STCK format STM R0,R1,RESULT Save result Using binary floating point: L R0,PERCENT Get PERCENT CDFBR FP0,R0 Convert to binary float LG R0,STCKDIFF Get STCKDIFF SRLG R0,R0,12 Convert to microseconds CDGBR FP2,R0 Convert to binary float MDBR FP0,FP2 STCKDIFF*PERCENT DDB FP0,=DB'100' STCKDIFF*PERCENT/100 CDGBR R0,1,FP0 Convert to fixed point SLLG R0,R0,12 Convert to STCK format STG R0,RESULT Save result I will leave the decimal floating point version as an exercise. David Bond
