     1                                  ; ****************************************************************************
     2                                  ; init386.s (init7.s) - Retro Unix 386 v1.2 - /etc/init - sys initialization 
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; Retro UNIX 386 v1 - /etc/init - process control initialization
     5                                  ;
     6                                  ; [ Last Modification: 02/03/2022 ]
     7                                  ;
     8                                  ; Derived from UNIX Operating System (v1.0 for PDP-11) 
     9                                  ; (Original) Source Code by Ken Thompson (1971-1972)
    10                                  ; <Bell Laboratories (17/3/1972)>
    11                                  ; <Preliminary Release of UNIX Implementation Document> (Section E.12)
    12                                  ; ****************************************************************************
    13                                  ; init4.s (17/11/2015) - Retro UNIX 386 v1
    14                                  ;
    15                                  ; (Retro UNIX 386 v1 - init386.s, NASM 2.11)
    16                                  ; Derived from INIT09.ASM (17/01/2014, Retro UNIX 8086 v1, MASM 6.11)  
    17                                  ; Derived from 'init.s' file of original UNIX v1
    18                                  ; INIT09.ASM, 17/01/2014 
    19                                  
    20                                  ; 27/02/2022
    21                                  ; 09/02/2022 (init7.s) - Retro UNIX 386 v1.2 & v1.1 (& v1.0)
    22                                  ; 24/01/2022 (init6.s) - Retro UNIX 386 v1.1
    23                                  ; 24/01/2022 (init5.s) - Retro UNIX 386 v1.2
    24                                  ; 17/11/2015 (init4.s)
    25                                  ; 23/10/2015 (init3.s)
    26                                  ; 14/10/2015 (init2.s)
    27                                  ; 17/09/2015
    28                                  ; 03/09/2015
    29                                  ; 27/08/2015
    30                                  ; 13/08/2015
    31                                  ; 07/08/2015
    32                                  ; 30/06/2015
    33                                  ; 14/07/2013
    34                                  
    35                                  ; 12/01/2022 (Retro UNIX 386 v1.2)
    36                                  ;
    37                                  ; UNIX v1 system calls
    38                                  _rele 	equ 0
    39                                  _exit 	equ 1
    40                                  _fork 	equ 2
    41                                  _read 	equ 3
    42                                  _write	equ 4
    43                                  _open	equ 5
    44                                  _close 	equ 6
    45                                  _wait 	equ 7
    46                                  _creat 	equ 8
    47                                  _link 	equ 9
    48                                  _unlink	equ 10
    49                                  _exec	equ 11
    50                                  _chdir	equ 12
    51                                  _time 	equ 13
    52                                  _mkdir 	equ 14
    53                                  _chmod	equ 15
    54                                  _chown	equ 16
    55                                  _break	equ 17
    56                                  _stat	equ 18
    57                                  _seek	equ 19
    58                                  _tell 	equ 20
    59                                  _mount	equ 21
    60                                  _umount	equ 22
    61                                  _setuid	equ 23
    62                                  _getuid	equ 24
    63                                  _stime	equ 25
    64                                  _quit	equ 26	
    65                                  _intr	equ 27
    66                                  _fstat	equ 28
    67                                  _emt 	equ 29
    68                                  _mdate 	equ 30
    69                                  _stty 	equ 31
    70                                  _gtty	equ 32
    71                                  _ilgins	equ 33
    72                                  _sleep	equ 34 ; Retro UNIX 8086 v1 feature only !
    73                                  _msg    equ 35 ; Retro UNIX 386 v1 feature only !
    74                                  _sleep	equ 34 ; Retro UNIX 8086 v1 feature only !
    75                                  _msg	equ 35 ; Retro UNIX 386 v1 feature only !
    76                                  _geterr	equ 36 ; Retro UNIX 386 v1 feature only !
    77                                  ; 12/01/2022 - Retro UNIX 386 v1.2
    78                                  ; Retro UNIX 386 v2 system calls
    79                                  _setgid	equ 37
    80                                  _getgid	equ 38
    81                                  _sysver	equ 39 ; (get) Retro Unix 386 version
    82                                  
    83                                  ;;;
    84                                  ESCKey equ 1Bh
    85                                  EnterKey equ 0Dh
    86                                  
    87                                  %macro sys 1-4
    88                                      ; 03/09/2015	
    89                                      ; 13/04/2015
    90                                      ; Retro UNIX 386 v1 system call.		
    91                                      %if %0 >= 2   
    92                                          mov ebx, %2
    93                                          %if %0 >= 3    
    94                                              mov ecx, %3
    95                                              %if %0 = 4
    96                                                 mov edx, %4   
    97                                              %endif
    98                                          %endif
    99                                      %endif
   100                                      mov eax, %1
   101                                      int 30h	   
   102                                  %endmacro
   103                                  
   104                                  ; Retro UNIX 386 v1 system call format:
   105                                  ; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
   106                                  
   107                                  [BITS 32] ; We need 32-bit intructions for protected mode
   108                                  
   109                                  [ORG 0] 
   110                                  
   111                                  START_CODE:
   112                                  	sys	_intr, 0  ; disable time-out function 
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 00000000 BB00000000          <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94                              <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 00000005 B81B000000          <1>  mov eax, %1
   101 0000000A CD30                <1>  int 30h
   113                                  	sys	_quit, 0  ; disable quit (ctrl+brk) signal
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 0000000C BB00000000          <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94                              <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 00000011 B81A000000          <1>  mov eax, %1
   101 00000016 CD30                <1>  int 30h
   114                                  
   115                                          sys	_open, ctty, 0 ; open tty0
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 00000018 BB[F8010000]        <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94 0000001D B900000000          <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 00000022 B805000000          <1>  mov eax, %1
   101 00000027 CD30                <1>  int 30h
   116 00000029 7256                    	jc	short error
   117                                  
   118                                          sys	_open, ctty, 1 ; for read and write
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 0000002B BB[F8010000]        <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94 00000030 B901000000          <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 00000035 B805000000          <1>  mov eax, %1
   101 0000003A CD30                <1>  int 30h
   119 0000003C 7243                    	jc	short error
   120                                  
   121                                  	sys	_write, 1, msg_te, sizeof_mte
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 0000003E BB01000000          <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94 00000043 B9[5C020000]        <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96 00000048 BA55000000          <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 0000004D B804000000          <1>  mov eax, %1
   101 00000052 CD30                <1>  int 30h
   122 00000054 722B                            jc	short error
   123                                  i0:
   124                                  	sys	_read, 0, tchar, 1
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 00000056 BB00000000          <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94 0000005B B9[F6010000]        <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96 00000060 BA01000000          <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 00000065 B803000000          <1>  mov eax, %1
   101 0000006A CD30                <1>  int 30h
   125 0000006C 7213                    	jc	short error
   126                                  
   127                                  	;sys	_close, 0 ; close input file/tty
   128                                  	;jc	short error
   129                                          ;sys	_close, 1 ; close output file/tty
   130                                  	;jc	short error
   131                                  
   132 0000006E A0[F6010000]            	mov	al, [tchar]
   133                                  
   134                                  	; 27/02/2022
   135                                  	;cmp	al, EnterKey
   136                                  	;je	short multiuser
   137                                  
   138 00000073 3C1B                    	cmp	al, ESCKey
   139 00000075 7430                    	je	short singleuser
   140                                  
   141                                  	;jmp	short i0
   142                                  
   143                                  	; 27/02/2022
   144                                  	; (ALT+127 will ensure multiuser login without tty8 and tty9)
   145 00000077 3C7F                    	cmp	al, 7Fh ; ALT+127
   146 00000079 7479                    	je	short multiuser_x
   147                                  
   148                                  	; 27/02/2022
   149 0000007B 3C0D                    	cmp	al, EnterKey
   150 0000007D 747C                    	je	short multiuser
   151                                  
   152 0000007F EBD5                    	jmp	short i0
   153                                  		
   154                                  error:
   155                                  	sys	_msg, error_msg, 255, 0Ch 
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 00000081 BB[D1020000]        <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94 00000086 B9FF000000          <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96 0000008B BA0C000000          <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 00000090 B823000000          <1>  mov eax, %1
   101 00000095 CD30                <1>  int 30h
   156                                  		; error message with red color (max. 255 chars)
   157                                  exit:
   158                                  	sys	_exit
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92                              <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94                              <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 00000097 B801000000          <1>  mov eax, %1
   101 0000009C CD30                <1>  int 30h
   159                                  
   160                                  haltsys:
   161                                  	;hlt
   162                                  	; 17/09/2015
   163 0000009E 90                      	nop
   164 0000009F 90                      	nop
   165 000000A0 90                      	nop
   166 000000A1 90                      	nop
   167 000000A2 90                      	nop
   168 000000A3 90                      	nop
   169 000000A4 90                      	nop
   170 000000A5 EBF7                    	jmp	short haltsys
   171                                  
   172                                  singleuser:
   173                                  i1:
   174                                  help:
   175                                  	sys	_close, 0 ; close input file/tty
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 000000A7 BB00000000          <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94                              <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 000000AC B806000000          <1>  mov eax, %1
   101 000000B1 CD30                <1>  int 30h
   176                                  	;jc	short error
   177                                  	sys	_close, 1 ; close output file/tty
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 000000B3 BB01000000          <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94                              <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 000000B8 B806000000          <1>  mov eax, %1
   101 000000BD CD30                <1>  int 30h
   178                                  	;jc	short error
   179                                  	sys	_open, ctty, 0 ; open control tty
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 000000BF BB[F8010000]        <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94 000000C4 B900000000          <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 000000C9 B805000000          <1>  mov eax, %1
   101 000000CE CD30                <1>  int 30h
   180                                  	;jc	short error
   181                                          sys	_open, ctty, 1 ; for read an write
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 000000D0 BB[F8010000]        <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94 000000D5 B901000000          <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 000000DA B805000000          <1>  mov eax, %1
   101 000000DF CD30                <1>  int 30h
   182                                  	;jc	short error
   183                                  	;
   184                                  	sys	_exec, shell, shellp
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 000000E1 BB[02020000]        <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94 000000E6 B9[22020000]        <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 000000EB B80B000000          <1>  mov eax, %1
   101 000000F0 CD30                <1>  int 30h
   185                                  	;
   186 000000F2 EBB3                     	jmp	short i1
   187                                  
   188                                  multiuser_x:	; 27/02/2022
   189 000000F4 C605[52020000]00        	mov	byte [itabs], 0 ; (disable serial port login)
   190                                  
   191                                  multiuser:
   192                                  	sys	_close, 0 ; close input file/tty
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 000000FB BB00000000          <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94                              <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 00000100 B806000000          <1>  mov eax, %1
   101 00000105 CD30                <1>  int 30h
   193                                  	;jc	short error
   194                                          sys	_close, 1 ; close output file/tty
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 00000107 BB01000000          <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94                              <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 0000010C B806000000          <1>  mov eax, %1
   101 00000111 CD30                <1>  int 30h
   195                                  	;jc	short error
   196                                  
   197                                  ; 09/02/2022
   198                                  
   199                                  ;	sys	_mount, fd1, usr
   200                                  ;			; root directory on mounted fd1
   201                                  ;			; disk is /usr
   202                                  ;	; 23/01/2022
   203                                  ;	; truncate /tmp/utmp 
   204                                  ;	sys	_creat, utmp, 1A4h ; Retro UNIX 386 1.2 
   205                                  ;				   ; (runix v2 fs inode flags)
   206                                  ;	;sys	_creat, utmp, 14 ; Retro UNIX 386 v1.1
   207                                  ;	;jc	short error	 ; (unix v1 fs inode flags)
   208                                  ;
   209                                  ;	sys	_close, eax	; close it
   210                                  ;	
   211                                  ;	; 23/01/2022
   212                                  ;	mov	byte [zero+8], 'x'
   213                                  ;	;mov	byte [zero+8], 0 ; put identifier
   214                                  ;				 ; in output buffer
   215                                  ;
   216                                  ;	call	wtmprec	     ; go to (call) write acting info
   217                                  
   218                                  	; 23/10/2015
   219                                  	;
   220                                  	;; 10/12/2013
   221                                  	;; 'Enable Multi Tasking' (Time-Out)
   222                                  	;; system call (Retro UNIX 8086 v1 feature only !)
   223                                  	sys	_emt, 1
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 00000113 BB01000000          <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94                              <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 00000118 B81D000000          <1>  mov eax, %1
   101 0000011D CD30                <1>  int 30h
   224                                  	;;
   225                                  
   226 0000011F BE[32020000]            	mov	esi, itab    ; address of table to ESI
   227                                  
   228                                  ; create shell processes
   229                                  i2:
   230 00000124 66AD                    	lodsw		     ; 'x', x=0, 1... to AX
   231 00000126 6621C0                  	and	ax, ax
   232 00000129 7412                    	jz	short pwait  ; branch if table end
   233                                  	
   234 0000012B A2[14020000]            	mov	[ttyx+8], al ; put symbol in ttyx
   235                                  	; 02/03/2022
   236                                  	;mov	ecx, eax ; 27/02/2022
   237 00000130 89F7                    	mov	edi, esi
   238 00000132 E83D000000              	call	dfork        ; go to make new init for this ttyx
   239                                  	;mov	eax, ecx ; 27/02/2022
   240 00000137 66AB                    	stosw		     ; save child id in word offer
   241                                  	 		     ;	'0', '1',...etc.
   242 00000139 89FE                    	mov	esi, edi
   243 0000013B EBE7                    	jmp	short i2     ; set up next child
   244                                  
   245                                  ; wait for process to die
   246                                  pwait:
   247                                  	;sys	_write, 1, beep, 1 ; 10/12/2013
   248                                  	;
   249                                          sys	_wait       ; wait for user to terminate process
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92                              <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94                              <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 0000013D B807000000          <1>  mov eax, %1
   101 00000142 CD30                <1>  int 30h
   250                                  	; 02/03/2022
   251 00000144 7305                    	jnc	short i6    ; (eax = process ID of the child)
   252                                  	; ERROR ! there is not a child process to wait ! 
   253                                  	; (This may be only viable option for now!) - 02/03/2022 - 
   254 00000146 E936FFFFFF              	jmp	error	; (print error message then terminate) 	
   255                                  i6:
   256 0000014B BE[32020000]            	mov	esi, itab   ; initialize for search
   257                                  	; 02/03/2022 
   258                                  	;mov	dx, ax
   259                                  	; 24/01/2022
   260 00000150 89C2                    	mov	edx, eax    ; (process ID of the child)
   261                                  
   262                                  ; search for process id
   263                                  i3:
   264 00000152 66AD                    	lodsw		    ; bump ESI to child id location
   265 00000154 6609C0                  	or	ax, ax
   266 00000157 74E4                    	jz	short pwait ; ? something silly
   267                                  
   268 00000159 66AD                    	lodsw
   269                                  	; 24/01/2022
   270 0000015B 39C2                    	cmp	edx, eax
   271                                  	;cmp	dx, ax      ; which process has terminated
   272 0000015D 75F3                    	jne	short i3    ; not this one
   273                                  
   274                                  ; take name out of utmp
   275                                  
   276                                  ; 09/02/2022
   277                                  ;	;mov	ecx, 4
   278                                  ;	; 24/01/2022
   279                                  ;	xor 	ecx, ecx
   280                                  ;	mov	cl, 4
   281                                  ;	sub	esi, 4	  ; process is found, point x to 'x'
   282                                  ;		          ; for it
   283                                  ;	sub	esi, ecx  ; 4
   284                                  ;	;push	esi	  ; save address on stack
   285                                  ;	mov	ax, [esi] ; move 'x' to AX
   286                                  ;	; 24/01/2022
   287                                  ;	sub	al, '0'
   288                                  ;	;sub	ax, '0'   ; remove zone bits from character
   289                                  ;	;;shl	ax, 4	  ; generate proper offset for seek
   290                                  ;	shl	ax, cl	  ; 4
   291                                  ;	;movzx	edx, ax	
   292                                  ;	; 24/01/2022
   293                                  ;	mov	edx, eax
   294                                  ;	mov	edi, zero
   295                                  ;	xor	eax, eax  ; 0 ; clear	
   296                                  ;	;mov	ecx, 4	  ; output buffer
   297                                  ;	rep	stosd	 
   298                                  ;	sys	_open, utmp, 1
   299                                  ;			  ; open file for writing
   300                                  ;	jc	short i4  ; if can't open, create user anyway
   301                                  ;	;movzx	edi, ax	  ; save file desc
   302                                  ;	; 24/01/2022
   303                                  ;	mov	edi, eax  ; save file descriptor	
   304                                  ;	sys	_seek, eax, edx, 0
   305                                  ;			  ; move to proper pointer position
   306                                  ;	sys	_write, edi, zero, 16
   307                                  ;			  ; zero this position in
   308                                  ;	sys	_close, edi
   309                                  ;			  ; close file
   310                                  
   311                                  ; re-create user process
   312                                  
   313                                  	; 02/03/2022
   314 0000015F 83EE04                  	sub	esi, 4
   315                                  i4:
   316                                  	;pop	esi	  ; restore 'x' to ESI
   317 00000162 66AD                    	lodsw		  ; move it to AX
   318 00000164 89F7                    	mov	edi, esi 
   319 00000166 A2[14020000]            	mov	[ttyx+8], al ; get correct ttyx
   320                                  
   321                                  ; 09/02/2022
   322                                  ;	mov	[zero+8], al
   323                                  ;	 		  ; move identifier to output buffer
   324                                  ;	call	wtmprec   ; go to write accting into
   325                                  
   326 0000016B E804000000              	call	dfork     ; fork
   327 00000170 66AB                    	stosw		  ; save id of child
   328                                  	; 02/03/2022 
   329                                  	;; 27/02/2022
   330                                  	;mov	edx, eax  ; save id of child
   331                                  	;	
   332 00000172 EBC9                    	jmp	pwait	  ; go to wait for next process end
   333                                  
   334                                  dfork:
   335 00000174 BB[83010000]            	mov	ebx, i5 ; return address for new process
   336                                  	sys	_fork
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92                              <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94                              <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 00000179 B802000000          <1>  mov eax, %1
   101 0000017E CD30                <1>  int 30h
   337 00000180 72F2                    	jc	short dfork ; try again
   338 00000182 C3                      	retn
   339                                  
   340                                  i5: ; to new copy of init
   341                                  	;sys	_quit, 0  ; disable quit (ctrl+brk) signal
   342                                  	;sys	_intr, 0  ; disable time-out function 
   343                                  	;sys	_chown, ttyx, 0
   344                                  	;;sys	_chmod; ttyx, 15
   345                                  	;sys	_chmod; ttyx, 13 ; 23/01/2022
   346                                  o0:	
   347 00000183 31DB                    	xor	ebx, ebx
   348                                  	;xor	ch, ch
   349                                  	;mov	cl, [ttyx+8]
   350 00000185 0FB60D[14020000]        	movzx	ecx, byte [ttyx+8]
   351 0000018C 80E930                  	sub	cl, '0'
   352                                  	; 17/01/2014
   353                                  	; 07/12/2013
   354                                  	; set console tty for current process
   355                                  	;mov	dx, 0FF00h
   356                                  	;mov	dh, 0FFh ; do not set cursor position
   357                                  		     ; do not set serial port parameters	
   358 0000018F BA00FF0000              	mov	edx, 0FF00h	
   359                                  	sys	_stty
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92                              <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94                              <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 00000194 B81F000000          <1>  mov eax, %1
   101 00000199 CD30                <1>  int 30h
   360 0000019B 724D                            jc	short terminate
   361                                  o1:
   362                                  	; 16/11/2015	
   363                                  	sys	_open, ttyx, 0 ; open this ttyx for reading
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 0000019D BB[0C020000]        <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94 000001A2 B900000000          <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 000001A7 B805000000          <1>  mov eax, %1
   101 000001AC CD30                <1>  int 30h
   364                                  	;jnc	short o2
   365                                  	;call	wait_for_terminal
   366                                  	;jmp	short o1
   367                                  	; 17/11/2015
   368 000001AE 723A                    	jc	short terminate	
   369                                  o2:
   370                                  	; 16/11/2015
   371                                  	sys	_open, ttyx, 1 ; open this ttyx for writing
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 000001B0 BB[0C020000]        <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94 000001B5 B901000000          <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 000001BA B805000000          <1>  mov eax, %1
   101 000001BF CD30                <1>  int 30h
   372                                  	;jnc	short o3
   373                                  	;call	wait_for_terminal
   374                                  	;jmp	short o2
   375                                  	; 17/11/2015
   376 000001C1 7227                    	jc	short terminate			
   377                                  o3:	
   378                                  	sys	_exec, getty, gettyp ; getty types <login> and
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 000001C3 BB[16020000]        <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94 000001C8 B9[2A020000]        <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 000001CD B80B000000          <1>  mov eax, %1
   101 000001D2 CD30                <1>  int 30h
   379                                  				; executes login which logs user
   380                                  				; in and executes sh-
   381                                  	; 14/10/2015
   382                                  	sys	_msg, getty_error_msg, 255, 0Ch 
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92 000001D4 BB[E7020000]        <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94 000001D9 B9FF000000          <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96 000001DE BA0C000000          <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 000001E3 B823000000          <1>  mov eax, %1
   101 000001E8 CD30                <1>  int 30h
   383                                  				; error msg with red color
   384                                  terminate:
   385                                  	sys	_exit  ; HELP!
    88                              <1> 
    89                              <1> 
    90                              <1> 
    91                              <1>  %if %0 >= 2
    92                              <1>  mov ebx, %2
    93                              <1>  %if %0 >= 3
    94                              <1>  mov ecx, %3
    95                              <1>  %if %0 = 4
    96                              <1>  mov edx, %4
    97                              <1>  %endif
    98                              <1>  %endif
    99                              <1>  %endif
   100 000001EA B801000000          <1>  mov eax, %1
   101 000001EF CD30                <1>  int 30h
   386                                  ;help1:
   387 000001F1 E9B1FEFFFF              	jmp	help
   388                                  
   389                                  ;wait_for_terminal:
   390                                  ;	; 16/11/2015
   391                                  ;	; 24/10/2015
   392                                  ;	mov	al, [ttyx+8]
   393                                  ;	sub	al, '0'
   394                                  ;	cmp	al, 8
   395                                  ;	jb	short sysexit
   396                                  ;	sys	_sleep
   397                                  ;	retn
   398                                  ;sysexit:
   399                                  ;	pop	eax ;return address	
   400                                  ;	jmp	short terminate
   401                                  
   402                                  ; 09/02/2022
   403                                  ;wtmprec:
   404                                  ;	; 24/01/2022
   405                                  ;	; 23/10/2015 (wtmp_err)
   406                                  ;	;cmp	byte [wtmp_err], 0
   407                                  ;	;ja	short i6 	
   408                                  ;
   409                                  ;	sys	_time  ; get time
   410                                  ;	mov	[zero+10], eax ; move to output buffer
   411                                  ;
   412                                  ;	sys	_open, wtmp, 1 ; open accounting file
   413                                  ;	;jc	short i7
   414                                  ;	; 24/01/2022
   415                                  ;	jc	short i6
   416                                  ;
   417                                  ;	mov	esi, eax ; save file descriptor
   418                                  ;
   419                                  ;	sys	_seek, eax, 0, 2 ; move pointer to end of file
   420                                  ;	;;push	esi    ; save file descriptor
   421                                  ;	;jc	short i7
   422                                  ;
   423                                  ;	sys	_write, esi, zero, 16 ; write accting info
   424                                  ;	;;pop	ebx	  ; restore file descriptor
   425                                  ;	;jc	short i7
   426                                  ;
   427                                  ;	sys	_close, esi ; close file
   428                                  ;i6:
   429                                  ;	retn
   430                                  ;;i7:
   431                                  ;	;inc	byte [wtmp_err] ; 23/10/2015
   432                                  ;	;retn
   433                                  
   434                                  ; 23/01/2022
   435                                  ;here:
   436                                  ;	hlt	; General Protection Fault ! 17/09/2015
   437                                  ;	;jmp	short here
   438                                  ;	jmp	haltsys	
   439                                  
   440                                  align 2
   441 000001F6 00                      tchar:  db 0
   442 000001F7 90                      align 2
   443 000001F8 2F6465762F74747900      ctty:   db "/dev/tty", 0
   444 00000201 90                      align 2
   445 00000202 2F62696E2F736800        shell:  db "/bin/sh", 0
   446 0000020A 2D00                    shellm: db "-", 0
   447                                  ;align 2
   448                                  ; 09/02/2022
   449                                  ;usr:	db "/usr",0
   450                                  ;align 2
   451                                  ; 09/02/2022	
   452                                  ;fd1:	db "/dev/fd1", 0
   453                                  ;
   454                                  align 2
   455                                  ; 09/02/2022
   456                                  ;utmp:   db "/tmp/utmp", 0
   457                                  ;wtmp:   db "/tmp/wtmp", 0
   458 0000020C 2F6465762F74747978-     ttyx:   db "/dev/ttyx", 0
   458 00000215 00                 
   459 00000216 2F6574632F67657474-     getty:  db "/etc/getty",0
   459 0000021F 7900               
   460                                  
   461 00000221 90                      align 2
   462                                  ; 27/08/2015 (dw -> dd)
   463 00000222 [0A020000]              shellp: dd shellm
   464 00000226 00000000                        dd 0
   465 0000022A [16020000]              gettyp: dd getty
   466 0000022E 00000000                	dd 0
   467                                  itab:
   468 00000232 30000000                	db '0',0, 0,0
   469 00000236 31000000                	db '1',0, 0,0
   470 0000023A 32000000                	db '2',0, 0,0
   471 0000023E 33000000                	db '3',0, 0,0
   472 00000242 34000000                	db '4',0, 0,0
   473 00000246 35000000                	db '5',0, 0,0
   474 0000024A 36000000                	db '6',0, 0,0
   475 0000024E 37000000                	db '7',0, 0,0
   476                                  itabs:		; 27/02/2022
   477                                  	; serial ports (COM1, COM2)
   478 00000252 38000000                	db '8',0, 0,0
   479 00000256 39000000                	db '9',0, 0,0
   480 0000025A 0000                    	dw 0
   481                                  
   482                                  ;-----------------------------------------------------------------
   483                                  ;  messages
   484                                  ;-----------------------------------------------------------------
   485                                  
   486                                  msg_te:
   487 0000025C 0D0A                            db 0Dh, 0Ah
   488 0000025E 5479706520454E5445-             db 'Type ENTER to start in multi user mode', 0Dh, 0Ah
   488 00000267 5220746F2073746172-
   488 00000270 7420696E206D756C74-
   488 00000279 692075736572206D6F-
   488 00000282 64650D0A           
   489 00000286 6F7220747970652045-             db 'or type ESC to start in single user mode.'
   489 0000028F 534320746F20737461-
   489 00000298 727420696E2073696E-
   489 000002A1 676C65207573657220-
   489 000002AA 6D6F64652E         
   490 000002AF 0D0A                            db 0Dh, 0Ah
   491                                  sizeof_mte equ $ - msg_te 
   492 000002B1 00                              db 0
   493                                  copy_right_msg:
   494 000002B2 286329204572646F67-     	db  '(c) Erdogan TAN - 02/03/2022'
   494 000002BB 616E2054414E202D20-
   494 000002C4 30322F30332F323032-
   494 000002CD 32                 
   495 000002CE 0D0A00                  	db  0Dh, 0Ah, 0
   496                                  error_msg:
   497 000002D1 0D0A07                  	db 0Dh, 0Ah, 07h
   498 000002D4 2F6574632F696E6974-     	db '/etc/init error ! '
   498 000002DD 206572726F72202120 
   499 000002E6 00                      	db 0
   500                                  
   501                                  getty_error_msg:
   502                                  	; 14/10/2015
   503 000002E7 0D0A07                  	db 0Dh, 0Ah, 07h
   504 000002EA 2F6574632F67657474-     	db '/etc/getty error ! '
   504 000002F3 79206572726F722021-
   504 000002FC 20                 
   505 000002FD 00                      	db 0
   506                                  
   507                                  ; 23/10/2015
   508                                  align 2
   509                                  ; 09/02/2022
   510                                  ;zero:
   511                                  ;	times 8 db 0
   512                                  ;	times 6 db 0
   513                                  ;	times 2 db 0	 
   514                                  ;
   515                                  ;wtmp_err:
   516                                  ;	db 0
   517                                  
   518                                  ; 23/01/2022
   519                                  	
   520                                  ;-----------------------------------------------------------------
   521                                  ; Original UNIX v1 - /etc/init source code (init.s)
   522                                  ;		     in PDP-11 (unix) assembly language
   523                                  ;-----------------------------------------------------------------
   524                                  
   525                                  ;/ init -- process control initialization
   526                                  ;
   527                                  ;mount = 21.
   528                                  ;
   529                                  ;	sys	intr; 0 / turn off interrupts
   530                                  ;	sys 	quit; 0
   531                                  ;	cmp	csw,$73700 / single user?
   532                                  ;	bne	1f / no
   533                                  ;help:
   534                                  ;	clr	r0 / yes
   535                                  ;	sys	close / close current read
   536                                  ;	mov	$1,r0 / and write
   537                                  ;	sys	close / files
   538                                  ;	sys	open; ctty; 0 / open control tty
   539                                  ;	sys	open; ctty; 1 / for read and write
   540                                  ;	sys	exec; shell; shellp / execute shell
   541                                  ;	br	help / keep trying
   542                                  ;1:
   543                                  ;	mov	$'0,r1 / prepare to change
   544                                  ;1 :
   545                                  ;	movb	r1,tapx+8 / mode of dec tape drive x, where
   546                                  ;	sys	chmod; tapx; 17 / x=0 to 7, to read/write by owner or
   547                                  ;	inc	r1 / non-owner mode
   548                                  ;	cmp	r1,$'8 / finished?
   549                                  ;	blo	1b / no
   550                                  ;	sys	mount; rk0; usr / yes, root file on mounted rko5
   551                                  ;				/ disk ls /usr
   552                                  ;	sys	creat; utmp; 16 / truncate /tmp/utmp
   553                                  ;	sys	close / close it
   554                                  ;	movb	$'x,zero+8. / put identifier in output buffer
   555                                  ;	jsr	pc,wtmprec / go to write accting info
   556                                  ;	mov	$itab,r1 / address of table to r1
   557                                  ;
   558                                  ;/ create shell processes
   559                                  ;
   560                                  ;1:
   561                                  ;	mov	(r1)+,r0 / 'x, x=0, 1... to r0
   562                                  ;	beq	1f / branch if table end
   563                                  ;	movb	r0,ttyx+8 / put symbol in ttyx
   564                                  ;	jsr	pc,dfork / go to make new init for this ttyx
   565                                  ;	mov	r0,(r1)+ / save child id in word offer '0, '1,...etc.
   566                                  ;	br	1b / set up next child
   567                                  ;
   568                                  ;/ wait for process to die
   569                                  ;
   570                                  ;1:
   571                                  ;	sys	wait / wait for user to terminate process
   572                                  ;	mov	$itab,r1 / initialize for search
   573                                  ;
   574                                  ;/ search for process id
   575                                  ;
   576                                  ;2:
   577                                  ;	tst	(r1)+ / bump r1 to child id location
   578                                  ;	beq	1b / ? something silly
   579                                  ;	cmp	r0,(r1)+ / which process has terminated
   580                                  ;	bne	2b / not this one
   581                                  ;
   582                                  ;/ take name out of utmp
   583                                  ;
   584                                  ;	sub	$4, r1 / process is found, point x' to 'x
   585                                  ;		       / for it
   586                                  ;	mov	r1,-(sp) / save address on stack
   587                                  ;	mov	(r1),r1 / move 'x to r1
   588                                  ;	sub	$'0,r1 / remove zone bits from character
   589                                  ;	asl	r1 / generate proper
   590                                  ;	asl	r1 / offset
   591                                  ;	asl	r1 / for
   592                                  ;	asl	r1 / seek
   593                                  ;	mov	r1,0f / move it to offset loc for seek
   594                                  ;	mov	$zero,r1
   595                                  ;2:
   596                                  ;	clr	(r1)+ / ccear-
   597                                  ;	cmp	r1,$zero+16. / output buffer
   598                                  ;	blo	2b / area
   599                                  ;	sys	open; utmp; 1 / open file for writing
   600                                  ;	bes	2f / if can't open, create user anyway
   601                                  ;	mov	r0,r1 / save file desc
   602                                  ;	sys	seek; 0:..; 0 / move to proper pointer position
   603                                  ;	mov	r1,r0 / not required
   604                                  ;	sys	write; zero; 16. / zero this position in
   605                                  ;	mov	r1,r0 / restore file descriptor
   606                                  ;	sys	close / close file
   607                                  ;
   608                                  ;/ re-create user process
   609                                  ;
   610                                  ;2:
   611                                  ;	mov	(sp)+,r1 / restore 'x to r1
   612                                  ;	mov	(r1)+,r0 / move it to r0
   613                                  ;	movb	r0,ttyx+8 / get correct ttyx
   614                                  ;	movb	r0,zero+8 / move identifier to output buffer
   615                                  ;	jsr	pc,wtmprec / go to write accting into
   616                                  ;	jsr	pc,dfork / fork
   617                                  ;	mov	r0,(r1)+ / save id of child
   618                                  ;	br	1b / go to wait for next process end
   619                                  ;
   620                                  ;dfork:
   621                                  ;	mov	r1,r2
   622                                  ;	sub	$itab+2,r2 / left over
   623                                  ;	asl	r2 / from previous
   624                                  ;	asl	r2 / version of code
   625                                  ;	mov	r2,offset
   626                                  ;	sys	fork
   627                                  ;		br 1f / to new copy of init
   628                                  ;	bes	dfork / try again
   629                                  ;	rts	pc / return
   630                                  ;1 :
   631                                  ;	sys	quit; 0 / new init turns off
   632                                  ;	sys	intr; 0 / interrupts
   633                                  ;	sys	chown; ttyx; 0 / change owner to super user
   634                                  ;	sys	chmod; ttyx; 15 / changemode to read/write owner,
   635                                  ;				/ write non-owner
   636                                  ;	sys	open; ttyx; 0 / open this ttyx for reading
   637                                  ;			      / and wait until someone calls
   638                                  ;	bes	help1 / branch if trouble
   639                                  ;	sys	open; ttyx; 1 / open this ttyx for writing after
   640                                  ;			      / user call
   641                                  ;	bes	help1 / branch if trouble
   642                                  ;	sys	exec; getty; gettyp / getty types <login> and
   643                                  ;				    / executes login which logs user
   644                                  ;				    / in and executes sh-
   645                                  ;	sys	exit / HELP!
   646                                  ;
   647                                  ;help1:
   648                                  ;	jmp	help / trouble
   649                                  ;
   650                                  ;wtmprec:
   651                                  ;	sys	time / get time
   652                                  ;	mov	ac,zero+10. / more to output
   653                                  ;	mov	mq,zero+12. / buffer
   654                                  ;	sys	open; wtmp; 1 / open accounting file
   655                                  ;	bes	2f
   656                                  ;	mov	r0,r2 / save file descriptor
   657                                  ;	sys	seek; 0; 2 / move pointer to end of file
   658                                  ;	mov	r2,r0 / not required
   659                                  ;	sys	write; zero; 16. / write accting info
   660                                  ;	mov	r2,r0 / restore file descriptor
   661                                  ;	sys	close / close file
   662                                  ;2:
   663                                  ;	rts	pc
   664                                  ;
   665                                  ;ctty:	</dev/tty\0>
   666                                  ;shell:	</bin/sh\0>
   667                                  ;shellm: <-\0>
   668                                  ;tapx:	</dev/tapx\0>
   669                                  ;rk0:	</dev/rk0\0>
   670                                  ;utmp:	</tmp/utmp\0>
   671                                  ;wtmp:	</tmp/wtmp\0>
   672                                  ;ttyx:	</dev/ttyx\0>
   673                                  ;getty:	</etc/getty\0>
   674                                  ;usr:	</usr\0>
   675                                  ;	.even
   676                                  ;
   677                                  ;shellp: shellm
   678                                  ;	0
   679                                  ;gettyp: getty
   680                                  ;	0
   681                                  ;itab:
   682                                  ;	'0; ..
   683                                  ;	'1; ..
   684                                  ;	'2; ..
   685                                  ;	'3; ..
   686                                  ;	'4; ..
   687                                  ;	'5; ..
   688                                  ;	'6; ..
   689                                  ;	'7; ..
   690                                  ;	0
   691                                  ;
   692                                  ;offset: .=.+2
   693                                  ;zero:	 .=.+8; .=.+6; .=.+2
   694                                  
   695                                  ; 23/01/2022
   696                                  
   697                                  ;-----------------------------------------------------------------
   698                                  ; Original UNIX v2 - /etc/init source code (init.s)
   699                                  ;		     in PDP-11 (unix) assembly language
   700                                  ;-----------------------------------------------------------------
   701                                  
   702                                  ; / init -- process control initialization
   703                                  ;
   704                                  ;	sys	intr; 0
   705                                  ;	sys	quit; 0
   706                                  ;	sys	38. / get console switches
   707                                  ;	cmp	r0,$173030
   708                                  ;	bne	1f
   709                                  ;help:
   710                                  ;	clr	r0
   711                                  ;	sys	close
   712                                  ;	mov	$1,r0
   713                                  ;	sys	close
   714                                  ;	sys	open; ctty; 0
   715                                  ;	sys	open; ctty; 1
   716                                  ;	sys	exec; shell; shellp
   717                                  ;	br	help
   718                                  ;1:
   719                                  ;	sys	mount; rk1; usr
   720                                  ;	sys	mount; rk2; ssys
   721                                  ;	sys	mount; rk3; crp
   722                                  ;	mov	$'0,r1
   723                                  ;1:
   724                                  ;	movb	r1,tapx+8
   725                                  ;	sys	chmod; tapx; 17
   726                                  ;	inc	r1
   727                                  ;	cmp	r1,$'8
   728                                  ;	blo	1b
   729                                  ;	sys	creat; utmp; 16
   730                                  ;	sys	close
   731                                  ;	sys	unlink; dpdlock
   732                                  ;	sys	fork
   733                                  ;		br daemon
   734                                  ;	sys	fork
   735                                  ;		br dirass
   736                                  ;	sys	fork
   737                                  ;		br dds
   738                                  ;	movb	$'x,zero+8.
   739                                  ;	jsr	pc,wtmprec
   740                                  ;	mov	$itab,r1
   741                                  ;	br	1f
   742                                  ;
   743                                  ;daemon:
   744                                  ;	sys	exec; etcdpd; etcdpdp
   745                                  ;	sys	exit
   746                                  ;
   747                                  ;dirass:
   748                                  ;	sys	chdir; usrmel
   749                                  ;	sys	exec; melda; meldap
   750                                  ;	sys	exit
   751                                  ;
   752                                  ;dds:
   753                                  ;	sys	exec; usrdd; usrddp
   754                                  ;	sys	exit
   755                                  ;
   756                                  ;/ create shell processes
   757                                  ;
   758                                  ;1:
   759                                  ;	mov	(r1)+,r0
   760                                  ;	beq	pwait
   761                                  ;	movb	r0,ttyx+8
   762                                  ;	jsr	pc,dfork
   763                                  ;	mov	r0,(r1)+
   764                                  ;	br	1b
   765                                  ;
   766                                  ;/ wait for process to die
   767                                  ;
   768                                  ;pwait:
   769                                  ;	sys	wait
   770                                  ;	mov	$itab,r1
   771                                  ;
   772                                  ;/ search for process id
   773                                  ;
   774                                  ;2:
   775                                  ;	tst	(r1)+
   776                                  ;	beq	pwait
   777                                  ;	cmp	r0,(r1)+
   778                                  ;	bne	2b
   779                                  ;
   780                                  ;/ take name out of utmp
   781                                  ;
   782                                  ;	sub	$4,r1
   783                                  ;	mov	r1,-(sp)
   784                                  ;	mov	(r1),r1
   785                                  ;	sub	$'0,r1
   786                                  ;	cmp	r1,$'a-'0
   787                                  ;	blo	2f
   788                                  ;	sub	$'a-'0-10.,r1	/ map a-z into 10. on
   789                                  ;2:
   790                                  ;	asl	r1
   791                                  ;	asl	r1
   792                                  ;	asl	r1
   793                                  ;	asl	r1
   794                                  ;	mov	r1,0f
   795                                  ;	mov	$zero,r1
   796                                  ;2:
   797                                  ;	clr	(r1)+
   798                                  ;	cmp	r1,$zero+16.
   799                                  ;	blo	2b
   800                                  ;	sys	open; utmp; 1
   801                                  ;	bes	2f
   802                                  ;	mov	r0,r1
   803                                  ;	sys	seek; 0:..; 0
   804                                  ;	mov	r1,r0
   805                                  ;	sys	write; zero; 16.
   806                                  ;	mov	r1,r0
   807                                  ;	sys	close
   808                                  ;
   809                                  ;/ re-create user process
   810                                  ;
   811                                  ;2:
   812                                  ;	mov	(sp)+,r1
   813                                  ;	mov	(r1)+,r0
   814                                  ;	movb	r0,ttyx+8
   815                                  ;	movb	r0,zero+8.
   816                                  ;	jsr	pc,wtmprec
   817                                  ;	jsr	pc,dfork
   818                                  ;	mov	r0,(r1)+
   819                                  ;	br	pwait
   820                                  ;
   821                                  ;dfork:
   822                                  ;	sys	fork
   823                                  ;		br 1f
   824                                  ;	bes	dfork
   825                                  ;	rts	pc
   826                                  ;1:
   827                                  ;	sys	quit; 0
   828                                  ;	sys	intr; 0
   829                                  ;	sys	chown; ttyx; 0
   830                                  ;	sys	chmod; ttyx; 15
   831                                  ;	sys	open; ttyx; 0
   832                                  ;	bes	help1
   833                                  ;	sys	open; ttyx; 1
   834                                  ;	bes	help1
   835                                  ;	sys	exec; getty; gettyp
   836                                  ;	sys	exit			/ HELP!
   837                                  ;
   838                                  ;help1:
   839                                  ;	jmp	help
   840                                  ;
   841                                  ;wtmprec:
   842                                  ;	mov	r1,-(sp)
   843                                  ;	sys	time
   844                                  ;	mov	r0,zero+10.
   845                                  ;	mov	r1,zero+12.
   846                                  ;	sys	open; wtmp; 1
   847                                  ;	bes	2f
   848                                  ;	mov	r0,r2
   849                                  ;	sys	seek; 0; 2
   850                                  ;	mov	r2,r0
   851                                  ;	sys	write; zero; 16.
   852                                  ;	mov	r2,r0
   853                                  ;	sys	close
   854                                  ;2:
   855                                  ;	mov	(sp)+,r1
   856                                  ;	rts	pc
   857                                  ;
   858                                  ;etcdpdp:
   859                                  ;	etcdpd; 0
   860                                  ;meldap:
   861                                  ;	melda; 0
   862                                  ;usrddp:
   863                                  ;	usrdd; 0
   864                                  ;usrdd:	</usr/demo/dds\0>
   865                                  ;melda:	</usr/mel/da\0>
   866                                  ;usrmel:</usr/mel\0>
   867                                  ;rk1:	</dev/rk1\0>
   868                                  ;rk2:	</dev/rk2\0>
   869                                  ;rk3:	</dev/rk3\0>
   870                                  ;usr:	</usr\0>
   871                                  ;ssys:	</sys\0>
   872                                  ;crp:	</crp\0>
   873                                  ;ctty:	</dev/tty\0>
   874                                  ;shell:	</bin/sh\0>
   875                                  ;shellm:<-\0>
   876                                  ;dpdlock:
   877                                  ;	</usr/dpd/lock\0>
   878                                  ;etcdpd:
   879                                  ;	</etc/dpd\0>
   880                                  ;tapx:	</dev/tapx\0>
   881                                  ;utmp:	</tmp/utmp\0>
   882                                  ;wtmp:	</tmp/wtmp\0>
   883                                  ;ttyx:	</dev/ttyx\0>
   884                                  ;getty:	</etc/getty\0>
   885                                  ;	.even
   886                                  ;
   887                                  ;shellp:shellm
   888                                  ;	0
   889                                  ;gettyp:getty
   890                                  ;	0
   891                                  ;itab:
   892                                  ;	'0; ..
   893                                  ;	'1; ..
   894                                  ;	'2; ..
   895                                  ;	'3; ..
   896                                  ;	'4; ..
   897                                  ;	'5; ..
   898                                  ;	'6; ..
   899                                  ;	'7; ..
   900                                  ;	'8; ..
   901                                  ;	'a; ..
   902                                  ;	'b; ..
   903                                  ;	 0
   904                                  ;
   905                                  ;	.bss
   906                                  ;offset:.=.+2
   907                                  ;zero:	.=.+8.; .=.+6; .=.+2.
