0% found this document useful (0 votes)
17 views4 pages

EXP2 - HEX To ASCII Conversion

Uploaded by

ahmed alhammad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views4 pages

EXP2 - HEX To ASCII Conversion

Uploaded by

ahmed alhammad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Experiment 2

HEX to ASCII conversion


Theory:
ASCII table used to display various alpha-numeric symbols on an output device such as printer,
LCD display, RS-232 console … etc.
Since all CPU calculations are done as binary (hex for simplicity) we need to convert the HEX
values to its ASCII code representation

Ex
(1F)H  3146
Since HEX numbers are 0-9 then A-F which gives as two ASCII ranges (30-39 for 0-9,41 to 46
for A-F) we need to compare each value with 10 if it is lower than 10 ASCII is 30 +Value else
ASCII is 41h+ value - Ah or 37+value
In this experiment we convert only numbers from 00-0F .
Example
1
1<10 then ASCII = 30+1= 31

B
B>10 then ASCII = 37+B = 42h
Experiment:
Convert the series of hex numbers in memory 1200 to 120F to ASCII and store the results
in 1300-130F
Flow chart
Start

Set SI = 1200
DI = 1300
Set counter CL=0F

Load [SI] ->


AL

AL < 0A No AL = AL + 07H

yes

AL = AL+ 30H

Store AL ->
[DI]

DCR CL

If CL=0

END
Instruction used in this experiment

1- INC , DEC:
INC REG
DEC REG
INC MEM
DEC MEM
REG could be 8 bit [AL, AH, BL, BH, CL, CH, DL, DH] or 16 bit [AX, BX, CX, DX, SP,
BP, SI, DI]

Mem could addressed as:


a- Direct DEC [1200] ; memory (DS:1200) -- ;
b- Register indirect INC [BX] ; memory (DS:BX) ++;
[BX, BP, SI, DI] could be used.
BX, SI, DI are for data segment DS
BP is for Stack segment SS
c- Others (not used in the LAB)
Those instructions affects the FLAG registers (Zero flag and others)

Compare instruction CMP X, X

Compare two registers, memory, and direct value.


2- Jump instructions conditional jumps depends on compare instruction (CMP) results or
directly check the flag register
Assembly Program

MOV SI, 1200


MOV DI, 1300
MOV CL,10
L1: LODSB
CMP AL, 0A
JB SMALL;
ADD AL, 07H
SMALL:ADD AL, 30H
STOSB
DEC CL
JNZ L1
INT 3

Procedure

1- Connect the Kit to 101 PS/2 Keyboard


2- Press SB 1200 to enter sub byte mode starting from memory 1200 in the data segment
3- Insert the bytes (00,01 …. 0F)
4- Press A followed by Enter
5- Start Address is: 1000
6- Write the program line by line followed by enter
7- Write down the memory locations for correspondent to L1, SMALL lables and JB small
instruction.
8- End the program by INT 3 instead of HLT
9- Press (.) to return to the Main screen
10- Re assemble the program starting from memory location of JB instruction just to correct
the jump location.
11- Write R to read the registers, initially the should be 0000
12- Write GO 1000 followed by Enter. The Program should end with BRK PT (Break point)
13- Write R to read the registers after Executing.
14- Results are from memory 1300 to 130F

Discussion

1- Explain Jump short and Jump long


2- Modify the program so it can convert 8 bit number such as A3 to 16 bit 4133

You might also like