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

The time stamp of a given file in a file directory uses a total of 16 bits. Bits

ID: 3823191 • Letter: T

Question

The time stamp of a given file in a file directory uses a total of 16 bits.
Bits 0-4 are used for the number of two second increments.
Bits 5-10 are used for the number of minutes.
Bits 11-15 are used for the hours using a 24-hour clock.

For example, the time 02:16:14 in hh:mm:ss format converts to 00010 010000 00111 in binary.

Write a procedure that receives a binary file time value in the AX register.
Display the time onscreen in hh:mm:ss format.

This is for x86 processors in Microprocessor Assembly Language. Please provide documentation for easy understanding.

Explanation / Answer

The folowing program receives file time and stores in AX and converts to ASCII time. The digits of the number must be pushed in the stack in reverse order:

ShowFileTime PROC ; Receive FileTime in AX and display it in hh:mm:ss format
mov dx,ax ; store FileTime in DX
and al,11111B ; mask to take the 2-seconds value
shl al,1 ; multiply it by 2 to get number of seconds
call ConvertNumber ; convert seconds to ASCII in the stack

mov ax,dx ; get FileTime in AX again
and ax,11111100000B ; mask to take the minutes
shr ax,5 ; shift number of minutes to right place
call ConvertNumber ; convert minutes to ASCII in the stack

mov ax,dx ; get FileTime in AX again
and ax,1111100000000000B ; mask to take the hours
shr ax,11 ; shift number of hours to right place
call ConvertNumber ; convert hours to ASCII in the stack

pop ax ; eliminate the last stored colon
mov cx,8 ; will show 8 characters
show_time:
pop dx ; take the next character in DL
mov ah,2 ; AH=VIDEO_OUTPUT DOS function
int 21H ; show the character in the screen
loop show_time ; repeat for 8 characters

ret ; return to caller program
ShowFileTime ENDP

ConvertNumber PROC ; Convert two-digit AL value to ASCII and push it in the stack
aam ; separate the digits in AH (first) and AL (second)
add ax,'00' ; convert both to ASCII
push ax ; push the second digit stored in AL
mov al,ah ; pass first digit to AL
push ax ; push the first digit
mov al,':' ; load a colon
push ax ; push the separator
ret ; return to caller
ConvertNumber ENDP

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