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

Program is for an assembly language class. Should be usable with intel 8088. The

ID: 3544164 • Letter: P

Question

Program is for an assembly language class. Should be usable with intel 8088.

The DOS Services function number 2Ah returns the current date. To call use: mov ah, 2Ah int 21h Your program may only issue this call only once, save all values in memory locations for later use. The results are then left in the following registers: DH = month (1 to 12) DL = day (1 to 31) CX - year (4 digit number) AL - day of week (0 to 6) You are to display the results as: Today's date is: 10-9-2013 You will need to use the print character function (2h) to display the dashes, the display string function (9h), and the PutDec procedure from the book's link library (util.lib). You must copy util.lib from the book cd in order to complete this assignment. Copy the file into the same directory as your assembly programs. You will need this file for the rest of the semester. You will need to use the following command to link your program with the util library: link myProg,util; PutDec expects a word sized value so you must extend the byte sized values to word sized before calling PutDec. mov dl, 9 mov dh,0 ; now the dl value is extended into dh mov ax, dx call PutDec remember that you need to include the line: .code extra PutDec: near at the beginning of your code segment to include information for the assembler that PutDec is an external procedure that will be added at link time.

Explanation / Answer

.MODEL SMALL .STACK 100H .DATA PROMPT DB 'Current System Time is : $' TIME DB '00:00:00$' ; time format hr:min:sec .CODE MAIN PROC MOV AX, @DATA ; initialize DS MOV DS, AX LEA BX, TIME ; BX=offset address of string TIME CALL GET_TIME ; call the procedure GET_TIME LEA DX, PROMPT ; DX=offset address of string PROMPT MOV AH, 09H ; print the string PROMPT INT 21H LEA DX, TIME ; DX=offset address of string TIME MOV AH, 09H ; print the string TIME INT 21H MOV AH, 4CH ; return control to DOS INT 21H MAIN ENDP ;**************************************************************************; ;**************************************************************************; ;------------------------- Procedure Definitions ------------------------; ;**************************************************************************; ;**************************************************************************; ;**************************************************************************; ;------------------------------ GET_TIME --------------------------------; ;**************************************************************************; GET_TIME PROC ; this procedure will get the current system time ; input : BX=offset address of the string TIME ; output : BX=current time PUSH AX ; PUSH AX onto the STACK PUSH CX ; PUSH CX onto the STACK MOV AH, 2CH ; get the current system time INT 21H MOV AL, CH ; set AL=CH , CH=hours CALL CONVERT ; call the procedure CONVERT MOV [BX], AX ; set [BX]=hr , [BX] is pointing to hr ; in the string TIME MOV AL, CL ; set AL=CL , CL=minutes CALL CONVERT ; call the procedure CONVERT MOV [BX+3], AX ; set [BX+3]=min , [BX] is pointing to min ; in the string TIME MOV AL, DH ; set AL=DH , DH=seconds CALL CONVERT ; call the procedure CONVERT MOV [BX+6], AX ; set [BX+6]=min , [BX] is pointing to sec ; in the string TIME POP CX ; POP a value from STACK into CX POP AX ; POP a value from STACK into AX RET ; return control to the calling procedure GET_TIME ENDP ; end of procedure GET_TIME ;**************************************************************************; ;------------------------------- CONVERT --------------------------------; ;**************************************************************************; CONVERT PROC ; this procedure will convert the given binary code into ASCII code ; input : AL=binary code ; output : AX=ASCII code PUSH DX ; PUSH DX onto the STACK MOV AH, 0 ; set AH=0 MOV DL, 10 ; set DL=10 DIV DL ; set AX=AX/DL OR AX, 3030H ; convert the binary code in AX into ASCII POP DX ; POP a value from STACK into DX RET ; return control to the calling procedure CONVERT ENDP ; end of procedure CONVERT ;**************************************************************************; ;--------------------------------------------------------------------------; ;**************************************************************************; END MAIN