?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1.  ifndef included_ascii_to_uint8
  2.  define included_ascii_to_uint8
  3.  
  4. ;#ifndef TOK_DECIMAL
  5. ;#ifdef TOK_DECIMAL
  6. ;#define TOK_DECIMAL TOK_DECIMAL
  7. ;#else
  8. TOK_DECIMAL='.'
  9. ;#endif
  10. ;#endif
  11.  
  12. ascii_to_uint8:
  13. ;c flag means don't increment the exponent
  14.   ld c,0
  15.   ld a,(hl)
  16.   jr c,ascii_to_uint8_noexp
  17.   cp TOK_DECIMAL
  18.   jr z,ascii_to_uint8_noexpm2
  19. ;_:
  20.   sub 3Ah
  21.   add a,10
  22.   jr nc,ascii_to_uint8_noexp_end
  23.   inc b
  24.   ld c,a
  25.   add a,a
  26.   add a,a
  27.   add a,c
  28.   add a,a
  29.   ld c,a
  30.   inc hl
  31. ;_:
  32.   ld a,(hl)
  33.   cp TOK_DECIMAL
  34.   jr z,ascii_to_uint8_noexp_2nd
  35. ;_:
  36.   sub 3Ah
  37.   add a,10
  38.   jr nc,ascii_to_uint8_noexp_end
  39.   inc b
  40.   add a,c
  41.   inc hl
  42.   ld (de),a
  43.   dec de
  44.   or a
  45.   ret
  46.  
  47. ascii_to_uint8_noexpm2
  48.   inc hl
  49.   ld a,(hl)
  50. ascii_to_uint8_noexp:
  51.   sub 3Ah
  52.   add a,10
  53.   jr nc,ascii_to_uint8_noexp_end
  54.   ld c,a
  55.   add a,a
  56.   add a,a
  57.   add a,c
  58.   add a,a
  59.   ld c,a
  60. ascii_to_uint8_noexp_2nd:
  61.   inc hl
  62.   ld a,(hl)
  63.   sub 3Ah
  64.   add a,10
  65.   jr nc,ascii_to_uint8_noexp_end
  66.   add a,c
  67.   inc hl
  68.   db $FE   ;start of `cp **`, saves 1cc
  69. ascii_to_uint8_noexp_end:
  70.   ld a,c
  71.   ld (de),a
  72.   dec de
  73.   scf
  74.   ret
  75.  endif
  76.