
NUMERIC PROGRAMMING EXAMPLES
iAPX2Sb MACRO ASSEMBLER | 80287 | 10: 12: 38 09/25/83 PAGE |
LOC aSJ | LINE | SOURCE |
51
52
53
54
55
56
57
'8
59
If the given number Ula!> zero, the ASCII string will contain a sign
and a single zero chacter. The value string_size indicates. the total
length of the ASCII string including the sign character. StringeD) will
alwal,ls hold the sign. It is possible for string_sile to be less than
field_sileo This occurs for zeroes or integer values. A pauedo zero
will return a special return code. The denormal count will indicate
the power of two original III associated with the vlillue. The power of ten and ASCII string will be as if the value was an o'f'dinar~ lero.
60This subroutine is accurate up to a maximum of 18 decimal diilits for
61integers. Integer values will have a decimal power of zero associated
62with them. For non integers. the result will be accurate to within 2
63dIJcimal digits of the 16th decimal place (double precision>. The
64exponentiate instruction is also used for scaling thIJ value into the
65range acceptable for the BCD data t~pe. The rounding mode in effect
66on entrv to the subroutine is used for thIJ conversion.
| 67 |
|
|
|
|
|
|
| 68 |
| The following regist.~rs are not transpart'nt: | ||||
| 69 |
|
|
|
|
|
|
| 70 |
|
|
|
|
|
|
| 71 |
|
|
|
|
|
|
| 72 | +1 |
|
|
|
|
|
| 73 | , | Dt'fine the stack lallout. | ||||
| 74 | ||||||
| 75 |
| '0· |
|
|
| |
OOOOC] | 76 | bp_save |
| word ptr [bpJ | |||
0002t:] | 77 | es_save |
| bp_save + size bp_save | |||
| '0· | ||||||
|
|
|
| es_save + size es_save | |||
0004[1 | 78 | returnJtr |
| '0· | |||
0006[] | 79 |
| '0· | return_ptr + size returnJltr | |||
OOOSt] | 80 | field_size |
| '0· | powerJltr + sile power_ptr | ||
CODAr] | 81 | SileJltr |
| '0· | field_size + size field_sil,e | ||
oOOetl | 82 |
| '0· | size_ptr + size sizeJltr | |||
OOOEt] | 83 | denormal_ptr | '0· | string_ptr + size stringJtr | |||
| 84 |
|
| '0· |
|
|
|
| 8. | parms_sl ze |
| size power_ptr + !;ize field_size + size | |||
OOOA | 87 | • |
|
| size stringJltr + size denormalJtT· | ||
86 |
|
|
| ||||
| 88 | , | Define | constants | used | ||
0012 | 89 |
| '0· |
| , Number of iigits in bcd_value | ||
90 | BCD_DIGITS | 18 | |||||
0002 | 91 | WORD_SIZE |
| 2 |
|
| |
| eo· |
|
| ||||
OOOA | 92 | BCD_SIZE |
| '0· | 10 | , Define return values | |
0001 | 93 | MINUS |
| eo· | I | ||
0004 | 94 | NAN |
| '0· | 4 | , The exact values chosen here are | |
0006 | 95 | INFINITY |
| '0. | 6 | important. The\! must correspond to | |
0003 | .6 | INDEFINITE |
| '0· | 3 | , the possible return v .. lu •• and b. in | |
0008 | 97 | PSUEDO_ZERO | '0· | - |
|
| |
8 | the same numeric order as tested b~ | ||||||
98 | INVALID |
| '0· | 2 | the program. | ||
9. | ZERO |
| '0· |
|
| ||
100 | DENORMAL |
|
|
| |||
| 101 | UNNORMAL |
| '0· |
|
| |
| '0· |
|
| ||||
0000 | 102 | NORMAL |
| '0· | 0 |
|
|
0002 | 103 | EXACT |
| '0· | 2 |
|
|
| 104 | , |
|
|
|
|
|
| 105 | Define la~out of temporOlr\! storage area. | |||||
106 |
| .,. |
|
|
| ||
107 | status |
| word ptr | ||||
108 | power _two |
| '0· | status - WORD_SIZE | |||
109 | power _ten |
| '0· | power_two - WORD_SIZE | |||
110 | bcd_value |
| '0· | tbyte ptr power _ten - BCD_SIZE | |||
III | bcd_byte |
| eo· | bl,lte ptr bcd_value | |||
112 | fr.c t i on |
| '0· | bcd_value | |||
| 113 |
|
|
|
|
|
|
| 114 |
|
|
| size status + size power_two + 6ize power_ten | ||
0010 | It116. |
|
|
| + size bcd_v.lue | ||
| lt7 |
|
|
|
|
|
|
| 118 | +1 |
|
|
|
|
|
| 119 |
|
| segment | e1" | pub I ic | |
| 120 |
|
| ext1"n | power_tab I.: q,ward | ||
| 121 |
|
|
|
|
|
|
|
| 12. |
|
| 123 |
0000 DADO | 124 | |
12. | ||
|
| 126 |
|
| 127 |
|
| 128 |
0002 FB | 129 | |
130 | ||
0003 | 04 |
|
0004 | F9 |
|
uuv;;; | u;;; |
|
0006 | 00 | 131 |
0007 | 06 |
|
0008 | 01 ' |
|
0009 | 07 |
|
OOOA Fe | 132 | |
0009 FE |
| |
Dooe FD |
| |
0000 | FE |
|
DOOE | FA | 133 |
DOOF | FE |
|
0010 | FB |
|
0011 | FE |
|
Constant. used blJ this function.
con.tlD | even |
| j | Optimize for 16 bits |
|
d. | 10 | J | AdJustment value floT" | too big BCD |
Convert the C3.C2.Cl.CO encoding fir om tos_stOltus into meaningful bit fllags OInd values.
dbUNNORMAL. NAN. VNNORMAl. + MINUS. NAN + MINUS.
NORMAL. INFINITY. NORMAL + MINUS. INFINITY + MINUS.
ZERO, INVAl.lD. ZERO + MINUS, INVALID,
DENORMAL, INVALID, OENORMAL + MINUS. INVALID