?login_element?

Subversion Repositories NedoOS

Rev

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

  1. #ifndef included_u16tof24
  2. #define included_u16tof24
  3.  
  4. u16tof24:
  5. ;Inputs:
  6. ;   HL holds a 16-bit unsigned integer, (0 to 65535)
  7. ;Outputs:
  8. ;   Converts to an f24 float in AHL
  9. ;   returns z flag set if zero, nz otherwise :)
  10.  
  11.  
  12. ;Check if HL is 0, if so return AHL == 0x000000
  13.   ld a,h
  14.   or l
  15.   ret z
  16.  
  17.   ld a,$3F+16    ;Initial exponent and sign
  18.  
  19. ; HL is non-zero
  20. ; shift HL left until there is an overflow (the implicit bit)
  21. ; meanwhile, decrement A, the exponent each iteration
  22.   dec a
  23.   add hl,hl
  24.   jr nc,$-2
  25.   ret
  26. #endif
  27.