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

Write a program to convert the hexadecimal contents of a block of RAM into print

ID: 1715964 • Letter: W

Question

Write a program to convert the hexadecimal contents of a block of RAM into printable ASCII characters and leave the results in another block of RAM. Each byte in the source block contains two 4-bit hex digits (nibbles) and the printable ASCII characters corresponding to each nibble are 8-bits each therefore each byte from the source block will be converted to two bytes in the result block (known as "ASCII hex"). Your program will be in the code section starting at $0000 and you will have three variables that will be in the variable/data section located at $0100: the first variable will contain the 2-byte starting address of the block to be converted, the second will contain the 2-byte starting address of the result block and the third variable will be the 1-byte number of bytes to convert (please define the variables in this order). Your program should include a subroutine to do the conversion of each nibble into its corresponding ASCII code.

Explanation / Answer

answer-

Nibble ASCII Nibble ASCII Hex Binary Char Hex Binary Char 0 0000 30 8 1000 38 1 0001 31 9 1001 39 2 0010 32 A 1010 41 3 0011 33 B 1011 42 4 0100 34 C 1100 43 5 0101 35 D 1101 44 6 0110 36 E 1110 45 7 0111 37 F 1111 46

Source program:
LXI SP, 27FFH : Initialize stack pointer
LXI H, 2000H : Source memory pointer
LXI D, 2200H : Destination memory pointer
MVI C, O5H : Initialize the counter
BACK: MOV A, M : Get the number
CALL ASCII : Call subroutine ASCII
STAX D : Store result
INX H : Increment source memory pointer
INX D : Increment destination memory pointer
DCR C : Decrement count by 1
CJNZ : if not zero, repeat
HLT : Stop program execution subroutine ASCII
ASCII: CPI, OAH : Check if number is OAR
JNC NEXT : If yes go to next otherwise continue
ADI 30H
JMP LAST
NEXT: ADI 37H
LAST: RET : Return to main program
Subroutine:
Subroutine 'ASCII' converts a hexadecimal digit to ASCII.The digit is passed using accumulator and the result is stored in accumulator.Stack starts From 27FEH to 27FDH.
FLOWCHART



Note: The ASCII Code (American Standard Code for Information Interchange) is commonly used for communication. In such cases we need to convert binary number to its ASCII equivalent. It is a seven bit code. In this code number 0 through 9 are represented as 30 through 39 respectively and letters A through Z are represented as 41H through 5AH. Therefore, by adding 30H we can convert number into its ASCII equivalent and by adding 37H we can convert letter to its ASCII equivalent.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote