?login_element?

Subversion Repositories NedoOS

Rev

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

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