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

Note: the four exercises must be included in ONE project using ONE assembly file

ID: 3747567 • Letter: N

Question

Note: the four exercises must be included in ONE project using ONE assembly file. Just separate in the file the exercises using clear comments. Programming Exercise I (6 points): The objective of this exercise is to write a program that converts a value v of a decimal digit d into the 9. Therefore, AL will ASCII code of the digit d. We assume that the register AL contains a value between 0 and contain the value of a decimal digit '0' to '9. You do not have to test AL for the range. Your program I) must store in the register DL the ASClIl code of the character, and 2) must display the character using the function WriteChar Example. If AL will contain the value 4. Your program 1) must store in DL the ASCII code of 4, ie. DL34h. and 2) must display the character 4 using the built-in function W To test our program, you must initialize AL to various values varying from 0 to 9 (e.g. MOV AL, 06h just before your instructions of the program you wrote. Programming Exercise 2 (24 points): (Implementing WriteHexByte) The objective of this exercise is to write a program that implements the function WriteHexByte to display hexadecimal on the console the byte contained in the register AL. We assume that AL contains a hexadecim number that uses only decimal digits (i.e. 0 to 9). Therefore, AL will contain a value such that both nibbles tal only the values from 0 to 9. For example, if AL 94h 1001 0100)2, then this content is valid because d most significant nibble (1001)2 and the least significant nibble (0100)2 are in the range [0-9]. The value 5Ah invalid because the least significant nibble ((1010)2 - Ah) is not in the range [0-9]. Given a valid value in A your program must I) store in the register DH the ASCIl code of the most significant nibble. 2) store in the register DL the ASCll code of the least significant nibble. 3) Display (using WriteChar) on the console the character stored in DH (recall that Writechar AL for the character to display). 4) Display (using WriteChar) on the console the character stored in DL. 5) Display 'h' to indicate that the number is a hexadecimal number 6) 'Display' the 'line feed' character (ASCIl code is 0Ah) to go to the next line. 7) Display' the 'carriage' character (ASCIl code is 0Dh) to go to the next line

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