I am doing assembler assignment in computer science class. We use visual studio
ID: 3941514 • Letter: I
Question
I am doing assembler assignment in computer science class. We use visual studio 2012 or 2015 to do this assembler. I have done 1 ~ 4 but I don't know 5~7 below. I wrote code for 5~7(bolded part below) but it is wrong, but I don't know how should I edit it. I need help for number 5~7. Below is the instruction.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1.Clear the display.
2.Display the string "CS2810 Fall Semester 2016" on row 7 column 0 of the display.
3.Display the string "Assembler Assignment #2" on row 8, column 0.
4.Display your name on row 9, column 0 of the display.
5.Prompt the user for FAT16 file time in hex format and allow the user to enter it on row 11, column 0.
6.Decode the entered file time and convert it to ASCII for display.
7.Display the converted file time on row 12, column 0.
8.Thoroughly test your project before submitting.
------------------------------------------------------------------------
* How to decode FAT16 time
1. Display semester, assignmnet, name
2. Prompt the user for FAT16 time value in Hex.
3. Read Hex Value
4. Decode Binary time field to ASCII
a. Preserve a copy of EAX for later steps
b. Isolate the first 5 bits and move them right
c. Convert binary hour to decimal digits
d. Convert the decimal values to ASCII
e. Move to the output display area
f. Restore EAX to its original state
g. Complete steps similar to b though e for minutes and seconds.
5. Display the converted time.
----------------------------------------------------------------
The Irvine library contains a number of Procs and Macros that simplify I/O in MASM.
On this assignment you will use three of the Procs in the library:
- Clrscr - clears the command window.
- Gotoxy - positions the cursor at the row and column specified in register sections DH and DL
- WriteString - displays the string at the address specified in the EDX register. The string must be 0 terminated.
- ReadHex - allows the user to enter a hex value which is converted to binary and placed in EAX
The sample program shows how to call the Procs.
Note that with any Procs that require values to be in registers, the registers MUST be set PRIOR to calling the Proc.
The following MASM instructions will also be used on this assignment.
MOV - the MOV instruction copies from register to register, register to memory and memory to register.
Sample formats are:
MOV ECX, EAX
MOV word ptr [displayTime], ax
ROR - the Rotate Right command shifts the bits of a register to the right. As bits are shifted out on the right, they rotate around and are placed back into the left. An example is ROR AX,8.
SHR - The Shift Right command shifts the bits of a register to the right. As bits are shifted out to the right, zeros are placed in the left. An example is SHR AX, 11
SHL - The Shift Left command shifts the bits of a register to the left. As bits are shifted out to the left, zeros are brought in on the right.
The effect of the command SHL AX,1 is that of multiplying the AX register by 2.
DIV - The Divide instruction allows for 8, 16 and 32 bit division. In this assignment you will use AX register as the dividend and use an 8-bit register half as the divisor. After the division, the quotient will be in AL and the remainder in AH.
An example is: DIV BL
Note that the dividend is not specified. It is always AX for 8-bit division.
ADD - The add instruction does just what it specifies. In this assignment you will use a form of the add wherein a literal is added to a register. Example: ADD AX, 3030h
AND - This instruction performs a bit-by-bit logical AND between a register and a literal with the result of the AND placed in the specified register. It is used to mask (ie. strip out) bits from a register.
Examples:
AND AX,1111100000000000b
AND AX,F800h
The command window is typically 80 columns (characters) wide and 25 rows (lines) deep.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Here is the code I have done so far:
TITLE CS2810 Assembler Assignment Template
; Student Name: Suyeon Noh
; Assignment Due Date: Sunday, November 20th, 2016
INCLUDE Irvine32.inc
.data
;--------- Enter Data Here
vSemester byte "CS2810 Fall Semester 2016", 0
vAssignment byte "Assembler Assignment #2", 0
vName byte "Suyeon Noh", 0
vTimeField BYTE "--:--:--", 0
.code
main PROC
;--------- Enter Code Below Here
call clrscr
mov dh, 7
mov dl, 0
call gotoxy
mov edx, offset vSemester
call WriteString
mov dh, 8
mov dl, 0
call gotoxy
mov edx, offset vAssignment
call WriteString
mov dh, 9
mov dl, 0
call gotoxy
mov edx, offset vName
call WriteString
call ReadHex
ror ax, 8 ; Means that rotate right on the ax register do 8 bits.
mov cx, ax ; (IMPORTANT!!!) MOV DESTINATION, SOURCE
and ax, 1111100000000000b
shr ax, 11
mov bl, 10
div bl
add ax, 3030h ; add al, 30h add ah, 30h
mov word ptr [vTimeField + 3], ax
mov edx, offset vTimeField
call WriteString
xor ecx, ecx
call readchar
exit
main ENDP
END main
Explanation / Answer
INCLUDE Irvine32.inc
.data
;--------- Enter Data Here
vSemester byte "CS2810 Fall Semester 2016", 0
vAssignment byte "Assembler Assignment #2", 0
vName byte "Suyeon Noh", 0
vTimeField BYTE "--:--:--", 0
.code
main PROC
;--------- Enter Code Below Here
call clrscr
mov dh, 7
mov dl, 0
call gotoxy
mov edx, offset vSemester
call WriteString
mov dh, 8
mov dl, 0
call gotoxy
mov edx, offset vAssignment
call WriteString
mov dh, 9
mov dl, 0
call gotoxy
mov edx, offset vName
call WriteString
call ReadHex
ror ax, 8 ; Means that rotate right on the ax register do 8 bits.
mov cx, ax ; (IMPORTANT!!!) MOV DESTINATION, SOURCE
and ax, 1111100000000000b
shr ax, 11
mov bl, 10
div bl
add ax, 3030h ; add al, 30h add ah, 30h
mov word ptr [vTimeField + 3], ax
mov edx, offset vTimeField
call WriteString
xor ecx, ecx
call readchar
exit
main ENDP
END main
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.