     1                                  ; ****************************************************************************
     2                                  ; date386.s (date1.s) - by Erdogan Tan - 31/05/2022
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; Retro UNIX 386 v1 - date - print and set the date
     5                                  ;
     6                                  ; [ Last Modification: 02/06/2022 ]
     7                                  ;
     8                                  ; Derived from (original) UNIX v5 'date.c' source Code
     9                                  ; Ref:
    10                                  ; www.tuhs.org (https://minnie.tuhs.org)
    11                                  ; ****************************************************************************
    12                                  ; [ v5root.tar.gz - usr/source/s1/date.c (archive date: 27-11-1974) ]
    13                                  ;		  - usr/source/s3/ctime.c (archive date: 27-11-1974)
    14                                  
    15                                  ; Assembler: NASM v2.15
    16                                  ; ((nasm date1.s -l date1.txt -o date1 -Z error.txt))
    17                                  
    18                                  ; date1.s - 02/06/2022 - Retro UNIX 386 v1 & v1.1 & V1.2
    19                                  ; date0.s - 02/06/2022 - Retro UNIX 8086 v1 (16 bit 'date1.s')
    20                                  
    21                                  ;; (unix) v5man.pdf (page 45)
    22                                  ;; --------------------------
    23                                  ;;
    24                                  ;;NAME
    25                                  ;;	date - print and set the date
    26                                  ;;SYNOPSIS
    27                                  ;;	date [ mmddhhmm[yy] ]
    28                                  ;;DESCRIPTION
    29                                  ;;	If no argument is given, the current date is printed to the second.
    30                                  ;;	If an argument is given, the current date is set.
    31                                  ;;	The first num is the month number; dd is the day number in the month;
    32                                  ;;	hh is the hour number (24 hour sys), the 2'nd mm is the minute number;
    33                                  ;;	yy is the last 2 digits of the year number and is optional. 
    34                                  ;;
    35                                  ;;	For example:
    36                                  ;;		date 10080045
    37                                  ;;
    38                                  ;;	sets the date to Oct 8, 12:45 AM. 
    39                                  ;;
    40                                  ;;	The current year is the default if no year is mentioned. 
    41                                  ;;
    42                                  
    43                                  ; 12/01/2022 (Retro UNIX 386 v1.2)
    44                                  ; 13/10/2015
    45                                  
    46                                  ; UNIX v1 system calls
    47                                  _rele 	equ 0
    48                                  _exit 	equ 1
    49                                  _fork 	equ 2
    50                                  _read 	equ 3
    51                                  _write	equ 4
    52                                  _open	equ 5
    53                                  _close 	equ 6
    54                                  _wait 	equ 7
    55                                  _creat 	equ 8
    56                                  _link 	equ 9
    57                                  _unlink	equ 10
    58                                  _exec	equ 11
    59                                  _chdir	equ 12
    60                                  _time 	equ 13
    61                                  _mkdir 	equ 14
    62                                  _chmod	equ 15
    63                                  _chown	equ 16
    64                                  _break	equ 17
    65                                  _stat	equ 18
    66                                  _seek	equ 19
    67                                  _tell 	equ 20
    68                                  _mount	equ 21
    69                                  _umount	equ 22
    70                                  _setuid	equ 23
    71                                  _getuid	equ 24
    72                                  _stime	equ 25
    73                                  _quit	equ 26	
    74                                  _intr	equ 27
    75                                  _fstat	equ 28
    76                                  _emt 	equ 29
    77                                  _mdate 	equ 30
    78                                  _stty 	equ 31
    79                                  _gtty	equ 32
    80                                  _ilgins	equ 33
    81                                  _sleep	equ 34 ; Retro UNIX 8086 v1 feature only !
    82                                  _msg    equ 35 ; Retro UNIX 386 v1 feature only !
    83                                  _geterr	equ 36 ; Retro UNIX 386 v1 feature only !
    84                                  ; 12/01/2022 - Retro UNIX 386 v1.2
    85                                  ; Retro UNIX 386 v2 system calls
    86                                  _setgid	equ 37
    87                                  _getgid	equ 38
    88                                  _sysver	equ 39 ; (get) Retro Unix 386 version
    89                                  
    90                                  ;;;
    91                                  ESCKey equ 1Bh
    92                                  EnterKey equ 0Dh
    93                                  
    94                                  %macro sys 1-4
    95                                      ; 03/09/2015	
    96                                      ; 13/04/2015
    97                                      ; Retro UNIX 386 v1 system call.		
    98                                      %if %0 >= 2   
    99                                          mov ebx, %2
   100                                          %if %0 >= 3    
   101                                              mov ecx, %3
   102                                              ;%if %0 = 4
   103                                              %if	%0 >= 4 ; 11/03/2022
   104                                  		mov edx, %4   
   105                                              %endif
   106                                          %endif
   107                                      %endif
   108                                      mov eax, %1
   109                                      int 30h	   
   110                                  %endmacro
   111                                  
   112                                  ; Retro UNIX 386 v1 system call format:
   113                                  ; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
   114                                  
   115                                  ; 11/03/2022
   116                                  ; Note: Above 'sys' macro has limitation about register positions;
   117                                  ;	ebx, ecx, edx registers must not be used after their
   118                                  ;	positions in sys macro.
   119                                  ; for example:
   120                                  ;	'sys _write, 1, msg, ecx' is defective, because
   121                                  ;	 ecx will be used/assigned before edx in 'sys' macro.
   122                                  ; correct order may be:
   123                                  ;	'sys _write, 1, msg, eax ; (eax = byte count)
   124                                  
   125                                  ;-----------------------------------------------------------------
   126                                  ;  text - code
   127                                  ;-----------------------------------------------------------------
   128                                  
   129                                  [BITS 32] ; 32-bit intructions (for 80386 protected mode)
   130                                  
   131                                  [ORG 0] 
   132                                  
   133                                  START_CODE:
   134                                  	; 02/06/2022
   135                                  	; 31/05/2022
   136 00000000 58                      	pop	eax ; number of arguments
   137 00000001 5A                      	pop	edx ; argv[0]	
   138                                  	;;mov	[argc], eax
   139                                  	;mov	[argc], al
   140                                  
   141                                  	;cmp	eax, 2
   142 00000002 3C01                    	cmp	al, 1
   143                                  	;ja	short dt_0
   144                                  	;jmp	dt_2 ; print current date time
   145 00000004 762F                    	jna	short dt_2
   146                                  dt_0:
   147                                  	; set date & time
   148                                  	; ((date [ mmddhhmm[yy] ]))	
   149 00000006 5D                      	pop	ebp ; dword [cbp]  ; argv[1]
   150                                  
   151                                  	;if(gtime()) {
   152                                  	;	write(1, "bad conversion\n", 15);
   153                                  	;	exit();
   154                                  
   155 00000007 E85C000000              	call	gtime
   156 0000000C 7311                    	jnc	short dt_1
   157                                  
   158 0000000E B8[E9030000]            	mov	eax, msg_bad
   159                                  dt_p_x:
   160 00000013 E890010000              	call	print_msg
   161                                  	sys	_exit	
    95                              <1> 
    96                              <1> 
    97                              <1> 
    98                              <1>  %if %0 >= 2
    99                              <1>  mov ebx, %2
   100                              <1>  %if %0 >= 3
   101                              <1>  mov ecx, %3
   102                              <1> 
   103                              <1>  %if %0 >= 4
   104                              <1>  mov edx, %4
   105                              <1>  %endif
   106                              <1>  %endif
   107                              <1>  %endif
   108 00000018 B801000000          <1>  mov eax, %1
   109 0000001D CD30                <1>  int 30h
   162                                  dt_1:
   163                                  	;if(stime(timbuf) < 0)
   164                                  	;	write(1, "no permission\n", 14);
   165                                  
   166                                  	sys	_stime, [timbuf]
    95                              <1> 
    96                              <1> 
    97                              <1> 
    98                              <1>  %if %0 >= 2
    99 0000001F 8B1D[10040000]      <1>  mov ebx, %2
   100                              <1>  %if %0 >= 3
   101                              <1>  mov ecx, %3
   102                              <1> 
   103                              <1>  %if %0 >= 4
   104                              <1>  mov edx, %4
   105                              <1>  %endif
   106                              <1>  %endif
   107                              <1>  %endif
   108 00000025 B819000000          <1>  mov eax, %1
   109 0000002A CD30                <1>  int 30h
   167 0000002C 7307                    	jnc	short dt_2
   168                                  dt_err:
   169 0000002E B8[FC030000]            	mov	eax, msg_no_perm
   170 00000033 EBDE                    	jmp	short dt_p_x
   171                                  dt_2:
   172                                  	;time(timbuf);
   173                                  	;cbp = cbuf;
   174                                  	;ctime(timbuf);
   175                                  	;write(1, cbuf, 20);
   176                                  	;tzn = tzname[localtime(timbuf)[8]];
   177                                  	;if (tzn)
   178                                  	;	write(1, tzn, 3);
   179                                  	;write(1, cbuf+19, 6);
   180                                  
   181 00000035 B8[F9030000]            	mov	eax, nextline
   182 0000003A E869010000              	call	print_msg
   183                                  
   184                                  	sys	_time
    95                              <1> 
    96                              <1> 
    97                              <1> 
    98                              <1>  %if %0 >= 2
    99                              <1>  mov ebx, %2
   100                              <1>  %if %0 >= 3
   101                              <1>  mov ecx, %3
   102                              <1> 
   103                              <1>  %if %0 >= 4
   104                              <1>  mov edx, %4
   105                              <1>  %endif
   106                              <1>  %endif
   107                              <1>  %endif
   108 0000003F B80D000000          <1>  mov eax, %1
   109 00000044 CD30                <1>  int 30h
   185                                  	;mov	[timbuf], eax
   186                                  	
   187                                  	; eax = unix epoch time
   188 00000046 E879010000              	call	ctime
   189                                  
   190                                  	sys	_write, 1, cbuf, 25
    95                              <1> 
    96                              <1> 
    97                              <1> 
    98                              <1>  %if %0 >= 2
    99 0000004B BB01000000          <1>  mov ebx, %2
   100                              <1>  %if %0 >= 3
   101 00000050 B9[9B030000]        <1>  mov ecx, %3
   102                              <1> 
   103                              <1>  %if %0 >= 4
   104 00000055 BA19000000          <1>  mov edx, %4
   105                              <1>  %endif
   106                              <1>  %endif
   107                              <1>  %endif
   108 0000005A B804000000          <1>  mov eax, %1
   109 0000005F CD30                <1>  int 30h
   191                                  
   192 00000061 B8[F9030000]            	mov	eax, nextline
   193 00000066 EBAB                    	jmp	short dt_p_x
   194                                  
   195                                  ;-----------------------------------------------------------------
   196                                  
   197                                  gtime:
   198                                  	; INPUT:
   199                                  	;    ebp = input string to be converted
   200                                  	;		 (to unix epoch time)
   201                                  	; OUTPUT:
   202                                    	;     cf = 0 -> OK
   203                                  	;     cf = 1 -> bad input 	
   204                                  
   205                                  	;t = gpair();
   206                                  	;if(t<1 || t>12)
   207                                  	;	goto bad;
   208                                  	;d = gpair();
   209                                  	;if(d<1 || d>31)
   210                                  	;	goto bad;
   211                                  	;h = gpair();
   212                                  	;if(h == 24) {
   213                                  	;	h = 0;
   214                                  	;	d++;
   215                                  
   216 00000068 E810010000              	call	gpair
   217 0000006D 726A                    	jc	short _bad
   218 0000006F 08D2                    	or	dl, dl
   219 00000071 7465                    	jz	short bad
   220 00000073 80FA0C                  	cmp	dl, 12
   221 00000076 7760                    	ja	short bad
   222 00000078 8815[14040000]          	mov	[_t_], dl
   223 0000007E E8FA000000              	call	gpair
   224 00000083 7254                    	jc	short _bad
   225 00000085 20D2                    	and	dl, dl
   226 00000087 744F                    	jz	short bad
   227 00000089 80FA1F                  	cmp	dl, 31
   228 0000008C 774A                    	ja	short bad
   229 0000008E 8815[15040000]          	mov	[_d_], dl
   230 00000094 E8E4000000              	call	gpair
   231 00000099 723E                    	jc	short _bad
   232 0000009B 80FA18                  	cmp	dl, 24
   233 0000009E 7738                    	ja	short bad
   234 000000A0 7202                    	jb	short gtime_1
   235 000000A2 28D2                    	sub	dl, dl ; 0
   236                                  gtime_1:
   237 000000A4 8815[16040000]          	mov	[_h_], dl
   238 000000AA E8CE000000              	call	gpair
   239 000000AF 7228                    	jc	short _bad
   240 000000B1 80FA3B                  	cmp	dl, 59
   241 000000B4 7722                    	ja	short bad
   242 000000B6 8815[17040000]          	mov	[_m_], dl
   243                                  
   244                                  	;m = gpair();
   245                                  	;if(m<0 || m>59)
   246                                  	;	goto bad;
   247                                  	;y = gpair();
   248                                  	;if (y<0) {
   249                                  	;	time(nt);
   250                                  	;	y = localtime(nt)[5];
   251                                  
   252                                  	;call	time
   253                                  	sys	_time
    95                              <1> 
    96                              <1> 
    97                              <1> 
    98                              <1>  %if %0 >= 2
    99                              <1>  mov ebx, %2
   100                              <1>  %if %0 >= 3
   101                              <1>  mov ecx, %3
   102                              <1> 
   103                              <1>  %if %0 >= 4
   104                              <1>  mov edx, %4
   105                              <1>  %endif
   106                              <1>  %endif
   107                              <1>  %endif
   108 000000BC B80D000000          <1>  mov eax, %1
   109 000000C1 CD30                <1>  int 30h
   254                                  	; eax = time (in unix epoch format)	
   255                                  
   256 000000C3 E883010000              	call	gmtime
   257                                  
   258 000000C8 E8B0000000              	call	gpair
   259 000000CD 730B                    	jnc	short gtime_2
   260 000000CF 668B15[33030000]        	mov	dx, [year]
   261 000000D6 EB16                    	jmp	short gtime_4
   262                                  bad:
   263                                  	;return(1);
   264 000000D8 F9                      	stc
   265                                  _bad:
   266 000000D9 C3                      	retn
   267                                  gtime_2:
   268 000000DA 66B8D007                	mov	ax, 2000
   269 000000DE 663B05[33030000]        	cmp	ax, [year] ; 2000
   270 000000E5 7604                    	jna	short gtime_3
   271 000000E7 66B86C07                	mov	ax, 1900
   272                                  gtime_3:
   273 000000EB 6601C2                  	add	dx, ax
   274                                  gtime_4:
   275 000000EE 668915[18040000]        	mov	[_y_], dx
   276                                  
   277                                  	;timbuf[0] = 0;
   278                                  	;timbuf[1] = 0;
   279                                  	;y =+ 1900;
   280                                  	;for(i=1970; i<y; i++)
   281                                  	;	gdadd(dysize(i));
   282                                  	;while(--t)
   283                                  	;	gdadd(dmsize[t-1]);
   284                                  	
   285 000000F5 31C0                    	xor	eax, eax
   286                                  	;mov	[timbuf], eax ; 0
   287                                  
   288 000000F7 66B9B207                	mov	cx, 1970
   289                                  gtime_5:
   290 000000FB 663B0D[18040000]        	cmp	cx, [_y_]
   291 00000102 730F                    	jnb	short gtime_6
   292 00000104 E854000000              	call	dysize
   293                                  	;call	gdadd
   294 00000109 0105[10040000]          	add	[timbuf], eax
   295 0000010F 6641                    	inc	cx
   296 00000111 EBE8                    	jmp	short gtime_5
   297                                  	
   298                                  gtime_6:
   299                                  	;while(--t)
   300                                  	;	gdadd(dmsize[t-1]);
   301                                  	
   302 00000113 E851000000              	call	dmsize
   303 00000118 0105[10040000]          	add	[timbuf], eax
   304                                  
   305                                  	; gdadd(d-1);
   306                                  	;movzx	eax, [_d_]
   307 0000011E 29C0                    	sub	eax, eax
   308 00000120 A0[15040000]            	mov	al, [_d_]
   309 00000125 FEC8                    	dec 	al
   310 00000127 0105[10040000]          	add	[timbuf], eax
   311                                  
   312                                  	; here, [timbuf] contains days since 1/1/1970
   313                                  
   314                                  	;gmdadd(24, h);
   315                                  	;gmdadd(60, m);
   316                                  	;gmdadd(60, 0);
   317                                  
   318 0000012D 29C9                    	sub	ecx, ecx
   319                                  
   320 0000012F 8A0D[16040000]          	mov	cl, [_h_]
   321 00000135 B018                    	mov	al, 24
   322 00000137 E811000000              	call	gmdadd
   323 0000013C 8A0D[17040000]          	mov	cl, [_m_]
   324 00000142 B03C                    	mov	al, 60
   325 00000144 E804000000              	call	gmdadd
   326                                  
   327 00000149 28C9                    	sub	cl, cl ; 0
   328 0000014B B03C                    	mov	al, 60
   329                                  	;call	gmdadd
   330                                  	;retn
   331                                  
   332                                  ;-----------------------------------------------------------------
   333                                  
   334                                  gmdadd: ; gmdadd(m, n)
   335                                  
   336                                  	;timbuf[0] =* m;
   337                                  	;t1 = timbuf[1];
   338                                  	;while(--m)
   339                                  	;	gdadd(t1);
   340                                  	;gdadd(n);
   341                                  	
   342                                  	; eax = m
   343                                  	; ecx = n
   344                                  
   345 0000014D F725[10040000]          	mul	dword [timbuf]
   346 00000153 01C8                    	add	eax, ecx
   347 00000155 A3[10040000]            	mov	[timbuf], eax
   348 0000015A 31C0                    	xor	eax, eax
   349 0000015C C3                      	retn
   350                                  
   351                                  ;-----------------------------------------------------------------
   352                                  
   353                                  ;gdadd:	; gdadd(n)
   354                                  ;
   355                                  ;	;t = timbuf[1]+n;
   356                                  ;	;if(t < timbuf[1])
   357                                  ;	;	timbuf[0]++;
   358                                  ;	;timbuf[1] = t;
   359                                  ;
   360                                  ;	; eax = n
   361                                  ;
   362                                  ;	add	[timbuf], eax
   363                                  ;	retn
   364                                  
   365                                  ;-----------------------------------------------------------------
   366                                  ; dysize (ctime.c)
   367                                  
   368                                  dysize: ; dysize(y)
   369                                  	
   370                                  	;if((y%4) == 0)
   371                                  	;	return(366);
   372                                  	;return(365);
   373                                  
   374                                  	; cl = low byte of year (to be checked)
   375                                  
   376 0000015D B86D010000              	mov	eax, 365
   377                                  
   378 00000162 F6C103                  	test	cl, 3
   379 00000165 7501                    	jnz	short dysize_r
   380                                  
   381 00000167 40                      	inc	eax ; 366
   382                                  dysize_r:
   383 00000168 C3                      	retn
   384                                  
   385                                  ;-----------------------------------------------------------------
   386                                  ; dmsize (ctime.c)
   387                                  
   388                                  dmsize: 
   389                                  	
   390                                  	;int	dmsize[12]
   391                                  	;{
   392                                  	;	31,
   393                                  	;	28,
   394                                  	;	31,
   395                                  	;	30,
   396                                  	;	31,
   397                                  	;	30,
   398                                  	;	31,
   399                                  	;	31,
   400                                  	;	30,
   401                                  	;	31,
   402                                  	;	30,
   403                                  	;	31
   404                                  	;};
   405                                  
   406 00000169 31DB                    	xor	ebx, ebx
   407 0000016B 8A1D[14040000]           	mov	bl, [_t_] ; 1 to 12
   408 00000171 FECB                    	dec	bl ; 0 to 11
   409 00000173 D0E3                    	shl	bl, 1
   410 00000175 668B83[37030000]        	mov	ax, [ebx+DMonth] ; (ctime386.s)	
   411 0000017C C3                      	retn		
   412                                  
   413                                  ;-----------------------------------------------------------------
   414                                  
   415                                  gpair:
   416                                  	; INPUT:
   417                                  	;    ebp = number text (digit pair) address
   418                                  	; OUTPUT:
   419                                    	;     dl (edx) = value (number) 		
   420                                   
   421                                  	;cp = cbp;
   422                                  	;if(*cp == 0)
   423                                  	;	return(-1);
   424                                  	;c = (*cp++ - '0') * 10;
   425                                  	;if (c<0 || c>100)
   426                                  	;	return(-1);
   427                                  	;if(*cp == 0)
   428                                  	;	return(-1);
   429                                  	;if ((d = *cp++ - '0') < 0 || d > 9)
   430                                  	;	return(-1);
   431                                  	;cbp = cp;
   432                                  	;return (c+d);
   433                                  
   434 0000017D 31D2                    	xor	edx, edx
   435                                  
   436 0000017F 89EE                    	mov	esi, ebp ; dword [cbp] ; argv[1]
   437 00000181 AC                      	lodsb
   438 00000182 20C0                    	and	al, al
   439 00000184 7420                    	jz	short gp_c
   440 00000186 2C30                    	sub	al, '0'
   441 00000188 721B                    	jb 	short gp_x
   442                                  	;cmp	al, 10 ; ':'-'0'
   443                                  	;ja	short gp_c
   444 0000018A 3C09                    	cmp	al, 9
   445 0000018C 7718                    	ja	short gp_c	
   446 0000018E B40A                    	mov	ah, 10
   447 00000190 F6E4                    	mul	ah
   448                                  	;; (ax >= 0 and ax <= 100)
   449                                  	; (ax >= 0 and ax <= 90)
   450 00000192 88C2                    	mov	dl, al
   451 00000194 AC                      	lodsb
   452 00000195 08C0                    	or	al, al
   453 00000197 740D                    	jz	short gp_c
   454 00000199 2C30                    	sub	al, '0'
   455 0000019B 7208                    	jb	short gp_x
   456 0000019D 3C09                    	cmp	al, 9
   457 0000019F 7705                    	ja	short gp_c
   458                                  
   459 000001A1 89F5                    	mov	ebp, esi
   460                                  
   461 000001A3 00C2                    	add	dl, al
   462                                  
   463                                  	; (dx >= 0 and dx <= 99)		
   464                                  gp_x:
   465 000001A5 C3                      	retn
   466                                  gp_c:
   467 000001A6 F9                      	stc
   468 000001A7 C3                      	retn
   469                                  
   470                                  ;-----------------------------------------------------------------
   471                                  
   472                                  print_msg:
   473                                  	; eax = asciiz string address
   474 000001A8 89C6                    	mov	esi, eax
   475 000001AA 4E                      	dec	esi
   476                                  nextchr:
   477 000001AB 46                      	inc	esi
   478 000001AC 803E00                  	cmp	byte [esi], 0
   479 000001AF 77FA                    	ja	short nextchr
   480                                  	;cmp	[esi], 0Dh
   481                                  	;ja	short nextchr
   482 000001B1 29C6                    	sub	esi, eax
   483                                  	; esi = asciiz string length
   484                                  	;
   485                                  	sys	_write, 1, eax, esi
    95                              <1> 
    96                              <1> 
    97                              <1> 
    98                              <1>  %if %0 >= 2
    99 000001B3 BB01000000          <1>  mov ebx, %2
   100                              <1>  %if %0 >= 3
   101 000001B8 89C1                <1>  mov ecx, %3
   102                              <1> 
   103                              <1>  %if %0 >= 4
   104 000001BA 89F2                <1>  mov edx, %4
   105                              <1>  %endif
   106                              <1>  %endif
   107                              <1>  %endif
   108 000001BC B804000000          <1>  mov eax, %1
   109 000001C1 CD30                <1>  int 30h
   486                                  	;
   487 000001C3 C3                      	retn
   488                                  
   489                                  ;-----------------------------------------------------------------
   490                                  ; ctime, localtime, asctime, gmtime functions
   491                                  
   492                                  %include 'ctime386.s' ; 31/05/2022 
   493                              <1> ; ****************************************************************************
   494                              <1> ; ctime386.inc (Retro Unix 386 v1 - /bin/ls - list file or directory)
   495                              <1> ; ----------------------------------------------------------------------------
   496                              <1> ; RETRO UNIX 386 (Retro Unix == Turkish Rational Unix)
   497                              <1> ; Operating System Project (v0.2) by ERDOGAN TAN (Beginning: 24/12/2013)
   498                              <1> ;
   499                              <1> ; [ Last Modification: 25/02/2022 ]
   500                              <1> ;
   501                              <1> ; Derived from 'CTIME.INC' source code file of 'Retro UNIX 8086 v1'
   502                              <1> ; operating system project, /bin/ls source code by Erdogan Tan
   503                              <1> ; (28/11/2013)
   504                              <1> ;
   505                              <1> ; Derived from 'ctime.c' file of original UNIX v5 (usr/source/s3/ctime.c)
   506                              <1> ;
   507                              <1> ; ls386.s (ls0.s) 23/09/2015 - 06/10/2015
   508                              <1> ; include ctime386.inc
   509                              <1> ;
   510                              <1> ; ****************************************************************************
   511                              <1> ; ctime386.s (06/10/2015 - 21/02/2022)
   512                              <1> 
   513                              <1> ; Assembler: NASM 2.11 (NASM 2.15, 2022)
   514                              <1> 
   515                              <1> ;timezone equ 5*60*60
   516                              <1> 
   517                              <1> ctime:  ; ctime(at)
   518                              <1> 	; int *at;
   519                              <1> 	; {
   520                              <1> 	; 	return(asctime(localtime(at)));
   521                              <1> 	; }
   522                              <1> 
   523                              <1> 	; EAX = unix epoch time (in seconds)
   524                              <1> 
   525                              <1> 	;call localtime
   526                              <1> 	;call asctime
   527                              <1> 
   528                              <1> 	;retn
   529                              <1>   
   530                              <1> localtime:
   531                              <1> 	; localtime(tim)
   532                              <1> 	; int tim[];
   533                              <1> 	; 	{
   534                              <1> 	;		register int *t, *ct, dayno;
   535                              <1> 	;	int daylbegin, daylend;
   536                              <1> 	;	int copyt[2];
   537                              <1> 	;	t = copyt;
   538                              <1> 	;	t[0] = tim[0];
   539                              <1> 	;	t[1] = tim[1];
   540                              <1> 	;	dpadd(t, -timezone);
   541                              <1> 	;	ct = gmtime(t);
   542                              <1> 	;	dayno = ct[YDAY];
   543                              <1> 	;	if (nixonflg && (ct[YEAR]>74 || ct[YEAR]==74 && (dayno > 5 ||
   544                              <1> 	;	    dayno==5 && ct[HOUR]>=2))) {
   545                              <1> 	;		daylight =| 1;
   546                              <1> 	;		daylbegin = -1;
   547                              <1> 	;		daylend = 367;
   548                              <1> 	;	} else {
   549                              <1> 	;		daylbegin = sunday(ct, 119);	/* last Sun in Apr */
   550                              <1> 	;		daylend = sunday(ct, 303);	/* last Sun in Oct */
   551                              <1> 	;	}
   552                              <1> 	;	if (daylight &&
   553                              <1> 	;	    (dayno>daylbegin || (dayno==daylbegin && ct[HOUR]>=2)) &&
   554                              <1> 	;	    (dayno<daylend || (dayno==daylend && ct[HOUR]<1))) {
   555                              <1> 	;		dpadd(t, 1*60*60);
   556                              <1> 	;		ct = gmtime(t);
   557                              <1> 	;		ct[ISDAY]++;
   558                              <1> 	;	}
   559                              <1> 	;	return(ct);
   560                              <1> 	;	}
   561                              <1> 
   562                              <1> 	;sub	eax, timezone	
   563                              <1> 
   564                              <1> 	;push	eax
   565                              <1> 
   566 000001C4 E882000000          <1> 	call 	gmtime
   567                              <1> ; if (nixonflg && (ct[YEAR]>74 || ct[YEAR]==74 && (dayno > 5 ||
   568                              <1> ;     dayno==5 && ct[HOUR]>=2))) {
   569                              <1> 	;cmp	byte [nixonflg], 0
   570                              <1> 	;jna	short lt1
   571                              <1> 	;cmp	word [year], 1974
   572                              <1> 	;jb	short lt1
   573                              <1> 	;ja	short lt0
   574                              <1> 	;cmp	word [yday], 5
   575                              <1> 	;jb	short lt1
   576                              <1> 	;ja	short lt0 
   577                              <1> 	;cmp	word [hour], 2
   578                              <1> 	;jb	short lt1
   579                              <1> ; nixonflag > 0
   580                              <1> ;lt0:
   581                              <1> 	;mov	word [daylight], 1
   582                              <1> 	;mov	word [daylbegin], -1
   583                              <1> 	;mov	word [daylend], 367
   584                              <1> ;	;jmp	short lt2
   585                              <1> 
   586                              <1> ; } else {
   587                              <1> ;lt1:
   588                              <1> ;	mov	cx, 119
   589                              <1> ;	call	sunday ; sunday(ct, 119); /* last Sun in Apr */
   590                              <1> ;	mov	[daylbegin], cx
   591                              <1> ;	mov	cx, 303
   592                              <1> ;	call	sunday ; sunday(ct, 303); /* last Sun in Oct */	
   593                              <1> ;	mov	[daylend], cx
   594                              <1> ;lt2:
   595                              <1> ; if (daylight &&
   596                              <1> ;    (dayno>daylbegin || (dayno==daylbegin && ct[HOUR]>=2)) &&
   597                              <1> ;    (dayno<daylend || (dayno==daylend && ct[HOUR]<1))) {
   598                              <1> 
   599                              <1> ;	pop	eax
   600                              <1> 
   601                              <1> 	;cmp	byte [daylight], 0
   602                              <1> 	;jna	short lt5
   603                              <1> 	
   604                              <1> 	;mov	cx, [yday]
   605                              <1> 
   606                              <1> 	;cmp	cx, [daylbegin]
   607                              <1> 	;jb	short lt5
   608                              <1> 	;ja	short lt3
   609                              <1> 	;cmp	word [hour], 2
   610                              <1> 	;jb	short lt5
   611                              <1> 	;jmp	short lt4
   612                              <1> ;lt3:
   613                              <1> 	;cmp	cx, [daylend]
   614                              <1> 	;jb	short lt4
   615                              <1> 	;ja	short lt5
   616                              <1> 	;cmp	word [hour], 1
   617                              <1> 	;jnb	short lt5
   618                              <1> ;lt4:
   619                              <1> 	;add	eax, 1*60*60
   620                              <1> 	;call	gmtime
   621                              <1> 	;inc	word [isday]
   622                              <1> ;lt5:
   623                              <1> ;	}
   624                              <1> ;	return(ct);
   625                              <1> ;	}
   626                              <1> 
   627                              <1> 	;retn
   628                              <1> 
   629                              <1> 	; 21/02/2022 (Retro UNIX 386 v1&v1.1&v1.2)
   630                              <1> asctime:
   631                              <1> 	; asctime(t)
   632                              <1> 	;int *t;
   633                              <1> 	;{
   634                              <1> 	;	register char *cp, *ncp;
   635                              <1> 	;	register int *tp;
   636                              <1> 	;
   637                              <1> 	;	cp = cbuf;
   638                              <1> 	;	for (ncp = "Day Mon 00 00:00:00 1900\n"; *cp++ = *ncp++;);
   639                              <1> 	;	ncp = &"SunMonTueWedThuFriSat"[3*t[6]];
   640                              <1> 	;	cp = cbuf;
   641                              <1> 	;	*cp++ = *ncp++;
   642                              <1> 	;	*cp++ = *ncp++;
   643                              <1> 	;	*cp++ = *ncp++;
   644                              <1> 	;	cp++;
   645                              <1> 	;	tp = &t[4];
   646                              <1> 	;	ncp = &"JanFebMarAprMayJunJulAugSepOctNovDec"[(*tp)*3];
   647                              <1> 	;	*cp++ = *ncp++;
   648                              <1> 	;	*cp++ = *ncp++;
   649                              <1> 	;	*cp++ = *ncp++;
   650                              <1> 	;	cp = numb(cp, *--tp);
   651                              <1> 	;	cp = numb(cp, *--tp+100);
   652                              <1> 	;	cp = numb(cp, *--tp+100);
   653                              <1> 	;	cp = numb(cp, *--tp+100);
   654                              <1> 	;	cp =+ 2;
   655                              <1> 	;	cp = numb(cp, t[YEAR]);
   656                              <1> 	;	return(cbuf);
   657                              <1> 	;}
   658                              <1> 	
   659                              <1> 	;;mov	edi, cbuf
   660                              <1> 	;;mov	esi, ncp0
   661                              <1> 	;;mov	ecx, 13
   662                              <1> 	;;movsw	
   663                              <1> 	;
   664 000001C9 BF[9B030000]        <1> 	mov	edi, cbuf	
   665                              <1> 	;movzx	esi, word [wday]
   666                              <1> 	;shl	si, 2
   667                              <1> 	;add	esi, ncp1
   668                              <1> 	;movsd
   669 000001CE 0FB735[31030000]    <1> 	movzx	esi, word [month]
   670                              <1> 	;shl	si, 2
   671 000001D5 C1E602              <1> 	shl	esi, 2 ; 21/02/2022
   672 000001D8 81C6[67030000]      <1> 	add	esi, ncp2 - 4
   673 000001DE A5                  <1> 	movsd
   674                              <1> 	;movzx eax, word [day]
   675 000001DF 66A1[2F030000]      <1> 	mov	ax, [day]
   676                              <1> 	;mov	cx, 10
   677 000001E5 B10A                <1> 	mov	cl, 10
   678 000001E7 E824010000          <1> 	call	numb
   679 000001EC B020                <1>  	mov	al, 20h
   680 000001EE AA                  <1> 	stosb
   681                              <1> 	;
   682 000001EF 66A1[33030000]      <1> 	mov	ax, [year]
   683 000001F5 B564                <1> 	mov	ch, 100
   684 000001F7 F6F5                <1> 	div	ch
   685                              <1> 	;push	ax ;
   686                              <1> 	; 21/02/2022
   687 000001F9 50                  <1> 	push	eax
   688 000001FA 6698                <1> 	cbw ; century (19, 20)
   689 000001FC E80F010000          <1> 	call	numb
   690                              <1> 	;pop	ax
   691                              <1> 	; 21/02/2022
   692 00000201 58                  <1> 	pop	eax
   693 00000202 88E0                <1> 	mov	al, ah
   694 00000204 6698                <1> 	cbw ;	year (0 to 99)
   695 00000206 E805010000          <1> 	call	numb
   696 0000020B B020                <1> 	mov 	al, 20h
   697 0000020D AA                  <1> 	stosb
   698                              <1> 	;
   699                              <1> 	;movzx   esi, word [wday]
   700                              <1> 	; 21/02/2022
   701 0000020E 668B35[35030000]    <1> 	mov	si, [wday]
   702                              <1> 	;shl	si, 2
   703 00000215 C1E602              <1> 	shl	esi, 2 ; 21/02/2022
   704 00000218 81C6[4F030000]      <1> 	add	esi, ncp1
   705 0000021E A5                  <1> 	movsd
   706                              <1> 	;
   707 0000021F 66A1[2D030000]      <1> 	mov	ax, [hour]
   708 00000225 E8E6000000          <1> 	call	numb
   709 0000022A B03A                <1>  	mov	al, ':'
   710 0000022C AA                  <1> 	stosb
   711 0000022D 66A1[2B030000]      <1> 	mov	ax, [minute]
   712 00000233 E8D8000000          <1> 	call	numb
   713 00000238 B03A                <1>  	mov	al, ':'
   714 0000023A AA                  <1> 	stosb
   715 0000023B 66A1[29030000]      <1> 	mov	ax, [second]
   716 00000241 E8CA000000          <1> 	call	numb
   717 00000246 B020                <1>  	mov	al, 20h
   718 00000248 AA                  <1> 	stosb
   719                              <1> 	;mov	ax, [year]
   720                              <1> 	;mov	ch, 100
   721                              <1> 	;div	ch
   722                              <1> 	;push	ax ;
   723                              <1> 	;cbw ; century (19, 20)
   724                              <1> 	;call	numb
   725                              <1> 	;pop	ax
   726                              <1> 	;mov	al, ah
   727                              <1> 	;cbw ;	year (0 to 99)
   728                              <1> 	;call	numb
   729                              <1> 	;mov	al, 20h
   730                              <1> 	;stosb
   731                              <1> 	;xor	al, al
   732                              <1> 	;stosb
   733                              <1> 
   734                              <1> 	; 25/02/2022
   735 00000249 AA                  <1> 	stosb
   736                              <1> 
   737 0000024A C3                  <1> 	retn
   738                              <1> 
   739                              <1> gmtime:
   740                              <1> 	; 21/02/2022 (Retro UNIX 386 v1&v1.1&v1.2)
   741                              <1> 	; 24/11/2013 (yday, wday)
   742                              <1> 	; Retro UNIX 8086 v1 - UNIX.ASM (20/06/2013)
   743                              <1> 	; Retro UNIX 8086 v1 feature/procedure only!
   744                              <1> 	; 'convert_from_epoch' procedure prototype: 
   745                              <1> 	; 	            UNIXCOPY.ASM, 10/03/2013
   746                              <1> 	; 30/11/2012
   747                              <1> 	; Derived from DALLAS Semiconductor
   748                              <1> 	; Application Note 31 (DS1602/DS1603)
   749                              <1> 	; 6 May 1998
   750                              <1> 	;
   751                              <1> 	; INPUT:
   752                              <1> 	; DX:AX = Unix (Epoch) Time
   753                              <1> 	;
   754                              <1> 	; ((Modified registers: AX, DX, CX, BX))  
   755                              <1> 	;
   756 0000024B 31D2                <1> 	xor edx, edx
   757                              <1> 	;mov ecx, 60
   758                              <1> 	; 21/02/2022
   759 0000024D 31C9                <1> 	xor ecx, ecx
   760 0000024F B13C                <1> 	mov cl, 60
   761 00000251 F7F1                <1> 	div ecx
   762                              <1> 	;mov [imin], eax     	  ; whole minutes
   763                              <1> 				  ; since 1/1/1970
   764 00000253 668915[29030000]    <1> 	mov [second], dx  	  ; leftover seconds
   765                              <1> 	;mov ecx, 60
   766 0000025A 29D2                <1> 	sub edx, edx
   767 0000025C F7F1                <1> 	div ecx
   768                              <1> 	;mov [ihrs], eax   	  ; whole hours
   769                              <1> 				  ; since 1/1/1970
   770 0000025E 668915[2B030000]    <1> 	mov [minute], dx  	  ; leftover minutes
   771                              <1> 	;mov ecx, 24
   772 00000265 31D2                <1> 	xor edx, edx
   773 00000267 B118                <1> 	mov cl, 24
   774 00000269 F7F1                <1> 	div ecx
   775                              <1> 	;mov [iday], ax  	  ; whole days
   776                              <1> 				  ; since 1/1/1970
   777 0000026B 66A3[35030000]      <1> 	mov [wday], ax 		  ; 24/11/2013	
   778 00000271 668915[2D030000]    <1> 	mov [hour], dx   	  ; leftover hours
   779 00000278 05DB020000          <1> 	add eax, 365+366	  ; whole day since
   780                              <1> 				  ; 1/1/1968 	
   781                              <1> 	;mov [iday], ax
   782 0000027D 50                  <1> 	push eax
   783 0000027E 66B9B505            <1> 	mov cx, (4*365)+1	  ; 4 years = 1461 days
   784 00000282 29D2                <1> 	sub edx, edx
   785 00000284 F7F1                <1> 	div ecx
   786 00000286 59                  <1> 	pop ecx
   787                              <1> 	;mov [lday], ax  	  ; count of quadyrs (4 years)
   788 00000287 52                  <1> 	push edx
   789                              <1> 	;mov [qday], dx           ; days since quadyr began
   790 00000288 6683FA3C            <1> 	cmp dx, 31+29             ; if past feb 29 then
   791 0000028C F5                  <1> 	cmc			  ; add this quadyr's leap day
   792 0000028D 83D000              <1> 	adc eax, 0		  ; to # of qadyrs (leap days)
   793                              <1> 	;mov [lday], ax  	  ; since 1968			  
   794                              <1> 	;mov cx, [iday]
   795 00000290 91                  <1> 	xchg ecx, eax		  ; CX = lday, AX = iday		  
   796 00000291 29C8                <1> 	sub eax, ecx		  ; iday - lday
   797                              <1> 	;mov ecx, 365
   798 00000293 66B96D01            <1> 	mov cx, 365
   799 00000297 31D2                <1> 	xor edx, edx		  ; DX  = 0
   800                              <1> 	; EAX = iday-lday
   801 00000299 F7F1                <1> 	div ecx
   802                              <1> 	;mov [iyrs], ax		  ; whole years since 1968
   803                              <1> 	; jday = iday - (iyrs*365) - lday
   804                              <1> 	;mov [jday], dx  	  ; days since 1/1 of current year
   805                              <1> 	;add eax, 1968		  ; compute year
   806 0000029B 05B0070000          <1> 	add eax, 1968
   807 000002A0 66A3[33030000]      <1> 	mov [year], ax
   808 000002A6 89C3                <1> 	mov ebx, eax		
   809                              <1> 	;mov ax, [qday]
   810 000002A8 58                  <1> 	pop eax
   811 000002A9 663D6D01            <1> 	cmp ax, 365		  ; if qday <= 365 and qday >= 60	
   812 000002AD 7709                <1> 	ja short L1		  ; jday = jday +1
   813 000002AF 6683F83C            <1> 	cmp ax, 60	          ; if past 2/29 and leap year then
   814 000002B3 F5                  <1>         cmc			  ; add a leap day to the # of whole
   815 000002B4 6683D200            <1> 	adc dx, 0		  ; days since 1/1 of current year
   816                              <1> L1:			
   817                              <1> 	;mov [jday], dx
   818                              <1> 	;mov [yday], dx 	  ; 24/11/2013	
   819                              <1> 	;mov cx, 12		  ; estimate month
   820                              <1> 	;xchg cx, dx		  ; CX = jday, DX = month 	
   821                              <1> 	; 21/02/2022
   822 000002B8 30ED                <1> 	xor ch, ch
   823 000002BA B10C                <1> 	mov cl, 12
   824 000002BC 87CA                <1> 	xchg ecx, edx 
   825 000002BE 66B86E01            <1> 	mov ax, 366		  ; mday, max. days since 1/1 is 365
   826 000002C2 6683E303            <1> 	and bx, 11b		  ; year mod 4	(and bx, 3) 
   827                              <1> L2:	; Month calculation	  ; 0 to 11  (11 to 0)	
   828                              <1> 	;cmp cx, ax		  ; mday = # of days passed from 1/1
   829                              <1> 	; 21/02/2022
   830 000002C6 39C1                <1> 	cmp ecx, eax
   831 000002C8 7319                <1> 	jnb short L3
   832                              <1> 	;dec dx			  ; month = month - 1
   833                              <1> 	; 21/02/2022
   834 000002CA 4A                  <1> 	dec edx
   835                              <1> 	;shl dx, 1 
   836 000002CB D1E2                <1> 	shl edx, 1 ; 21/02/2022
   837 000002CD 668B82[37030000]    <1> 	mov ax, [edx+DMonth] 	  ; # elapsed days at 1st of month
   838                              <1> 	;shr dx, 1		  ; dx = month - 1 (0 to 11)
   839 000002D4 D1EA                <1> 	shr edx, 1 ; 21/02/2022
   840 000002D6 6683FA01            <1> 	cmp dx, 1		  ; if month > 2 and year mod 4  = 0	
   841 000002DA 76EA                <1> 	jna short L2		  ; then mday = mday + 1
   842 000002DC 08DB                <1> 	or bl, bl		  ; if past 2/29 and leap year then
   843 000002DE 75E6                <1> 	jnz short L2		  ; add leap day (to mday)
   844                              <1> 	;inc ax			  ; mday = mday + 1
   845                              <1> 	; 21/02/2022
   846 000002E0 40                  <1> 	inc eax
   847 000002E1 EBE3                <1> 	jmp short L2
   848                              <1> L3:
   849                              <1> 	;inc dx 		  ; -> dx = month, 1 to 12
   850                              <1> 	; 21/02/2022
   851 000002E3 42                  <1> 	inc edx
   852 000002E4 668915[31030000]    <1> 	mov [month], dx
   853                              <1> 	;sub cx, ax		  ; day = jday - mday + 1	
   854                              <1> 	;inc cx 			  
   855                              <1> 	; 21/02/2022
   856 000002EB 29C1                <1> 	sub ecx, eax
   857 000002ED 41                  <1> 	inc ecx	
   858 000002EE 66890D[2F030000]    <1> 	mov [day], cx
   859                              <1> 	
   860                              <1> 	; eax, ebx, ecx, edx are changed at return
   861                              <1> 	; output ->
   862                              <1> 	; [year], [month], [day], [hour], [minute], [second]
   863                              <1> 	; [yday] -> 24/11/2013
   864                              <1> 	; [wday] -> 24/11/2013
   865                              <1> 	;
   866                              <1> 	; 24/11/2013
   867 000002F5 66A1[35030000]      <1> 	mov ax, [wday] ; [iday]
   868                              <1> 	;xor dx, dx
   869 000002FB 31D2                <1> 	xor edx, edx ; 21/02/2022
   870 000002FD 6683C004            <1> 	add ax, 4
   871                              <1> 	; NOTE: January 1, 1970 was THURSDAY
   872                              <1> 	; ch = 0
   873 00000301 B107                <1> 	mov cl, 7
   874 00000303 66F7F1              <1> 	div cx
   875 00000306 668915[35030000]    <1> 	mov [wday], dx ; week of the day,  0 to 6 
   876                              <1> 	; 0 = sunday ... 6 = saturday
   877                              <1> 	;mov word [isday], 0
   878                              <1> 
   879 0000030D C3                  <1> 	retn
   880                              <1> 
   881                              <1> ;sunday:
   882                              <1> 	; sunday(at, ad)
   883                              <1> 	; 	int *at;
   884                              <1> 	;	 {
   885                              <1> 	; 	register int *t, d;
   886                              <1> 	; 	t = at;
   887                              <1> 	; 	d = ad;
   888                              <1> 	; 	d = ad + dysize(t[YEAR]) - 365;
   889                              <1> 	; 	return(d - (d - t[YDAY] + t[WDAY] + 700) % 7);
   890                              <1> 	; 	}
   891                              <1> 
   892                              <1> 	;mov	dx, [year]
   893                              <1> 	;call	dysize
   894                              <1> 	;sub	ax, 365
   895                              <1> 	; add 	cx, ax
   896                              <1> ;	test	word [year], 11b
   897                              <1> ;	jnz	short sunday1
   898                              <1> 	; CX = 119 (77h) or CX = 303 (12Fh)
   899                              <1> 	;inc	cx
   900                              <1> ;	inc	cl
   901                              <1> ;sunday1:
   902                              <1> ;	mov	ax, cx
   903                              <1> ;	add	ax, [wday]
   904                              <1> 	;adc	ax, 700
   905                              <1> ;	add	ax, 700
   906                              <1> ;	sub	ax, [yday]
   907                              <1> 	;xor	dx, dx
   908                              <1> ;	mov	bx, 7
   909                              <1> 	;div	bx
   910                              <1> ;	div	bl
   911                              <1> ;	sub	cx, bx
   912                              <1> ;	retn
   913                              <1> 
   914                              <1> ;dysize:
   915                              <1> ; dysize(y)
   916                              <1> ;	{
   917                              <1> ;	if((y%4) == 0)
   918                              <1> ;		return(366);
   919                              <1> ;	return(365);
   920                              <1> ;	}
   921                              <1> 
   922                              <1> ;	mov 	ax, 365	
   923                              <1> ;	test 	dx, 11b
   924                              <1> ;	jnz 	short dysize1
   925                              <1> ;	;inc 	ax
   926 0000030E FEC0                <1> 	inc 	al			
   927                              <1> ;dysize1:	
   928                              <1> ;	retn 
   929                              <1> 
   930                              <1> numb:   ; AX = 0 to 99
   931                              <1> 	;
   932                              <1> 	; numb(acp, n)
   933                              <1> 	; {
   934                              <1> 	;	register char *cp;
   935                              <1> 	;
   936                              <1> 	;	cp = acp;
   937                              <1> 	;	cp++;
   938                              <1> 	;	if (n>=10)
   939                              <1> 	;	   *cp++ = (n/10)%10 + '0';
   940                              <1> 	;	else
   941                              <1> 	;	   *cp++ = ' ';
   942                              <1> 	;	*cp++ = n%10 + '0';
   943                              <1> 	;	return(cp);
   944                              <1> 	; }
   945                              <1> 	;
   946                              <1> 	;mov	cl, 10
   947 00000310 6683F80A            <1> 	cmp 	ax, 10
   948 00000314 7306                <1> 	jnb	short nb1
   949 00000316 88C4                <1> 	mov	ah, al
   950 00000318 30C0                <1> 	xor	al, al ; 0
   951 0000031A EB04                <1> 	jmp	short nb2
   952                              <1> nb1:	
   953 0000031C F6F1                <1> 	div	cl
   954 0000031E 88E2                <1> 	mov	dl, ah
   955                              <1> 	
   956                              <1> nb2:	
   957 00000320 0430                <1> 	add	al, '0'
   958 00000322 AA                  <1> 	stosb	; digit 1
   959 00000323 88E0                <1> 	mov	al, ah
   960 00000325 0430                <1> 	add	al, '0'
   961 00000327 AA                  <1> 	stosb	; digit 2
   962 00000328 C3                  <1> 	retn
   963                              <1> 
   964                              <1> ;;; DATA
   965                              <1> 
   966                              <1> ;daylight: db 1 ; int daylight 1; /* Allow daylight conversion */
   967                              <1> ;nixonflg: db 0 ; int nixonflg 0; /* Daylight time all year around */
   968                              <1> ;daylbegin: dw 0
   969                              <1> ;daylend: dw 0
   970                              <1> 
   971                              <1> ct:
   972                              <1> ; 24/11/2013 (re-order)
   973                              <1> ;
   974                              <1> ; Retro UNIX 8086 v1 - UNIX.ASM
   975                              <1> ; 09/04/2013 epoch variables
   976                              <1> ; Retro UNIX 8086 v1 Prototype: UNIXCOPY.ASM, 10/03/2013
   977                              <1> ;
   978                              <1> 
   979 00000329 0000                <1> second: dw 0
   980 0000032B 0000                <1> minute: dw 0
   981 0000032D 0000                <1> hour: dw 0
   982 0000032F 0100                <1> day: dw 1
   983 00000331 0100                <1> month: dw 1
   984 00000333 B207                <1> year: dw 1970
   985 00000335 0000                <1> wday: dw 0 ; 24/11/2013
   986                              <1> ;yday: dw 0 ; 24/11/2013
   987                              <1> ;isday: dw 0 ; 24/11/2013
   988                              <1> 
   989                              <1> DMonth:
   990 00000337 0000                <1> dw 0
   991 00000339 1F00                <1> dw 31
   992 0000033B 3B00                <1> dw 59
   993 0000033D 5A00                <1> dw 90
   994 0000033F 7800                <1> dw 120
   995 00000341 9700                <1> dw 151
   996 00000343 B500                <1> dw 181
   997 00000345 D400                <1> dw 212
   998 00000347 F300                <1> dw 243
   999 00000349 1101                <1> dw 273
  1000 0000034B 3001                <1> dw 304
  1001 0000034D 4E01                <1> dw 334
  1002                              <1> 
  1003                              <1> ;ncp0: db "Day Mon 00 00:00:00 1970", 0, 0
  1004 0000034F 53756E204D6F6E2054- <1> ncp1: db "Sun Mon Tue Wed Thu Fri Sat "
  1004 00000358 756520576564205468- <1>
  1004 00000361 752046726920536174- <1>
  1004 0000036A 20                  <1>
  1005 0000036B 4A616E20466562204D- <1> ncp2: db "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec "
  1005 00000374 617220417072204D61- <1>
  1005 0000037D 79204A756E204A756C- <1>
  1005 00000386 204175672053657020- <1>
  1005 0000038F 4F6374204E6F762044- <1>
  1005 00000398 656320              <1>
  1006                              <1> 
  1007                              <1> cbuf: 	; char cbuf[26]
  1008                              <1> 	;times 26 db 0
  1009                              <1> 	; 25/02/2022
  1010 0000039B 00<rep 1Bh>         <1> 	times 27 db 0	
  1011                              <1> 
  1012                              <1> ;; ctime.c (Unix v5)
  1013                              <1> ;
  1014                              <1> ;#
  1015                              <1> ;/*
  1016                              <1> ; * This routine converts time as follows.
  1017                              <1> ; * The epoch is 0000 Jan 1 1970 GMT.
  1018                              <1> ; * The argument time is in seconds since then.
  1019                              <1> ; * The localtime(t) entry returns a pointer to an array
  1020                              <1> ; * containing
  1021                              <1> ; *  seconds (0-59)
  1022                              <1> ; *  minutes (0-59)
  1023                              <1> ; *  hours (0-23)
  1024                              <1> ; *  day of month (1-31)
  1025                              <1> ; *  month (0-11)
  1026                              <1> ; *  year-1970
  1027                              <1> ; *  weekday (0-6, Sun is 0)
  1028                              <1> ; *  day of the year
  1029                              <1> ; *  daylight savings flag
  1030                              <1> ; *
  1031                              <1> ; * The routine corrects for daylight saving
  1032                              <1> ; * time and will work in any time zone provided
  1033                              <1> ; * "timezone" is adjusted to the difference between
  1034                              <1> ; * Greenwich and local standard time (measured in seconds).
  1035                              <1> ; * In places like Michigan "daylight" must
  1036                              <1> ; * be initialized to 0 to prevent the conversion
  1037                              <1> ; * to daylight time.
  1038                              <1> ; *
  1039                              <1> ; * "nixonflg,", if set to 1, will
  1040                              <1> ; * cause daylight savings time all year around
  1041                              <1> ; * independently of "daylight".
  1042                              <1> ; *
  1043                              <1> ; * The routine does not work
  1044                              <1> ; * in Saudi Arabia which runs on Solar time.
  1045                              <1> ; *
  1046                              <1> ; * asctime(tvec))
  1047                              <1> ; * where tvec is produced by localtime
  1048                              <1> ; * returns a ptr to a character string
  1049                              <1> ; * that has the ascii time in the form
  1050                              <1> ; *	Thu Jan 01 00:00:00 1970n0\; *	01234567890123456789012345
  1052                              <1> ; *	0	  1	    2
  1053                              <1> ; *
  1054                              <1> ; * ctime(t) just calls localtime, then asctime.
  1055                              <1> ; */
  1056                              <1> ;char	cbuf[26];
  1057                              <1> ;int	dmsize[12]
  1058                              <1> ;{
  1059                              <1> ;	31,
  1060                              <1> ;	28,
  1061                              <1> ;	31,
  1062                              <1> ;	30,
  1063                              <1> ;	31,
  1064                              <1> ;	30,
  1065                              <1> ;	31,
  1066                              <1> ;	31,
  1067                              <1> ;	30,
  1068                              <1> ;	31,
  1069                              <1> ;	30,
  1070                              <1> ;	31
  1071                              <1> ;};
  1072                              <1> ;
  1073                              <1> ;int timezone	5*60*60;
  1074                              <1> ;int tzname[]
  1075                              <1> ;{
  1076                              <1> ;	"EST",
  1077                              <1> ;	"EDT",
  1078                              <1> ;};
  1079                              <1> ;int	daylight 1;	/* Allow daylight conversion */
  1080                              <1> ;int	nixonflg 0;	/* Daylight time all year around */
  1081                              <1> ;
  1082                              <1> ;#define SEC	0
  1083                              <1> ;#define MIN	1
  1084                              <1> ;#define HOUR	2
  1085                              <1> ;#define MDAY	3 
  1086                              <1> ;#define MON	4
  1087                              <1> ;#define YEAR	5
  1088                              <1> ;#define WDAY	6
  1089                              <1> ;#define YDAY	7
  1090                              <1> ;#define ISDAY	8
  1091                              <1> ;
  1092                              <1> ;ctime(at)
  1093                              <1> ;int *at;
  1094                              <1> ;{
  1095                              <1> ;	return(asctime(localtime(at)));
  1096                              <1> ;}
  1097                              <1> ;
  1098                              <1> ;localtime(tim)
  1099                              <1> ;int tim[];
  1100                              <1> ;{
  1101                              <1> ;	register int *t, *ct, dayno;
  1102                              <1> ;	int daylbegin, daylend;
  1103                              <1> ;	int copyt[2];
  1104                              <1> ;
  1105                              <1> ;	t = copyt;
  1106                              <1> ;	t[0] = tim[0];
  1107                              <1> ;	t[1] = tim[1];
  1108                              <1> ;	dpadd(t, -timezone);
  1109                              <1> ;	ct = gmtime(t);
  1110                              <1> ;	dayno = ct[YDAY];
  1111                              <1> ;	if (nixonflg && (ct[YEAR]>74 || ct[YEAR]==74 && (dayno > 5 ||
  1112                              <1> ;	    dayno==5 && ct[HOUR]>=2))) {
  1113                              <1> ;		daylight =| 1;
  1114                              <1> ;		daylbegin = -1;
  1115                              <1> ;		daylend = 367;
  1116                              <1> ;	} else {
  1117                              <1> ;		daylbegin = sunday(ct, 119);	/* last Sun in Apr */
  1118                              <1> ;		daylend = sunday(ct, 303);	/* last Sun in Oct */
  1119                              <1> ;	}
  1120                              <1> ;	if (daylight &&
  1121                              <1> ;	    (dayno>daylbegin || (dayno==daylbegin && ct[HOUR]>=2)) &&
  1122                              <1> ;	    (dayno<daylend || (dayno==daylend && ct[HOUR]<1))) {
  1123                              <1> ;		dpadd(t, 1*60*60);
  1124                              <1> ;		ct = gmtime(t);
  1125                              <1> ;		ct[ISDAY]++;
  1126                              <1> ;	}
  1127                              <1> ;	return(ct);
  1128                              <1> ;}
  1129                              <1> ;
  1130                              <1> ;sunday(at, ad)
  1131                              <1> ;int *at;
  1132                              <1> ;{
  1133                              <1> ;	register int *t, d;
  1134                              <1> ;
  1135                              <1> ;	t = at;
  1136                              <1> ;	d = ad;
  1137                              <1> ;	d = ad + dysize(t[YEAR]) - 365;
  1138                              <1> ;	return(d - (d - t[YDAY] + t[WDAY] + 700) % 7);
  1139                              <1> ;}
  1140                              <1> ;
  1141                              <1> ;gmtime(tim)
  1142                              <1> ;int tim[];
  1143                              <1> ;{
  1144                              <1> ;	register int d0, d1;
  1145                              <1> ;	register *tp;
  1146                              <1> ;	static xtime[9];
  1147                              <1> ;	extern int ldivr;
  1148                              <1> ;
  1149                              <1> ;	/*
  1150                              <1> ;	 * break initial number into
  1151                              <1> ;	 * multiples of 8 hours.
  1152                              <1> ;	 * (28800 = 60*60*8)
  1153                              <1> ;	 */
  1154                              <1> ;
  1155                              <1> ;	d0 = ldiv(tim[0], tim[1], 28800);
  1156                              <1> ;	d1 = ldivr;
  1157                              <1> ;	tp = &xtime[0];
  1158                              <1> ;
  1159                              <1> ;	/*
  1160                              <1> ;	 * generate hours:minutes:seconds
  1161                              <1> ;	 */
  1162                              <1> ;
  1163                              <1> ;	*tp++ = d1%60;
  1164                              <1> ;	d1 =/ 60;
  1165                              <1> ;	*tp++ = d1%60;
  1166                              <1> ;	d1 =/ 60;
  1167                              <1> ;	d1 =+ (d0%3)*8;
  1168                              <1> ;	d0 =/ 3;
  1169                              <1> ;	*tp++ = d1;
  1170                              <1> ;
  1171                              <1> ;	/*
  1172                              <1> ;	 * d0 is the day number.
  1173                              <1> ;	 * generate day of the week.
  1174                              <1> ;	 */
  1175                              <1> ;
  1176                              <1> ;	xtime[WDAY] = (d0+4)%7;
  1177                              <1> ;
  1178                              <1> ;	/*
  1179                              <1> ;	 * year number
  1180                              <1> ;	 */
  1181                              <1> ;	for(d1=70; d0 >= dysize(d1); d1++)
  1182                              <1> ;		d0 =- dysize(d1);
  1183                              <1> ;	xtime[YEAR] = d1;
  1184                              <1> ;	xtime[YDAY] = d0;
  1185                              <1> ;
  1186                              <1> ;	/*
  1187                              <1> ;	 * generate month
  1188                              <1> ;	 */
  1189                              <1> ;
  1190                              <1> ;	if (dysize(d1)==366)
  1191                              <1> ;		dmsize[1] = 29;
  1192                              <1> ;	for(d1=0; d0 >= dmsize[d1]; d1++)
  1193                              <1> ;		d0 =- dmsize[d1];
  1194                              <1> ;	dmsize[1] = 28;
  1195                              <1> ;	*tp++ = d0+1;
  1196                              <1> ;	*tp++ = d1;
  1197                              <1> ;	xtime[ISDAY] = 0;
  1198                              <1> ;	return(xtime);
  1199                              <1> ;}
  1200                              <1> ;
  1201                              <1> ;asctime(t)
  1202                              <1> ;int *t;
  1203                              <1> ;{
  1204                              <1> ;	register char *cp, *ncp;
  1205                              <1> ;	register int *tp;
  1206                              <1> ;
  1207                              <1> ;	cp = cbuf;
  1208                              <1> ;	for (ncp = "Day Mon 00 00:00:00 1900\n"; *cp++ = *ncp++;);
  1209                              <1> ;	ncp = &"SunMonTueWedThuFriSat"[3*t[6]];
  1210                              <1> ;	cp = cbuf;
  1211                              <1> ;	*cp++ = *ncp++;
  1212                              <1> ;	*cp++ = *ncp++;
  1213                              <1> ;	*cp++ = *ncp++;
  1214                              <1> ;	cp++;
  1215                              <1> ;	tp = &t[4];
  1216                              <1> ;	ncp = &"JanFebMarAprMayJunJulAugSepOctNovDec"[(*tp)*3];
  1217                              <1> ;	*cp++ = *ncp++;
  1218                              <1> ;	*cp++ = *ncp++;
  1219                              <1> ;	*cp++ = *ncp++;
  1220                              <1> ;	cp = numb(cp, *--tp);
  1221                              <1> ;	cp = numb(cp, *--tp+100);
  1222                              <1> ;	cp = numb(cp, *--tp+100);
  1223                              <1> ;	cp = numb(cp, *--tp+100);
  1224                              <1> ;	cp =+ 2;
  1225                              <1> ;	cp = numb(cp, t[YEAR]);
  1226                              <1> ;	return(cbuf);
  1227                              <1> ;}
  1228                              <1> ;
  1229                              <1> ;dysize(y)
  1230                              <1> ;{
  1231                              <1> ;	if((y%4) == 0)
  1232                              <1> ;		return(366);
  1233                              <1> ;	return(365);
  1234                              <1> ;}
  1235                              <1> ;
  1236                              <1> ;
  1237                              <1> ;numb:
  1238                              <1> ;	
  1239                              <1> ;
  1240                              <1> ;numb(acp, n)
  1241                              <1> ;{
  1242                              <1> ;	register char *cp;
  1243                              <1> ;	cp = acp;
  1244                              <1> ;	cp++;
  1245                              <1> ;	if (n>=10)
  1246                              <1> ;		*cp++ = (n/10)%10 + '0';
  1247                              <1> ;	else
  1248                              <1> ;		*cp++ = ' ';
  1249                              <1> ;	*cp++ = n%10 + '0';
  1250                              <1> ;	return(cp);
  1251                              <1> ;}
  1252                              <1> ;
   493                                  ; 	(ctime386.s file last modification date: 25/02/2022) 
   494                                  
   495                                  ;-----------------------------------------------------------------
   496                                  ;  data - initialized data
   497                                  ;-----------------------------------------------------------------
   498                                  
   499                                  ;;argc:	dd 0
   500                                  ;argc:	db 0
   501                                  
   502                                  ; ----------------------------------------------------------------
   503                                  
   504                                  ;program_msg:
   505                                  	;db  0Dh, 0Ah
   506 000003B6 526574726F20554E49-     	db  'Retro UNIX 386 v1 DATE by Erdogan TAN - 02/06/2022'
   506 000003BF 582033383620763120-
   506 000003C8 444154452062792045-
   506 000003D1 72646F67616E205441-
   506 000003DA 4E202D2030322F3036-
   506 000003E3 2F32303232         
   507                                  	;db  0Dh, 0Ah, 0
   508 000003E8 00                      	db 0
   509                                  
   510                                  ;usage_msg:
   511                                  ;	db  0Dh, 0Ah
   512                                  ;	db  'usage: date [ mmddhhmm[yy] ]' ; (unix v5)
   513                                  
   514                                  ;nextline:
   515                                  ;	db  0Dh, 0Ah, 0
   516                                  
   517                                  msg_bad:
   518 000003E9 0D0A                    	db 0Dh, 0Ah
   519 000003EB 62616420636F6E7665-     	db 'bad conversion'
   519 000003F4 7273696F6E         
   520                                  nextline:
   521 000003F9 0D0A00                  	db 0Dh, 0Ah, 0
   522                                  
   523                                  msg_no_perm:
   524 000003FC 0D0A                    	db 0Dh, 0Ah
   525 000003FE 6E6F207065726D6973-     	db 'no permission'
   525 00000407 73696F6E           
   526 0000040B 0D0A00                  	db 0Dh, 0Ah, 0
   527                                  
   528                                  ;-----------------------------------------------------------------
   529                                  ;  bss - uninitialized data
   530                                  ;-----------------------------------------------------------------
   531                                  
   532 0000040E 90<rep 2h>              align 4
   533                                  
   534                                  bss_start:
   535                                  
   536                                  ABSOLUTE bss_start
   537                                  
   538 00000410 ????????                timbuf:	resd 1 ; (unix epoch time, 32 bit)
   539                                  
   540 00000414 ??                      _t_:	resb 1 ; month
   541 00000415 ??                      _d_:	resb 1 ; day
   542 00000416 ??                      _h_:	resb 1 ; hour
   543 00000417 ??                      _m_:	resb 1 ; minute
   544 00000418 ????                    _y_:	resw 1 ; year
   545 0000041A ????                    	resw 1
   546                                  
   547                                  ; 31/05/2022
   548                                  ;-----------------------------------------------------------------
   549                                  ; Original UNIX v5 - date - c source code (date.s)
   550                                  ;-----------------------------------------------------------------
   551                                  ; UNIX V5 source code: see www.tuhs.org for details.
   552                                  ;-----------------------------------------------------------------
   553                                  ; v5root.tar.gz - usr/source/s1/date.c (archive date: 27-11-1974)
   554                                  
   555                                  ;int	timbuf[2];
   556                                  ;char	*cbp;
   557                                  ;
   558                                  ;char *tzname[2];
   559                                  ;int	dmsize[];
   560                                  ;char	cbuf[];
   561                                  ;char	*cbp;
   562                                  ;
   563                                  ;struct {
   564                                  ;	char	name[8];
   565                                  ;	char	tty;
   566                                  ;	char	fill1;
   567                                  ;	int	wtime[2];
   568                                  ;	int	fill2;
   569                                  ;} wtmp[2];
   570                                  ;
   571                                  ;main(argc, argv)
   572                                  ;int argc, **argv;
   573                                  ;{
   574                                  ;	register char *tzn;
   575                                  ;	extern int timezone, *localtime();
   576                                  ;	int wf;
   577                                  ;
   578                                  ;	if(argc > 1) {
   579                                  ;		cbp = argv[1];
   580                                  ;		if(gtime()) {
   581                                  ;			write(1, "bad conversion\n", 15);
   582                                  ;			exit();
   583                                  ;		}
   584                                  ;		if (*cbp != 's') {
   585                                  ;	/* convert to Greenwich time, on assumption of Standard time. */
   586                                  ;			dpadd(timbuf, timezone);
   587                                  ;	/* Now fix up to local daylight time. */
   588                                  ;			if (localtime(timbuf)[8])
   589                                  ;				dpadd(timbuf, -1*60*60);
   590                                  ;		}
   591                                  ;		time(wtmp[0].wtime);
   592                                  ;		wtmp[0].tty =  '|';
   593                                  ;		if(stime(timbuf) < 0)
   594                                  ;			write(1, "no permission\n", 14);
   595                                  ;		if ((wf = open("/usr/adm/wtmp", 1)) >= 0) {
   596                                  ;			time(wtmp[1].wtime);
   597                                  ;			wtmp[1].tty = '}';
   598                                  ;			seek(wf, 0, 2);
   599                                  ;			write(wf, wtmp, 32);
   600                                  ;		}
   601                                  ;	}
   602                                  ;	time(timbuf);
   603                                  ;	cbp = cbuf;
   604                                  ;	ctime(timbuf);
   605                                  ;	write(1, cbuf, 20);
   606                                  ;	tzn = tzname[localtime(timbuf)[8]];
   607                                  ;	if (tzn)
   608                                  ;		write(1, tzn, 3);
   609                                  ;	write(1, cbuf+19, 6);
   610                                  ;}
   611                                  ;
   612                                  ;gtime()
   613                                  ;{
   614                                  ;	register int i;
   615                                  ;	register int y, t;
   616                                  ;	int d, h, m;
   617                                  ;	extern int *localtime();
   618                                  ;	int nt[2];
   619                                  ;
   620                                  ;	if (*cbp == 's')
   621                                  ;		return(spidertime());
   622                                  ;	t = gpair();
   623                                  ;	if(t<1 || t>12)
   624                                  ;		goto bad;
   625                                  ;	d = gpair();
   626                                  ;	if(d<1 || d>31)
   627                                  ;		goto bad;
   628                                  ;	h = gpair();
   629                                  ;	if(h == 24) {
   630                                  ;		h = 0;
   631                                  ;		d++;
   632                                  ;	}
   633                                  ;	m = gpair();
   634                                  ;	if(m<0 || m>59)
   635                                  ;		goto bad;
   636                                  ;	y = gpair();
   637                                  ;	if (y<0) {
   638                                  ;		time(nt);
   639                                  ;		y = localtime(nt)[5];
   640                                  ;	}
   641                                  ;	if (*cbp == 'p')
   642                                  ;		h =+ 12;
   643                                  ;	if (h<0 || h>23)
   644                                  ;		goto bad;
   645                                  ;	timbuf[0] = 0;
   646                                  ;	timbuf[1] = 0;
   647                                  ;	y =+ 1900;
   648                                  ;	for(i=1970; i<y; i++)
   649                                  ;		gdadd(dysize(i));
   650                                  ;	while(--t)
   651                                  ;		gdadd(dmsize[t-1]);
   652                                  ;	gdadd(d-1);
   653                                  ;	gmdadd(24, h);
   654                                  ;	gmdadd(60, m);
   655                                  ;	gmdadd(60, 0);
   656                                  ;	return(0);
   657                                  ;
   658                                  ;bad:
   659                                  ;	return(1);
   660                                  ;}
   661                                  ;
   662                                  ;gdadd(n)
   663                                  ;{
   664                                  ;	register char *t;
   665                                  ;
   666                                  ;	t = timbuf[1]+n;
   667                                  ;	if(t < timbuf[1])
   668                                  ;		timbuf[0]++;
   669                                  ;	timbuf[1] = t;
   670                                  ;}
   671                                  ;
   672                                  ;gmdadd(m, n)
   673                                  ;{
   674                                  ;	register int t1;
   675                                  ;
   676                                  ;	timbuf[0] =* m;
   677                                  ;	t1 = timbuf[1];
   678                                  ;	while(--m)
   679                                  ;		gdadd(t1);
   680                                  ;	gdadd(n);
   681                                  ;}
   682                                  ;
   683                                  ;gpair()
   684                                  ;{
   685                                  ;	register int c, d;
   686                                  ;	register char *cp;
   687                                  ;
   688                                  ;	cp = cbp;
   689                                  ;	if(*cp == 0)
   690                                  ;		return(-1);
   691                                  ;	c = (*cp++ - '0') * 10;
   692                                  ;	if (c<0 || c>100)
   693                                  ;		return(-1);
   694                                  ;	if(*cp == 0)
   695                                  ;		return(-1);
   696                                  ;	if ((d = *cp++ - '0') < 0 || d > 9)
   697                                  ;		return(-1);
   698                                  ;	cbp = cp;
   699                                  ;	return (c+d);
   700                                  ;}
   701                                  ;
   702                                  ;/*
   703                                  ; * get time from spider network.
   704                                  ; */
   705                                  ;char	asktime[] {0226, 0207, 0205};
   706                                  ;
   707                                  ;spidertime()
   708                                  ;{
   709                                  ;	register tiuf, n;
   710                                  ;	static char buf[10];
   711                                  ;	struct { char ch[4]; };
   712                                  ;	int c;
   713                                  ;
   714                                  ;	if ((tiuf = open("/dev/tiu/d0", 2)) < 0)
   715                                  ;		return(1);
   716                                  ;	/* get trouble */
   717                                  ;	snstat(tiuf, &c, 3);
   718                                  ;	/* set signal */
   719                                  ;	c = 3;
   720                                  ;	snstat(tiuf, &c, 0);
   721                                  ;	write(tiuf, asktime, 3);
   722                                  ;	snstat(tiuf, &c, 3);
   723                                  ;	n = read(tiuf, buf, 10);
   724                                  ;	/* get signal byte */
   725                                  ;	snstat(tiuf, &c, 1);
   726                                  ;	if (c!=3 || buf[0]!=012 || buf[5]!=0177600)
   727                                  ;		return(1);
   728                                  ;	timbuf[0].ch[0] = buf[2];
   729                                  ;	timbuf[0].ch[1] = buf[1];
   730                                  ;	timbuf[0].ch[2] = buf[4];
   731                                  ;	timbuf[0].ch[3] = buf[3];
   732                                  ;	return(0);
   733                                  ;}
