?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. #ifndef included_f24tof32
  2. #define included_f24tof32
  3. #include "pushpop.z80"
  4.  
  5. f24tof32:
  6. ;convert an "f24" float to an IEEE-754 binary32
  7. ;Input: AHL is the input float. BC points to where the f32 should be written.
  8. ;Destroys: None
  9.   call pushpop
  10.   ex de,hl
  11.   ld h,b
  12.   ld l,c
  13. ; Check for special values
  14.   ld c,a  ;save for the sign
  15.   add a,a
  16.   jr z,f24tof32_return_0
  17.   inc a
  18.   inc a
  19.   jr z,f24tof32_return_infnan
  20.   add a,126
  21.   rra
  22.   rl c
  23.   rra
  24.   rr d
  25.   rr e
  26.   ld (hl),0
  27.   rr (hl)
  28.   inc hl
  29.   ld (hl),e
  30.   inc hl
  31.   ld (hl),d
  32.   inc hl
  33.   ld (hl),a
  34.   ret
  35. f24tof32_return_0:
  36.   ld (hl),a
  37.   inc hl
  38.   ld (hl),a
  39.   inc hl
  40.   ld (hl),a
  41.   rra
  42.   inc hl
  43.   ld (hl),a
  44.   ret
  45. f24tof32_return_infnan:
  46.   ld a,d
  47.   or e
  48.   ld (hl),a
  49.   inc hl
  50.   ld (hl),a
  51.   inc hl
  52.   or %10000000
  53.   ld (hl),a
  54.   inc hl
  55.   ld a,c
  56.   or %01111111
  57.   ld (hl),a
  58.   ret
  59. #endif
  60.