home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: OtherApp / OtherApp.zip / aping.zip / atime.a37 < prev    next >
Text File  |  1993-03-22  |  8KB  |  104 lines

  1. ATIME    CSECT                                                          CLS00010
  2. * 3/19/93 John Brady       JFB@RALVM6                                           
  3. *         Neal Scheunemann NEALS@RALVM6                                         
  4. *                                                                               
  5. * ATIME returns a 32 bit integer value for a time stamp.                        
  6. * Usage:                                                                        
  7. *   This routine returns a pretty meaningless stamp                             
  8. *   from only one call.  The real usefulness is                                 
  9. *   in a code segment as follows:                                               
  10. *                                                                               
  11. *     i=atime();                                                                
  12. *        do                                                                     
  13. *          some                                                                 
  14. *              work                                                             
  15. *     j=atime();                                                                
  16. *                                                                               
  17. *     j=j-i;                                                                    
  18. *                                                                               
  19. * The quantity j would represent the number of Milliseconds                     
  20. * the work took to complete.                                                    
  21. *                                                                               
  22. * The algorithm takes the 64 bit time of day clock and shifts                   
  23. * it right 22 positions to preserve, in 32 bits,                                
  24. * a representation of the clock precise to 1/1024 seconds.                      
  25. *                                                                               
  26. * The quantity is then adjusted:                                                
  27. *                                                                               
  28. * 1) it is multiplied by a factor of (1000/1024), this transforms               
  29. *    the precision from (1/1024) seconds to (1/1000) seconds.                   
  30. *                                                                               
  31. * 2) multiply by a clock factor.  See the STCK instruction                      
  32. * in S/370 Principles of operation for rationale about the                      
  33. * clock factor.                                                                 
  34. *                                                                               
  35. * 3) multiply by 1000 to represent the number of milliseconds                   
  36. *    on return                                                                  
  37. *                                                                               
  38. * Notice the value of CLKF has a 1000 built into it                             
  39. * for dividing purposes, this allows the algorithm to keep                      
  40. * precision, and avoids use of floating point math                              
  41.          PRINT GEN                                                      CLS00020
  42. *                                                                               
  43. * Entry Linkage and data basing                                                 
  44.          STM   R2,R14,12(13)        SAVE REGISTERS                              
  45.          LR    R3,R15               MAKE R3 BASE                                
  46.          USING ATIME,R3             TELL ASSEMBLER WHAT THE BASE IS             
  47.          ST    R13,SAVE0            SAVE CALLERS SAVEAREA ADDRESS               
  48. *                                                                               
  49. * Begin mainline                                                                
  50.          LA    R4,SYMBOL            Get address for store clock                 
  51.          STCK  0(R4)                Put 64 bit TOD clock in SYMBOL              
  52. *                                                                               
  53. * Load the 4/5 register pair to represent high and low order                    
  54. *   halves of 64 bit clock value recently gleaned                               
  55.          L     R4,SYMBOL            Load reg..4                                 
  56.          L     R5,SYMBOL+4                  ...and 5                            
  57.          LA    R8,0                                                             
  58. *                                                                               
  59. * Shift insignificant low order 22 bits off the deep end                        
  60.          SRDL  R4,22(R8)                                                        
  61. *                                                                               
  62. * Clear high order register                                                     
  63.          SR    R4,R4                                                            
  64. *                                                                               
  65. * Scale up the time value by 1.048576                                           
  66.          M     R4,CLKF                                                          
  67. *                                                                               
  68. * Divide by 4096 (4 x 1024).  This has the net effect of                        
  69. * shifting the clock value the final 2 positions                                
  70. * (we have only shifted 20 so far) and normalizing                              
  71. * the quantity by a factor of (1000/1024).                                      
  72.          D     R4,DIVISOR                                                       
  73. *                                                                               
  74. * Return to caller                                                              
  75.          LR    R15,R5                PUT RETURN VALUE IN R15                    
  76.          LM    R2,R14,12(13)         RESTORE REGISTERS                          
  77.          BR    14                    BACK TO CALLER                             
  78.          DS   0F                                                                
  79. SAVE0    DS   F                                                                 
  80. SYMBOL   DS   D                                                                 
  81. ANSWER   DC   D'0'                                                              
  82. * Clock factor, the TOD clock's 31 bit flips a little                           
  83. * slower than a second                                                          
  84. CLKF     DC   F'1048576'                                                        
  85. * divide by adjustment factor                                                   
  86. DIVISOR  DC   F'1024000'                                                        
  87. R0       EQU  0                                                         CLS00310
  88. R1       EQU  1                                                         CLS00320
  89. R2       EQU  2                                                         CLS00330
  90. R3       EQU  3                                                         CLS00340
  91. R4       EQU  4                                                         CLS00350
  92. R5       EQU  5                                                         CLS00360
  93. R6       EQU  6                                                         CLS00370
  94. R7       EQU  7                                                         CLS00380
  95. R8       EQU  8                                                         CLS00390
  96. R9       EQU  9                                                         CLS00400
  97. R10      EQU  10                                                        CLS00410
  98. R11      EQU  11                                                        CLS00420
  99. R12      EQU  12                                                        CLS00430
  100. R13      EQU  13                                                        CLS00440
  101. R14      EQU  14                                                        CLS00450
  102. R15      EQU  15                                                        CLS00460
  103.          END                                                            CLS00470
  104.