Advertisement
Guest User

Untitled

a guest
Mar 12th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DOSSEG
  2.    .MODEL SMALL
  3.    .STACK 100h
  4.    .DATA
  5. HelloMessage DB 'Hello, world',13,10,'$'
  6.    .CODE
  7.  
  8. time proc near
  9.    mov ax,2c00h                     ;get time from dos
  10.    int  21h
  11.  
  12.  
  13. ;CH HOURS
  14. ;CL MINS
  15. ;DH SECS
  16. ;DL CENTISECS
  17.  
  18.    PUSH dX
  19.    PUSH cX
  20.  
  21.    mov  ah,0
  22.    mov  al,ch                       ;dividend
  23.    mov  cl,10                       ;divisor
  24.    div  cl                          ;quotient in al, remainder in ah
  25.  
  26.    push ax                          ;save quotient & remainder
  27.  
  28.    or   al,30h                      ;tens of hours to ascii
  29.  
  30.  
  31.    mov  dl,al
  32.    mov  ah,02h
  33.    int  21h
  34.  
  35.    pop  ax                          ;restore quotient & remainder
  36.    or   ah,30h                      ;units of hours to ascii numeric
  37.  
  38.    mov  dl,ah
  39.    mov  ah,02h
  40.    int  21h
  41.  
  42.     call do_colon
  43.  
  44.    pop cx                           ;restore minutes
  45.  
  46.    mov  ah,0
  47.    mov  al,cl
  48.    mov  cl,10
  49.    div  cl
  50.  
  51.    push ax                          ;save quotient & remainder
  52.  
  53.    or   al,30h                      ;tens of minutes to ascii
  54.  
  55.    mov  dl,al
  56.    mov  ah,02h
  57.    int  21h
  58.  
  59.     pop ax                          ;restore quotient & remainder
  60.  
  61.    or   ah,30h                      ;units of minutes to ascii
  62.  
  63.    mov  dl,ah
  64.    mov  ah,02h
  65.    int  21h
  66.  
  67.     call do_colon
  68.  
  69.    pop  dx                          ;restore secs & cent-secs
  70.    push dx                          ;& save it again
  71.  
  72.    mov  ah,0
  73.    mov  al,dh                       ;secs
  74.    mov  cl,10
  75.    div  cl
  76.  
  77.     push ax                         ;save tens & units of secs
  78.  
  79.     or  al,30h                      ;tens of secs to ascii
  80.  
  81.     mov dl,al
  82.     mov ah,02h
  83.     int 21h
  84.  
  85.     pop ax
  86.  
  87.     or  ah,30h                       ;units of secs to ascii
  88.     mov dl,ah
  89.     mov ah,02h
  90.     int 21h
  91.  
  92.     call do_colon
  93.  
  94.     pop dx                          ;restore secs & centi-secs
  95.  
  96.    mov  ah,0
  97.    mov  al,dl                       ;centi-secs
  98.    mov  cl,10
  99.    div  cl
  100.  
  101.     push ax                         ;save tens & units of centisecs
  102.  
  103.     or  al,30h                      ;tens of centi-secs to ascii
  104.  
  105.     mov dl,al
  106.     mov ah,02h
  107.     int 21h
  108.  
  109.     pop ax
  110.  
  111.     or  ah,30h                       ;units of centi-secs to ascii
  112.     mov dl,ah
  113.     mov ah,02h
  114.     int 21h
  115.  
  116.     call do_space
  117.  
  118.    mov ax,2a00h                     ;get date from dos
  119.    int  21h
  120.  
  121.  
  122. ;Cx year (1980 - 2099)
  123. ;DH month
  124. ;DL day
  125. ;al day of week 0 == sun
  126.  
  127.     push cx                         ;save year
  128.     push dx                         ;save month & day
  129.  
  130.  
  131.    mov  ah,0
  132.    mov  al,dl                       ;day
  133.    mov  cl,10
  134.    div  cl
  135.  
  136.     push ax                         ;save tens (al) & units (ah) of day
  137.  
  138.     or  al,30h                      ;tens of day to ascii
  139.  
  140.     mov dl,al
  141.     mov ah,02h
  142.     int 21h
  143.  
  144.     pop ax
  145.  
  146.     or  ah,30h                       ;units of day to ascii
  147.     mov dl,ah
  148.     mov ah,02h
  149.     int 21h
  150.  
  151.     call do_slash
  152.  
  153.     pop dx                          ;restore month (dh)
  154.  
  155.    mov  ah,0
  156.    mov  al,dh                       ;month
  157.    mov  cl,10
  158.    div  cl
  159.  
  160.     push ax                         ;save tens (al) & units (ah) of month
  161.  
  162.     or  al,30h                      ;tens of month to ascii
  163.  
  164.     mov dl,al
  165.     mov ah,02h
  166.     int 21h
  167.  
  168.     pop ax
  169.  
  170.     or  ah,30h                       ;units of month to ascii
  171.     mov dl,ah
  172.     mov ah,02h
  173.     int 21h
  174.  
  175.     call do_slash
  176.  
  177.     pop ax                          ;year
  178.     mov dx,0                        ;clr ms byte of dividend
  179.     mov cx,1000                     ;and divide by 1000 to get thousands
  180.     div cx                          ;quotient in ax, remainder in dx
  181.  
  182.     push dx                         ;save remainder
  183.  
  184.     or  al,30h                      ;into ascii
  185.     mov ah,02h
  186.     mov dl,al
  187.     int 21h
  188.  
  189.     pop ax                          ;restore remainder
  190.  
  191.     mov dx,0                        ;clr msb
  192.     mov cx,100                      ;get hundreds
  193.     div cx                          ;quotient in ax, remainder in dx
  194.  
  195.     push dx                         ;save remainder
  196.  
  197.     or  al,30h                      ;into ascii
  198.     mov ah,02h
  199.     mov dl,al
  200.     int 21h
  201.  
  202.     pop ax                          ;restore remainder
  203.  
  204.     mov dx,0                        ;clr msb
  205.     mov cx,10                       ;get tens
  206.     div cx                          ;quotient in ax, remainder in dx
  207.  
  208.     push dx                         ;save remainder
  209.  
  210.     or  al,30h                      ;into ascii
  211.     mov ah,02h
  212.     mov dl,al
  213.     int 21h
  214.  
  215.     pop ax                          ;restore remainder (units)
  216.  
  217.     or al,30h                       ;into ascii
  218.     mov ah,02h
  219.     mov dl,al
  220.     int 21h
  221.            
  222.    mov  ax,@data
  223.    mov  ds,ax                       ;set DS to point to the data segment
  224.    mov  ah,9                        ;DOS print string function
  225.    mov  dx,OFFSET HelloMessage      ;point to "Hello, world"
  226.    int  21h                         ;display "Hello, world"
  227.  
  228.  
  229.    mov  aX,4c00h                      ;DOS terminate program function
  230.    int  21h                         ;terminate the program
  231.     endp
  232.  
  233. do_space proc near
  234.     push ax
  235.     push dx
  236.     mov ah,02
  237.     mov dl,' '
  238.     int 21h
  239.     pop dx
  240.     pop ax
  241.     ret
  242.     endp
  243.  
  244. do_colon proc near
  245.     push ax
  246.     push dx
  247.     mov ah,02
  248.     mov dl,':'
  249.     int 21h
  250.     pop dx
  251.     pop ax
  252.     ret
  253.     endp
  254.  
  255. do_slash proc near
  256.     push ax
  257.     push dx
  258.     mov ah,02
  259.     mov dl,'/'
  260.     int 21h
  261.     pop dx
  262.     pop ax
  263.     ret
  264.     endp
  265.  
  266.  
  267.  
  268.  
  269.    END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement