# Assembly Programming Assembly Numbers - Assembly Programming

## What is Assembly Numbers?

Numerical data is generally represented in binary system. arithmetic instructions operate on binary data. when numbers are displayed on screen or entered from keyboard, they are in ASCII form.

So far, we have converted this input data in ASCII form to binary for arithmetic calculations and converted the end result back to binary. the following code shows this −

When the above code is compiled and executed, it produces the following result –

Such conversions, but, have an overhead, and assembly language programming allows processing numbers in a more green way, in the binary form. Decimal numbers can be represented in two forms −

• ASCII form
• BCD or Binary Coded Decimal form

## ASCII Representation

In ASCII representation, decimal numbers are stored as string of ASCII characters. for example, the decimal value 1234 is stored as –

Where, 31H is ASCII value for 1, 32H is ASCII value for 2, and so on. There are four instructions for processing numbers in ASCII representation −

• AAS − ASCII Adjust After Subtraction
• AAM − ASCII Adjust After Multiplication

These instructions do not take any operands and assume the required operand to be in the AL register.

The following example uses the AAS instruction to demonstrate the concept –

When the above code is compiled and executed, it produces the following result−

## BCD Representation

There are two types of BCD representation −

• Unpacked BCD representation
• Packed BCD representation

In unpacked BCD representation, each byte stores the binary equivalent of a decimal digit. for example, the number 1234 is saved as –

There are two instructions for processing these numbers −

• AAM - ASCII Adjust After Multiplication

The four ASCII adjust instructions, AAA, AAS, AAM, and AAD, can also be used with unpacked BCD representation. In packed BCD representation, each digit is stored using four bits. two decimal digits are packed into a byte. for example, the range 1234 is saved as –

There are two instructions for processing these numbers −

• DAS - decimal Adjust After Subtraction

There is no support for multiplication and division in packed BCD representation.

## Example

The following program adds up two 5-digit decimal numbers and displays the sum. It uses the above concepts –

When the above code is compiled and executed, it produces the following result –