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

I need help coding this in assembly. We are told to use the ReadChar function to

ID: 3907067 • Letter: I

Question

I need help coding this in assembly. We are told to use the ReadChar function to read the character value in and then convert it to ASCII. This includes all values 0 through F.

The objective of this exercise is to write the procedure DigitValue2ASCII that converts a value v of a hexadecimal digit d into the ASCII code of the digit d. The procedure DigitValue2ASCII uses the register AL as parameter. We assume that AL contains a value between 0 and 0Fh=(15)10. Therefore, AL will contain the value of a hexadecimal digit ‘0’ to ‘F’. You do not have to test AL for the range. The procedure DigitValue2ASCII must return in the register DL the ASCII code of the digit d.

Examples:

1) If AL contains the value 4, procedure DigitValue2ASCII returns in DL the ASCII code of ‘4’, i.e. DL = 34h.

2) If AL contains the value 0Ch=(12)10, your procedure return in DL the ASCII code of ‘C’, i.e. DL = 43h.

Explanation / Answer

DigitValue2ASCII:

mov dl,0

mov dl,al

cmp dl,09h

jbe DIGIT_ASCII

add dl,07h

DIGIT_ASCII:

add dl,30h

ret

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