Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DOSSEG
- .MODEL SMALL
- .STACK 100h
- .DATA
- HelloMessage DB 'Hello, world',13,10,'$'
- .CODE
- time proc near
- mov ax,2c00h ;get time from dos
- int 21h
- ;CH HOURS
- ;CL MINS
- ;DH SECS
- ;DL CENTISECS
- PUSH dX
- PUSH cX
- mov ah,0
- mov al,ch ;dividend
- mov cl,10 ;divisor
- div cl ;quotient in al, remainder in ah
- push ax ;save quotient & remainder
- or al,30h ;tens of hours to ascii
- mov dl,al
- mov ah,02h
- int 21h
- pop ax ;restore quotient & remainder
- or ah,30h ;units of hours to ascii numeric
- mov dl,ah
- mov ah,02h
- int 21h
- call do_colon
- pop cx ;restore minutes
- mov ah,0
- mov al,cl
- mov cl,10
- div cl
- push ax ;save quotient & remainder
- or al,30h ;tens of minutes to ascii
- mov dl,al
- mov ah,02h
- int 21h
- pop ax ;restore quotient & remainder
- or ah,30h ;units of minutes to ascii
- mov dl,ah
- mov ah,02h
- int 21h
- call do_colon
- pop dx ;restore secs & cent-secs
- push dx ;& save it again
- mov ah,0
- mov al,dh ;secs
- mov cl,10
- div cl
- push ax ;save tens & units of secs
- or al,30h ;tens of secs to ascii
- mov dl,al
- mov ah,02h
- int 21h
- pop ax
- or ah,30h ;units of secs to ascii
- mov dl,ah
- mov ah,02h
- int 21h
- call do_colon
- pop dx ;restore secs & centi-secs
- mov ah,0
- mov al,dl ;centi-secs
- mov cl,10
- div cl
- push ax ;save tens & units of centisecs
- or al,30h ;tens of centi-secs to ascii
- mov dl,al
- mov ah,02h
- int 21h
- pop ax
- or ah,30h ;units of centi-secs to ascii
- mov dl,ah
- mov ah,02h
- int 21h
- call do_space
- mov ax,2a00h ;get date from dos
- int 21h
- ;Cx year (1980 - 2099)
- ;DH month
- ;DL day
- ;al day of week 0 == sun
- push cx ;save year
- push dx ;save month & day
- mov ah,0
- mov al,dl ;day
- mov cl,10
- div cl
- push ax ;save tens (al) & units (ah) of day
- or al,30h ;tens of day to ascii
- mov dl,al
- mov ah,02h
- int 21h
- pop ax
- or ah,30h ;units of day to ascii
- mov dl,ah
- mov ah,02h
- int 21h
- call do_slash
- pop dx ;restore month (dh)
- mov ah,0
- mov al,dh ;month
- mov cl,10
- div cl
- push ax ;save tens (al) & units (ah) of month
- or al,30h ;tens of month to ascii
- mov dl,al
- mov ah,02h
- int 21h
- pop ax
- or ah,30h ;units of month to ascii
- mov dl,ah
- mov ah,02h
- int 21h
- call do_slash
- pop ax ;year
- mov dx,0 ;clr ms byte of dividend
- mov cx,1000 ;and divide by 1000 to get thousands
- div cx ;quotient in ax, remainder in dx
- push dx ;save remainder
- or al,30h ;into ascii
- mov ah,02h
- mov dl,al
- int 21h
- pop ax ;restore remainder
- mov dx,0 ;clr msb
- mov cx,100 ;get hundreds
- div cx ;quotient in ax, remainder in dx
- push dx ;save remainder
- or al,30h ;into ascii
- mov ah,02h
- mov dl,al
- int 21h
- pop ax ;restore remainder
- mov dx,0 ;clr msb
- mov cx,10 ;get tens
- div cx ;quotient in ax, remainder in dx
- push dx ;save remainder
- or al,30h ;into ascii
- mov ah,02h
- mov dl,al
- int 21h
- pop ax ;restore remainder (units)
- or al,30h ;into ascii
- mov ah,02h
- mov dl,al
- int 21h
- mov ax,@data
- mov ds,ax ;set DS to point to the data segment
- mov ah,9 ;DOS print string function
- mov dx,OFFSET HelloMessage ;point to "Hello, world"
- int 21h ;display "Hello, world"
- mov aX,4c00h ;DOS terminate program function
- int 21h ;terminate the program
- endp
- do_space proc near
- push ax
- push dx
- mov ah,02
- mov dl,' '
- int 21h
- pop dx
- pop ax
- ret
- endp
- do_colon proc near
- push ax
- push dx
- mov ah,02
- mov dl,':'
- int 21h
- pop dx
- pop ax
- ret
- endp
- do_slash proc near
- push ax
- push dx
- mov ah,02
- mov dl,'/'
- int 21h
- pop dx
- pop ax
- ret
- endp
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement