Mercurial > hg > index.cgi
comparison src/number.s @ 95:25b44f1ac2aa
Fix detection of integer value on ascii conversion
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 22 Oct 2023 21:03:24 -0600 |
parents | 5fa8c479dbf7 |
children | 6837d10b67fb |
comparison
equal
deleted
inserted
replaced
94:5fa8c479dbf7 | 95:25b44f1ac2aa |
---|---|
237 std val0+val.int+2 | 237 std val0+val.int+2 |
238 rts | 238 rts |
239 ; Normalization is not required here though rounding might be. Rounding will be handled during floating point return. | 239 ; Normalization is not required here though rounding might be. Rounding will be handled during floating point return. |
240 ; By ensuring there were no leading zeroes converted, the result is already pre-normalized without losing precision due | 240 ; By ensuring there were no leading zeroes converted, the result is already pre-normalized without losing precision due |
241 ; to an aribtrary number of leading zeroes. | 241 ; to an aribtrary number of leading zeroes. |
242 val_parsenum11a cmpb fpaextra ; is the exponent less than the number of digits? | 242 val_parsenum11a cmpb #9 ; is the exponent greater than possible for a 32 bit integer? |
243 blt val_parsenum13 ; brif so - return floating point (signed comparison!) | 243 bgt val_parsenum13 |
244 cmpb #10 ; is exponent in the range for a binary integer? | 244 lda fpaextra ; fetch the number of digits |
245 bgt val_parsenum13 ; brif not - return floating point | 245 deca ; account for the decimal point offset |
246 cmpa fpa0+fpa.exp ; do we have more digits than the exponent (fractional)? | |
247 bgt val_parsenum13 ; brif we have more digits than exponent | |
246 ; Compare with 2147483648, the maximum *negative* value; note that this is a floating point comparison because we | 248 ; Compare with 2147483648, the maximum *negative* value; note that this is a floating point comparison because we |
247 ; already normalized everything above and it handles exponents properly | 249 ; already normalized everything above and it handles exponents properly |
248 lda fpa0+fpa.exp ; compare exponents (unbiased), exponent adjusted for above code | 250 lda fpa0+fpa.exp ; compare exponents (unbiased) |
249 cmpa #10 | 251 cmpa #9 |
250 bne val_parsenum12 | 252 bne val_parsenum12 |
251 ldx fpa0+fpa.sig ; compare top of significand | 253 ldx fpa0+fpa.sig ; compare top of significand |
252 cmpx #0x2147 | 254 cmpx #0x2147 |
253 bne val_parsenum12 | 255 bne val_parsenum12 |
254 ldx fpa0+fpa.sig+2 ; compare middle of significand | 256 ldx fpa0+fpa.sig+2 ; compare middle of significand |
267 sta fpa0+fpa.exp | 269 sta fpa0+fpa.exp |
268 ldy #val0+val.value ; normalize/round and return the result | 270 ldy #val0+val.value ; normalize/round and return the result |
269 jmp fps_normalize | 271 jmp fps_normalize |
270 val_parsenum14 lda #valtype_int ; set value type to integer | 272 val_parsenum14 lda #valtype_int ; set value type to integer |
271 sta val0+val.type | 273 sta val0+val.type |
272 ldb #10 ; exponent needed for decimal point to the right of significand | 274 ldb #9 ; exponent needed for decimal point to the right of significand |
273 subb fpa0+fpa.exp ; number of digit shifts needed to denormalize | 275 subb fpa0+fpa.exp ; number of digit shifts needed to denormalize |
274 beq val_parsenum16 ; brif already denormalized | 276 beq val_parsenum16 ; brif already denormalized |
275 lslb ; do 4 shifts per digit | 277 lslb ; do 4 shifts per digit |
276 lslb | 278 lslb |
277 val_parsenum15 lsr fpa0+fpa.sig ; shift a digit right | 279 val_parsenum15 lsr fpa0+fpa.sig ; shift a digit right |