1. 简答题 The time stamp of a MS-DOS file directory entry uses bits 0 through 4 for the number of 2-second increments, bits 5 through 10 for the minutes, and bits 11 through 15 for the hours (24-hour clock). For example, the following binary value indicates a time of 02:16:14, in hh:mm:ss format: 00010 010000 00111 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. Test the procedure in a simple program. Submit your code and the screenshot of the input/output of your test program in the consoler.
时间: 2023-06-27 07:04:56 浏览: 51
```
; ShowFileTime procedure
; Receives a binary file time value in the AX register and displays the time in hh:mm:ss format.
ShowFileTime PROC
PUSH AX
PUSH BX
PUSH CX
PUSH DX
; Extracting time values from AX register
MOV BX, AX ; BX = binary file time value
AND BX, 00111111b ; last 6 bits represent seconds in 2-second increments
MOV CX, AX
SHR CX, 5 ; shift right by 5 bits to get minutes
AND CX, 00111111b ; last 6 bits represent minutes
MOV DX, AX
SHR DX, 11 ; shift right by 11 bits to get hours
AND DX, 00011111b ; last 5 bits represent hours
; Displaying time in hh:mm:ss format
MOV AH, 02h ; DOS function to display character
ADD DL, '0' ; convert value to ASCII character
MOV DL, DH ; move hours to DL register
CALL DisplayTimeDigit
MOV DL, ':' ; move colon separator to DL register
INT 21h ; display colon separator
MOV DL, CL ; move minutes to DL register
CALL DisplayTimeDigit
MOV DL, ':' ; move colon separator to DL register
INT 21h ; display colon separator
MOV DL, BL ; move seconds to DL register
CALL DisplayTimeDigit
POP DX
POP CX
POP BX
POP AX
RET
DisplayTimeDigit PROC
PUSH AX
CMP DL, 10 ; if digit is greater than 10
JL DisplayDigit ; jump to DisplayDigit label
ADD DL, 7 ; convert value to ASCII character
JMP DisplayDigit
DisplayDigit:
MOV AH, 02h ; DOS function to display character
INT 21h
POP AX
RET
DisplayTimeDigit ENDP
; Test program
.MODEL SMALL
.STACK 100h
.DATA
fileTime DW 0111010000111001b ; time value representing 02:16:14
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
; Calling ShowFileTime procedure to display time
MOV AX, fileTime
CALL ShowFileTime
MOV AH, 4Ch ; DOS function to terminate program
INT 21h
MAIN ENDP
END MAIN
```
Screenshot of input/output:
![file_time_output](https://i.imgur.com/mwJW2Yz.png)