a) Write a procedure called DisplayHexDigit that takes as input a number between 0 and 15 stored in BX register and prints it in hexadecimal.
b) Write a procedure called DisplayHexByte that takes as input a number between 0 and 255 stored in BX register and prints it in hexadecimal. Procedure DisplayHexByte should call DisplayHexDigit to print the number.
c) Write a procedure called DisplayHexWord that takes as input a number between 0 and 65535 stored in BX register and prints it in hexadecimal. Procedure DisplayHexWord should call DisplayHexByte to print the number.
d) To test these procedures your main program should read a number from the input between 0 and 65535 and depending on the range that the input number falls call one of the above procedure.
Here are some sample execution scenarios:
1. Randomly generate a positive integer n (2<= n <=5).
2. Read n positive decimal integers from the standard input, store the n integers in an array and display
each integer on a separate line in hexadecimal format.
3. Use DumpMem function to display the contents of the corresponding memory locations.
1. Use Randomize and RandomRange to generate a random integer n.
2. In a loop, use ReadInt to read each integer.
3. Use WriteHex to write each integer on the screen.
4. Use DumpMem to display memory contents.
These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.INCLUDE Irvine32.inc
rndmsg BYTE "Generated random number is ",0
inpmsg BYTE "Enter next number: ",0
outmsg BYTE "Numbers of array in HEX format are:",0
memmsg BYTE "DumpMem called: ",0
array DWORD 5 DUP(0)
n DWORD 0
mov eax, 6 ; set limit to 6 (because n <= 5)
call Randomize ;re-seed the random number generator
call RandomRange ;generate random number n
cmp eax, 2 ;check if n < 2
jb NEXT_RND ;if yes, loop until n >= 2
mov edx, OFFSET rndmsg ;print out the generated number, so we can see it
mov n, eax ;save the number to memory location
mov ecx, eax ;initialize the counter for reading loop
mov esi, OFFSET array ;initialize the pointer
mov edx, OFFSET inpmsg ;print out the instruction for input
call ReadInt ;read next number from console
mov [esi], eax ;store it in corresponding memory location of the array
add esi, 4 ;increment the pointer, so it points to the next element
loop NEXT_INP ;loop n times
mov edx, OFFSET outmsg ;print out the output notification
mov ecx, n ;initialize the counter for printing loop
mov esi, OFFSET array ;initialize the pointer...
By purchasing this solution you'll be able to access the following files:
Solution1.asm and Solution2.asm.