?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #ifndef included_f16tof24
  2. #define included_f16tof24
  3.  
  4. f16tof24:
  5. ;HL is the f16 input
  6. ;AHL is the f24 output
  7.  
  8. ;check for inf or NaN
  9.   ld a,h
  10.   and %01111100
  11.   jr z,f16tof24_zero
  12.   cp %01111100
  13.   jr z,f16tof24_inf_nan
  14.  
  15.   ; subtract 15 and add 63 to the exponent, net +48
  16. ;it is not a special value
  17.   add hl,hl
  18.   rla        ;A = xxxxxxxs
  19.   add a,a    ;A = xxxxxxs0
  20.   add a,a    ;A = xxxxxs00
  21.   add hl,hl
  22.   rla        ;A = xxxxs00e
  23.   add hl,hl
  24.   rla        ;A = xxxs00ee
  25.   add hl,hl
  26.   rla        ;A = xxs00eee
  27.   add hl,hl
  28.   rla        ;A = xs00eeee
  29.   add hl,hl
  30.   rla        ;A = s00eeeee
  31.   ; Finally, subtract 15 and add 63 to the exponent
  32.   add a,48
  33.   ret
  34.  
  35. f16tof24_zero:
  36.   sla h
  37.   rra
  38.   ret
  39.  
  40. f16tof24_inf_NaN:
  41.   ld a,h
  42.   and 3
  43.   or l
  44.   ld l,a
  45.   ld a,h
  46.   or $7F
  47.   ld h,l
  48.   ret
  49. #endif
  50.