You are on page 1of 3

Experiment no: 04

Experiment name: Converting Hexadecimal to Decimal Numbers Using EMU8086.


Requirements: 1. PC/Laptop 2. EMU8086 software
Objectives:
⦁ To familiar with the basic syntax of assembly language.
⦁ To learn how to implement and execute assembly code in EMU8086.
Theory: In Assembly language, a hexadecimal number is typically represented as a
sequence of two?digit pairs. Each digit in the pair represents a power of 16, starting
from the rightmost digit with a power of 16^0 and increasing by one for each
subsequent digit to the left. For example, the hexadecimal number A2 can be
represented as:
A*
16^1
+2*
16^0
whic
h
equa
ls:
160 + 2
or: 162

1
To
convert this representation to decimal, we simply evaluate the expression by
multiplying each digit by its corresponding power of 16 and adding up the results. In
Assembly language, we can load the hexadecimal number into a register using the
MOV instruction. We can then extract each digit from the register using bitwise
operations (such as AND and SHR) or by converting the value to ASCII and subtracting
the ASCII code for the digit '0' or 'A' (depending on whether it represents a numeral
or an alphabetic character). Once we have extracted each digit, we can multiply it by
its corresponding power of 16 using the MUL instruction. This will produce a result
that is twice the size of the original register (e.g., multiplying a byte by a word- sized
value will produce a double-word-sized result), so we need to store it in another
register (such as DX or CX) to prevent overflow. We can then add up all the products
to get the decimal equivalent of the hexadecimal number.

Source Code and output:


2
Discussion:
In this lab i do a operation of : Converting Hexadecimal to Decimal Numbers Using
EMU8086.First i installed EMU8086 and set functionalities properly.Then i followed steps
for completing this task.The idea is to extract the digits of a given hexadecimal number
starting from the rightmost digit and keep a variable dec_value. At the time of extracting
digits from the hexadecimal number, multiply the digit with the proper base (Power of
16) and add it to the variable dec_value. In the end, the variable dec_value will store the
required decimal number.At last, i am abled to complete my task properly and get a
clear concept about converting process in EMU8086.

You might also like