daily pastebin goal
46%
SHARE
TWEET

ConvRStr

Zeda Jan 4th, 2012 133 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;===============================================================
  2. ConvRStr:
  3. ;===============================================================
  4. ;Input:
  5. ;     HL points to the base 10 number or the byte before
  6. ;Outputs:
  7. ;     A is the byte before the number
  8. ;     BC is the 16-bit value of the number
  9. ;     DE is 10^(number of digits plus one)
  10. ;     HL points to the byte after the number
  11. ;Size:  38 bytes
  12. ;Speed: 139d+11w+25[+12 if ending byte is >39h]
  13. ;       d is the number of digits in the number
  14. ;       w is at most the number of digits minus 2
  15. ;       at most 765 cycles
  16. ;===============================================================
  17.         dec hl
  18.         bit 3,(iy+34)
  19.         jp nz,ConvHexStr
  20.         ld bc,0
  21. ConvLoop:
  22.         ld a,(hl)
  23.         sub 30h \ ret c
  24.         cp 10 \ ret nc
  25.         inc hl
  26.         ld (progPtr),hl
  27.  
  28.         ld h,b \ ld l,c
  29.         add hl,hl
  30.         add hl,hl
  31.         add hl,bc
  32.         add hl,hl
  33.         ld b,h
  34.  
  35.         add a,l
  36.         ld hl,(progPtr)
  37.         ld c,a
  38.         jr nc,ConvLoop
  39.         inc b
  40.         jr ConvLoop
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