?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. #ifndef included_singletof24
  2. #define included_singletof24
  3.  
  4. singletof24:
  5. ;convert a single-precision float (the format in this lib) at HL
  6. ;to an f24 float in AHL
  7. ;destroys BC,DE
  8.  
  9.   ld c,(hl)
  10.   inc hl
  11.   ld e,(hl)
  12.   inc hl
  13.   ld d,(hl)
  14.   inc hl
  15.   ld a,(hl)
  16. ;check for special values
  17.   or a
  18.   jr nz,+_
  19.   ;get the sign
  20.   rl d
  21.   rra
  22.   ret z
  23.   or $7F
  24.   rl d
  25.   ccf
  26.   sbc hl,hl
  27.   ret
  28. _:
  29.  
  30. ;Make sure the exponent isn't too large
  31.   cp 64+128
  32.   jr c,+_
  33.   ld a,d
  34.   or $7F
  35.   ld h,b
  36.   ld l,b
  37.   ret
  38. _:
  39.  
  40. ;Make sure the exponent isn't too small
  41.   sub 128-62
  42.   jr nc,+_
  43.   xor a
  44.   ret
  45. _:
  46.  
  47. ;okay, now adjust the exponent
  48.   inc a
  49.   add a,a
  50.  
  51. ;shift the mantissa up 1
  52.   sla c
  53.   ex de,hl
  54.   adc hl,hl
  55. ;shift the sign into a
  56.   rra
  57.  
  58. ;round
  59.   sla c
  60.   ld bc,0
  61.   adc hl,bc
  62.   adc a,b
  63.   ret
  64. #endif
  65.