home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / bluebook / asm-subr / bin16out < prev    next >
Encoding:
Text File  |  1985-12-22  |  1.3 KB  |  42 lines

  1. ;-------------------------bin16out routine begins--------------------------+
  2. ; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
  3. ;         page : 44
  4. ;
  5. ; ROUTINE FOR CONVERSION FROM 16-BIT BINARY TO ASCII BINARY
  6. ;
  7. ; FUNCTION: This routine accepts an 16-bit binary number in the DX register
  8. ; and converts it to ASCII binary form which is sent to the std output
  9. ; device.
  10. ; INPUT: Upon entry an 16-bit binary is in the DX register
  11. ; OUTPUT: A string of ASCII digits representing a binary number is sent
  12. ; out through the std output device.
  13. ; REGISTERS USED:  No registers are modified.  DX is used for input
  14. ; SEGMENTS REFERENCED:  None
  15. ; ROUTINES CALLED:  STDOUT
  16. ; SPECIAL NOTES: None
  17. ;
  18. ; ROUTINE TO CONVERT FROM INTERNAL 16-BIT BINARY TO ASCII BINARY
  19. ;
  20. bin16out    proc    far
  21. ;
  22. ;  a binary number is in DX
  23. ;    
  24.     push    cx        ; save registers
  25.     push    ax
  26. ;
  27.     mov    cx,16        ; loop for a count of 16
  28. bin16out1:
  29.     rol    dx,1        ; rotate DX left once
  30.     mov    al,dl        ; move into AL
  31.     and    al,1        ; just keep digit
  32.     add    al,30h        ; adjust AL to ASCII
  33.     call    stdout        ; output to console
  34.     loop    bin16out1    ; again until cx is 0
  35. ;
  36.     pop    ax        ; restore registers
  37.     pop    cx
  38.     ret            ; return
  39. ;
  40. bin16out    endp
  41. ;-------------------------bin16out routine ends---------------------------+
  42.