BINARY.DOC -- Description of BINARY.ASM ======================================= From `BLUEBOOK of ASSEMBLY ROUTINES for the IBM PC & XT' by Christopher L. Morgan Copyright (C) 1984 by The Waite Group, Inc. Purpose: BINARY.ASM contains routines to convert between number bases. Contents: --------- BIN16IN -- Convert from ASCII Binary to 16-bit Binary BIN16OUT -- Convert from 16-bit Binary to ASCII Binary BIN8OUT -- Convert from 8-bit Binary to ASCII Binary DEC16IN -- Convert from ASCII Decimal to 16-bit Binary DEC16OUT -- Convert from 16-bit Binary to ASCII Decimal DEC8OUT -- Convert from 8-bit Binary to ASCII Decimal HEX16IN -- Convert from ASCII Hexadecimal to 16-bit Binary HEX16OUT -- Convert from 16-bit Binary to ASCII Hexadecimal HEX8OUT -- Convert from 8-bit Binary to ASCII Hexadecimal OCT16IN -- Convert from ASCII Octal to 16-bit Binary OCT16OUT -- Convert from 16-bit Binary to ASCII Octal OCT8OUT -- Convert from 8-bit Binary to ASCII Octal Overview: These routines perform conversion between the PC's 8- and 16-bit internal BINARY integer formats and all the popular external integer number bases: binary, octal, hexadecimal, and decimal. For each number base, there are three routines: 1) Input from external to 16-bit binary internal format 2) Output from 8-bit binary internal format to external 3) Output from 16-bit binary internal format to external Throughout the routines, the 8088 registers are used consistently: AX is used for quick calculations and data movement CL & CX are used for counting, multiplying, or dividing DL & DX are used to pass numerical data in and out of routines ________________________________ BINARY ROUTINES ______________________________ BIN16IN -- Convert from ASCII Binary to 16-bit Binary Function: This routine accepts a binary number from the standard input device and converts it to internal 16-bit binary form. Input: The individual digits of the binary number are received in ASCII through a call to a standard I/O routine. The valid digits are 0 and 1. An ASCII code other than for a valid digit will terminatete the routine. Output: A 16-bit binary number is returned in the DX register. Registers used: Only DX is modified. It returns the result. Routines called: STDIN ______________________________________________________________________________ BIN8OUT Function: This routine accepts an 8-bit binary number in the DL register, converts it to ASCII binary form, and sends it to the standard output device. Input: Upon entry an 8-bit binary number is in the DL register. Output: A string of ASCII digits representing a binary number is sent out through the standard output device. Registers used: No registers are modified. DL is used for input. Routines called: STDOUT ______________________________________________________________________________ BIN16OUT Function: This routine accepts a 16-bit binary number in the DX register, converts it to ASCII binary form, and sends it to the standard output device. Input: Upon entry a 16-bit binary number is in the DX register. Output: A string of ASCII digits representing a binary number is sent out through the standard output device. Registers used: No registers are modified. DX is used for input. Routines called: STDOUT ______________________________________________________________________________ OCT16IN Function: This routine accepts an octal number from the standard input device and converts it to internal 16-bit binary form. Input: The individual digits of the octal number are received in ASCII through a call to a standard I/O routine. The valid digits are 0 through 7. An ASCII code other than for a valid digit will terminate the routine. Output: A 16-bit binary number is returned in the DX register. Registers used: Only DX is modified. It returns the result. Routines called: STDIN ______________________________________________________________________________ OCT8OUT Function: This routine accepts an 8-bit binary number in the DL register, converts it to ASCII octal form and sends it to the standard output device. Input: Upon entry an 8-bit binary number is in the DL register. Output: A string of ASCII digits representing an Octal number is sent out through the standard output device. Registers used: No registers are modified. DL is used for input. Routines called: STDOUT ______________________________________________________________________________ OCT16OUT Function: This routine accepts 16-bit binary number in the DX register, converts it to ASCII octal form and sends it to the standard output device. Input: Upon entry a 16-bit binary number is in the DX register. Output: A string of ASCII digits representing an octal number is sent out through the standard output device. Registers used: No registers are modified. DX is used for input. Routines called: STDOUT ______________________________________________________________________________ HEX16IN Function: This routine accepts a hexadecimal number from the standard input device and converts it to internal 16-bit binary form. Input: The individual digits of the hexadecimal number are received in ASCII through a call to a standard I/O routine. The valid digits are 0 through 9 and A through F. An ASCII code other than for a valid digit will terminate the routine. Output: A 16-bit binary number is returned in the DX register. Registers usnd: Only DX is modified. It returns the result. Routines called: STDIN ______________________________________________________________________________ HEX8OUT Function: This routine accepts an 8-bit binary number in the DL register, converts it to ASCII hexadecimal form and sends it to the standard output device. Input: Upon entry an 8-bit binary number is in the DL register. Output: A string of ASCII digits representing a hexadecimal number is sent out through the standard output device. Registers used: No registers are modified. DL is used for input. Routines called: STDOUT ______________________________________________________________________________ HEX16OUT Function: This routine accepts a 16-bit binary number in the DX register, converts it to ASCII hexadecimal form and sends it to the standard output device. Input: Upon entry a 16-bit binary number is in the DX register. Output: A string of ASCII digits representing a hexadecimal number is sent out through the standard output device. Registers used: No registers are modified. DX is used for input. Routines called: STDOUT ______________________________________________________________________________ _ DEC16IN Function: This routine accepts a decimal number from the standard input device and converts it to internal 16-bit binary form. Input: The individual digits of the decimal number are received in ASCII through a call to a standard I/O routine. The valid digits are 0 through 0. An ASCII code other than for a valid digit will terminate the routine. Output: A 16-bit binary number is returned in the DX register. Registers used: Only DX is modified. It returns the result. Routines called: STDIN ______________________________________________________________________________ DEC8OUT Function: This routine accepts an 8-bit binary number in the DL register, converts it to ASCII decimal form and sends it to the standard output device. Input: Upon entry an 8-bit binary number is in the DL register. Output: A string of ASCII digits representing a decimal number is stored in a buffer called TBUFF and then sent out through the standard output device. Registers used: No registers are modified. DL is used for input. Segments referenced: DATAS is a data segment which contains TBUFF Routines called: STDOUT ______________________________________________________________________________ DEC16OUT Function: This routine accepts a 16-bit binary number in the DX register, converts it to ASCII decimal form and sends it to the standard output device. Input: Upon entry a 16-bit binary number is in the DX register Output: A string of ASCII digits representing a decimal number is stored in a buffer called TBUFF and then sent out through the standard output device. Registers used: No registers are modified. DX is used for input. Segments referenced: DATAS is data segment which contains TBUFF Routines called: STDOUT ______________________________________________________________________________ >>>>> Physical EOF BINARY.DOC <<<<<