home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / cpm68k / sd68k.lbr / MD5DC.S < prev    next >
Encoding:
Text File  |  1986-06-11  |  1.0 KB  |  40 lines

  1. ****    MD5DC -- convert binary value to decimal string
  2. **
  3. **    Function:
  4. **        Store the contents of D1.W as 5 decimal characters in memory
  5. **        location (5 bytes) pointed to by D0.L
  6. **    Inputs:  D0.L == pointer to 5-byte buffer
  7. **         D1.W == value to convert
  8. **    Outputs: D0.L == pointer to byte following buffer
  9. **    Registers affected: D0.L
  10. **    Routines called:  -none-
  11. **    Special error conditions:  -none-
  12. *
  13.     .globl    md5dc
  14.     .text
  15. md5dc:
  16.     movem.l    d1-d2/a1,-(a7)    * save registers
  17.     move.l    d0,a1
  18.     addq    #5,a1
  19.     moveq    #4,d2
  20. md5dc1:    ext.l    d1        * clear upper
  21.     divu    #10,d1        * get last digit
  22.     swap    d1
  23.     add    #$30,d1        * convert to ascii
  24.     move.b    d1,-(a1)    * and store
  25.     swap    d1
  26.     dbra    d2,md5dc1    * loop for 5 digits
  27. *
  28.     moveq    #3,d2        * get rid of leading zeros
  29. md5dc2:    move.b    (a1),d1
  30.     cmpi.b    #$30,d1
  31.     bne    md5dc3        * if not ZERO
  32.     move.b    #$20,(a1)+    * change to blank
  33.     dbra    d2,md5dc2
  34. *
  35. md5dc3:    addq    #5,d0
  36.     movem.l    (a7)+,d1-d2/a1
  37.     rts
  38. *
  39.     .end
  40.