Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please please anyone who can help me in assembly language Introduction: how to p

ID: 3695684 • Letter: P

Question

please please anyone who can help me in assembly language

Introduction:
how to print the number in Hex. Approach follows:
1) Assume that it is a 1 byte number which consists of two hex numbers. In our
case here, the number is 9C as indicated by line #1.
2) We first process and print the first hex digit (the left 4 bits) and then the second
hex digit.
3) Please note that two sections of code (lines 9~13 and 17~21) are identical.
1 mov bl, 9C
2 and bl, f0
3 mov cx, 4
4 shr bl, 1
5 loop (to the instruction above)
6
7 mov ah, 2
8 mov dl, bl
9 add dl, 30
10 cmp dl, 3A
11 JL (to the next “int 21”, the 2nd line down)
12 add dl, 7
13 int 21
14
15 mov dl, 9C
16 and dl, 0f
17 add dl, 30
18 cmp dl, 3A
19 JL (to the next “int 21” the 2nd line down)
20 add dl, 7
21 int 21
22
23 mov ah, 4c
24 int 21
II. Assignment:
1. Step 1:
a. Use debug to assemble the sample program and write this file to disk.
Name this file “prnHex.com”
b. Run this file at DOS command.
c. Understand how this program works.
2. Step 2:
a. Write an assembly program based upon this.
b. Name this program “p2Hex.asm”.
c. Among other modifications, you will need to:
i. Use labels for Loop and JL instructions.
ii. Declare a variable whose Hex value is 9C.
iii. Have the program print the following:
The Hex number is 9C
Where 9C is not hard-coded as part of the string.
iv. Remember that in Debug default number format is Hex, but not in
Assembly Language program.

Explanation / Answer

LXI H, 9C ; storing data into array and pointing to pointer
MOV B,M ; moving data into Bregister
MOV A,B ; copying again data to A register
ANI OFH ; upper nibble masking
INX H   
MOV M,A ; lower nibble (remaining part) storing
MOV AX,A;
INT 21H ;printing lower nibble
MOV A,B
ANI FOH ;swapping lower nibble with upper nibble
RRC ;rotating for 4 bits
RRC
RRC
RRC
INX H
MOV M,A ;upper nibble storing
MOV AX,A;
INT 21H ;printing upper nibble