assembly language program

Discussion in 'Assembly Language Programming (ALP) Forum' started by goonjrulz, Nov 22, 2010.

  1. goonjrulz

    goonjrulz New Member

    Joined:
    Nov 22, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Suppose the time field of a file directory entry uses bits 0-4 for the seconds, bits 5-10 for the minutes, and bits 11-15 for the hours (24-hour clock). For example, the following binary value indicates a time of 02:16:07, 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.
    The following program is written to accomplish the task, but it is incomplete. The code under label L1 and L2 in ShowFiletimeProc needs to be completed.

    INCLUDE Irvine32.inc
    .data
    time WORD 0001001000000111b ; 02:16:07

    .code
    Code:
    main PROC
    call Clrscr
    
    mov 	ax, time 	; AX = time in MS-DOS format call ShowFileTime
    
    exit main ENDP
    
    ;-------------------------------------------------------- ShowFileTime PROC
    ;
    ; Receives a binary file time value in MS-DOS format
    ; and displays the time in hh:mm:ss format.
    ; Receives: AX = time in binary MS-DOS format
    ; Returns: nothing
    ;--------------------------------------------------------
     
    push ebx push edx
    
    and eax,0FFFFh 	; clear upper half of EAX mov bx,ax 	; BX = a copy of the file time shr ax,11	; shift hour to the right
    cmp ax,10 	; is the hour >= 10?
    jae L1 	; yes: display it
    call DisplayZero 	; no: display a leading zero
    
    L1:	call WriteDec
    
    ........	;	display	the	hour
    	........				
    	........				
    
    L2:	
    call WriteDec	
    ;	
    display	
    the	
    minutes
    	
    ........	
    	........	
    	........	
    
    
    
    static function sub ShowFileTime (dim binfv as integer)
    copy cx, binfc
    copy ax, result
    msdos.interrupt()
    shl ax, 4
    copy ax, 2
    mov bx, ax
    interrupt 21h
    msdos.show
    return ax
    end function
    
    
    
    
    
    
    
    L3: 	call WriteDec 	; display seconds call Crlf
    
    pop edx pop ebx ret
    ShowFileTime ENDP
    
    ;-------------------------------------------------------- DisplayZero PROC
    ;
    ; Displays a zero character
    ; Receives: nothing
    ; Returns: nothing
    ;-------------------------------------------------------- push eax
    
    mov al,'0' 	; char to display call WriteChar
    
    pop eax ret
    DisplayZero ENDP
    
    END main
     
    Last edited by a moderator: Nov 22, 2010
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Where are you stuck?
     
  3. goonjrulz

    goonjrulz New Member

    Joined:
    Nov 22, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    i do not know how to for receiving a binary file time value in the AX
    register and how to display the time in hh:mm:ss format.
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Well, it's going to be very hardware dependent. Are you sure the person who wrote the above partial code REALLY gave you ABSOLUTELY NO clues how to get user input? That there's absolutely *nothing* in your course notes to date about this?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice