Question
MASM Assembly Language x86 Processor - DOS File Time Hello Chegg experts, I have a working code for the assignment below, but I have to
MASM Assembly Language x86 Processor - DOS File Time
Hello Chegg experts, I have a working code for the assignment below, but I have to fix it with further instructions.
Here are the requirements:
- Use five shift instructions only. You can choose any from shl, shr, shld, or shrd - Don't use AND - Don't use MUL You can still make use of call prefixZero and mov al,':' call WriteChar without need change of others
And this is the assignment:
DOS_file_time (Chapter 7, Supplied)
Suppose the time field of a file directory entry uses bits 0-4 for 2-second increments, bits 5-10 for minutes, and bits 11-15 for hours (24-hour clock). Write a procedure named ShowFileTime that receives a binary file time value in the AX register and displays the time in hh:mm:ss format. For example, the binary 0001 0010 0000 0111 indicates a time of 02:16:14, in hh:mm:ss format:
00010 010000 00111 |
For simplicity, we want to input 4-digit hexadecimal and show its binary to verify. For this, you can call ReadHex and WriteBinB. Then you can call your ShowFileTime to display the file time. You may call WriteDec, WriteChar, and consider prefixed zeros. Run your program; the screen will be like this:
C:\Teaching\CSCI241\KipIrvine\SixthEdition\Prog_Ex_SM\ch07\Debug>project Please enter 16-bit hexadecimal (4-digit, e.g., 1207): A103 Your equivalent binary is 1010 0001 0000 0011 Your DOS file time is 20:08:06 C:\Teaching\CSCI241\KipIrvine\SixthEdition\Prog_Ex_SM\ch07\Debug>project Please enter 16-bit hexadecimal (4-digit, e.g., 1207): 1207 Your equivalent binary is 0001 0010 0000 0111 Your DOS file time is 02:16:14 |
Any reusable helper procedure is preferred, such as displaying a leading zero character if the value of hours, minutes, or seconds less than 10, else displaying an original two digits.
--------------------------------------------------------------------------
Now this is my working code that needs to be fixed.
INCLUDE Irvine32.inc
.data msg1 BYTE "Please enter 16-bit hexadecimal (4-digit, e.g., 1207): ",0 msg2 BYTE "Your equivalent binary is ",0 msg3 BYTE "Your DOS file time is ",0 msg4 BYTE "Error... Invalid display...", 0
.code main PROC mov edx,OFFSET msg1 call WriteString call ReadHex jnz continue mov edx,OFFSET msg4 call WriteString call Crlf call Crlf exit
continue: mov edx,OFFSET msg2 call WriteString
mov ebx,TYPE WORD call WriteBinB call Crlf
mov edx,OFFSET msg3 call WriteString call ShowFileTime call Crlf exit
main ENDP
ShowFileTime PROC mov ecx,eax mov edx,eax shr ecx,11 call prefixZero mov al,':' call WriteChar mov ecx,edx shr cx,5 and cx,3Fh call prefixZero mov al,':' call WriteChar mov ecx,edx and ecx,001Fh mov eax,ecx mov bx,2 mul bx mov ecx,eax call prefixZero ret ShowFileTime ENDP
prefixZero PROC cmp ecx,9 ja move mov eax,0 call WriteDec move: mov eax,ecx call WriteDec ret prefixZero ENDP
END main
Thank you in advance...
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started