Question: CSC 2 2 1 Project 0 5 : MS - DOS Date - Time Formatter ( Unpacking ) Objective: Use the provided starter code to:

CSC221 Project 05: MS-DOS Date-Time Formatter (Unpacking)
Objective: Use the provided starter code to:
1. Unpack a 32-bit MS-DOS Date-Time format stored in the EDX register.
2. Extract and display the year, month, day, hour, minute, and second fields.
Starter Code:
The provided starter code:
1. Gets the current date and time from the system.
2. Packs the year, month, day, hour, minute, and second into the 32-bit EDX register, formatted
as follows:
Bit Index Field Bits Range
02 Second 3030 take 65 bits second shift 3(divide by 8) to get 3 bits
38 Minute 6059
913 Hour 5023
14-15 Empty
1620 Day 5131
2124 Month 4112
2531 Year Offset 70127(19802107)
The year is stored as an offset from 1980(e.g.,1999 is stored as 19).
Your Task:
1. Unpack the 32-bit value in EDX:
o Extract each field (year, month, day, hour, minute, second) using bitwise operations
(AND, SHR, etc.).
o Restore the full year by adding 1980 to the unpacked value.
o Restore the seconds by multiplying the 3-bit value by 8(SHL al,3).
2. Display the unpacked values:
o Print each field in the format:
Year: YYYY, Month: MM, Day: DD, Hour: HH, Minute: MM, Second: SS.
Steps to Complete the Project
1. Unpacking Logic (Procedure: unpack):
Write a procedure called unpack that:
1. Receives the packed 32-bit value in EDX.
2. Using the procedure sub given extracts and print the fields for time using:
o Shift right by 16(remove time)
o Days (bits 04): mask off month and year with AND
o Months (bits 58): Shift right by 5 and mask with AND 01111b
o Years (bits 915): Shift right by 9 and then add 1980.
3. Using the procedure sub given extracts and print the fields for time using:
o Seconds (bits 02): And 0111b and shift left by 3(multiple 8).
o Minutes (bits38): Shift right by 3 and mask with AND 0111111b.
o Hours (bits 913): Shift right by 9 and mask with AND 0111111111b.
Note: these instructions are general guidelines, there could be minor errors
Program Structure
1. Call the starter code to populate the EDX register with the packed 32-bit date-time value.
2. Call the two Unpack and Display procedures.
Program
Input: Unpacked fields from registers.
Output: Formatted date-time string to the console.
Requirements:
Submitted program must build, code that does not build will not be graded
Correctly format code, special care given to indentations and spacing, goal is for readability
Comment all code, have comment header with description, project number, authors name
and date of last modification Procedures (excluding main) must have complete
Descriptions, Receives, Returns, Requires
Use the course convention for naming the submitted file
Example User Interaction
The current date is (YYYY:MM:DD): 2024:11:23
The current time is (HH:MM:SS): 12:16:7
YYYY YYYM MMMD DDDD 00HH HHHM MMMM MSSS
edx =01011001011101110001100010000000b
The current date is (YYYY:MM:DD): 2024:11:23
The current time is (HH:MM:SS): 12:16:0
Deliverables
1. A well-documented MASM assembly program including:
o File name, project description, author, and last modified date.
o Comments for each block of code to explain its purpose.
2. The program must:
o Use the starter code to pack the value into EDX.
o Include your unpack and display procedures.
o Use Irvine32 library procedures for I/O operations.
o Use only the procedures we discussed in class
o Keep the existing structure, dont change anything but the two Unpack and Display
procedures.
Helpful Hints
Use masking (AND) and shifting (SHR) to extract specific bits for each field.
Test your unpacking logic thoroughly by comparing output with the original values.
Use the provided WriteBin function (or mshow macro) to see the packed binary value or even
better use the debugger on visual studio.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!