daily pastebin goal
68%
SHARE
TWEET

Conv_OP1

Zeda Jun 28th, 2013 121 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Conv_OP1:
  2.      ld hl,8478h
  3. ConvDecAtHL:
  4. ;Inputs:
  5. ;     HL points to the FP number to convert
  6. ;Outputs:
  7. ;      A is the 8-bit result
  8. ;      B is 0
  9. ;      C is the value of the last digit
  10. ;     DE is the 16-bit result
  11. ;     HL is incremented by 9
  12. ;Destroys:
  13.      ex de,hl
  14.      ld hl,9
  15.      add hl,de
  16.      push hl
  17.      ex de,hl
  18.      ld a,(hl)
  19.      and 80h
  20.      push af
  21.      inc hl
  22.      ld a,(hl)
  23.      sub 80h
  24.      ld de,0
  25.      jr nc,$+17
  26.        ld c,e
  27.        ld b,e
  28. ConvDone:
  29.        pop af
  30.        jr z,$+9
  31.          ld a,e \ cpl \ ld e,a
  32.          ld a,d \ cpl \ ld d,a
  33.          inc de
  34.        pop hl
  35.        ld a,e
  36.        ret
  37.      ld b,a
  38.      inc b
  39.      inc hl
  40.      ld a,(hl)
  41. ConvDecLoop:
  42.      rlca
  43.      rlca
  44.      rlca
  45.      rlca
  46.      push hl
  47.      ld h,d
  48.      ld l,e
  49.      add hl,hl
  50.      add hl,hl
  51.      add hl,de
  52.      add hl,hl
  53.      ex de,hl
  54.      pop hl
  55.      and 15
  56.      add a,e
  57.      ld e,a
  58.      jr nc,$+3
  59.      inc d
  60.      dec b
  61.      jr z,ConvDone
  62.      ld a,80h
  63.      xor b
  64.      jr z,ConvDone
  65.      ld b,a
  66.      ld a,(hl)
  67.      jp m,ConvDecLoop+4
  68.      inc hl
  69.      jp ConvDecLoop-1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top