1 ; **************************************************************************** 2 ; init386.s (init8.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: 20/03/2022 ] 7 ; 8 ; Derived from UNIX Operating System (v1.0 for PDP-11) 9 ; (Original) Source Code by Ken Thompson (1971-1972) 10 ; 11 ; (Section E.12) 12 ; **************************************************************************** 13 ; init4.s (17/11/2015) - Retro UNIX 386 v1 & v1.1 14 ;;init5.s (24/01/2022) - Retro UNIX 386 v1.2 15 ; init6.s (24/01/2022-02/03/2022) - Retro UNIX 386 v1 & v1.1 16 ; init7.s (09/02/2022-19/03/2022) - Retro UNIX 386 v1.2 & v1.1 (& v1.0) 17 ;;init8.s (14/02/2022-20/03/2022) - Retro UNIX 386 v1.2 18 ; init9.s (20/03/2022) - Retro UNIX 386 v1 & v1.1 19 ; 20 ; (Retro UNIX 386 v1 - init386.s, NASM 2.11) 21 ; Derived from INIT09.ASM (17/01/2014, Retro UNIX 8086 v1, MASM 6.11) 22 ; Derived from 'init.s' file of original UNIX v1 23 ; INIT09.ASM, 17/01/2014 24 25 ; 19/03/2022 26 ; 02/03/2022 27 ; 25/02/2022 28 ; 14/02/2022 (init8.s) - Retro UNIX 386 v1.2 29 ; 09/02/2022 (init7.s) - Retro UNIX 386 v1.2 30 ; 24/01/2022 (init6.s) - Retro UNIX 386 v1 & v1.1 31 ; 24/01/2022 (init5.s) - Retro UNIX 386 v1 & v1.1 32 ; 17/11/2015 (init4.s) 33 ; 23/10/2015 (init3.s) 34 ; 14/10/2015 (init2.s) 35 ; 17/09/2015 36 ; 03/09/2015 37 ; 27/08/2015 38 ; 13/08/2015 39 ; 07/08/2015 40 ; 30/06/2015 41 ; 14/07/2013 42 43 ; 12/01/2022 (Retro UNIX 386 v1.2) 44 ; 45 ; UNIX v1 system calls 46 _rele equ 0 47 _exit equ 1 48 _fork equ 2 49 _read equ 3 50 _write equ 4 51 _open equ 5 52 _close equ 6 53 _wait equ 7 54 _creat equ 8 55 _link equ 9 56 _unlink equ 10 57 _exec equ 11 58 _chdir equ 12 59 _time equ 13 60 _mkdir equ 14 61 _chmod equ 15 62 _chown equ 16 63 _break equ 17 64 _stat equ 18 65 _seek equ 19 66 _tell equ 20 67 _mount equ 21 68 _umount equ 22 69 _setuid equ 23 70 _getuid equ 24 71 _stime equ 25 72 _quit equ 26 73 _intr equ 27 74 _fstat equ 28 75 _emt equ 29 76 _mdate equ 30 77 _stty equ 31 78 _gtty equ 32 79 _ilgins equ 33 80 _sleep equ 34 ; Retro UNIX 8086 v1 feature only ! 81 _msg equ 35 ; Retro UNIX 386 v1 feature only ! 82 _geterr equ 36 ; Retro UNIX 386 v1 feature only ! 83 ; 12/01/2022 - Retro UNIX 386 v1.2 84 ; Retro UNIX 386 v2 system calls 85 _setgid equ 37 86 _getgid equ 38 87 _sysver equ 39 ; (get) Retro Unix 386 version 88 89 ;;; 90 ESCKey equ 1Bh 91 EnterKey equ 0Dh 92 93 %macro sys 1-4 94 ; 03/09/2015 95 ; 13/04/2015 96 ; Retro UNIX 386 v1 system call. 97 %if %0 >= 2 98 mov ebx, %2 99 %if %0 >= 3 100 mov ecx, %3 101 %if %0 = 4 102 mov edx, %4 103 %endif 104 %endif 105 %endif 106 mov eax, %1 107 int 30h 108 %endmacro 109 110 ; Retro UNIX 386 v1 system call format: 111 ; sys systemcall (eax) , , 112 113 [BITS 32] ; We need 32-bit intructions for protected mode 114 115 [ORG 0] 116 117 START_CODE: 118 sys _intr, 0 ; disable time-out function 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 00000000 BB00000000 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000005 B81B000000 <1> mov eax, %1 107 0000000A CD30 <1> int 30h 119 sys _quit, 0 ; disable quit (ctrl+brk) signal 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 0000000C BB00000000 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000011 B81A000000 <1> mov eax, %1 107 00000016 CD30 <1> int 30h 120 121 sys _open, ctty, 0 ; open tty0 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 00000018 BB[54030000] <1> mov ebx, %2 99 <1> %if %0 >= 3 100 0000001D B900000000 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000022 B805000000 <1> mov eax, %1 107 00000027 CD30 <1> int 30h 122 00000029 7259 jc short error 123 124 sys _open, ctty, 1 ; for read and write 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 0000002B BB[54030000] <1> mov ebx, %2 99 <1> %if %0 >= 3 100 00000030 B901000000 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000035 B805000000 <1> mov eax, %1 107 0000003A CD30 <1> int 30h 125 0000003C 7246 jc short error 126 127 sys _write, 1, msg_te, sizeof_mte 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 0000003E BB01000000 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 00000043 B9[DC030000] <1> mov ecx, %3 101 <1> %if %0 = 4 102 00000048 BA55000000 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 0000004D B804000000 <1> mov eax, %1 107 00000052 CD30 <1> int 30h 128 00000054 722E jc short error 129 i0: 130 sys _read, 0, tchar, 1 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 00000056 BB00000000 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 0000005B B9[52030000] <1> mov ecx, %3 101 <1> %if %0 = 4 102 00000060 BA01000000 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000065 B803000000 <1> mov eax, %1 107 0000006A CD30 <1> int 30h 131 0000006C 7216 jc short error 132 133 ;sys _close, 0 ; close input file/tty 134 ;jc short error 135 ;sys _close, 1 ; close output file/tty 136 ;jc short error 137 138 0000006E A0[52030000] mov al, [tchar] 139 140 ; 25/02/2022 141 ;cmp al, EnterKey 142 ;je short multiuser 143 144 00000073 3C1B cmp al, ESCKey 145 00000075 7433 je short singleuser 146 147 ;jmp short i0 148 149 ; 25/02/2022 150 ; (ALT+127 will ensure multiuser login without tty8 and tty9) 151 ;cmp al, 7Fh ; ALT+127 152 ;je short multiuser_x 153 154 ; 25/02/2022 155 00000077 3C0D cmp al, EnterKey 156 00000079 747C je short multiuser 157 158 ;jmp short i0 159 160 ; 20/03/2022 161 ; 25/02/2022 162 0000007B 3C7F cmp al, 7Fh ; ALT+127 163 0000007D 75D7 jne short i0 164 0000007F E9AC000000 jmp multiuser_x 165 166 error: 167 sys _msg, error_msg, 255, 0Ch 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 00000084 BB[51040000] <1> mov ebx, %2 99 <1> %if %0 >= 3 100 00000089 B9FF000000 <1> mov ecx, %3 101 <1> %if %0 = 4 102 0000008E BA0C000000 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000093 B823000000 <1> mov eax, %1 107 00000098 CD30 <1> int 30h 168 ; error message with red color (max. 255 chars) 169 exit: 170 sys _exit 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 0000009A B801000000 <1> mov eax, %1 107 0000009F CD30 <1> int 30h 171 172 haltsys: 173 ;hlt 174 ; 17/09/2015 175 000000A1 90 nop 176 000000A2 90 nop 177 000000A3 90 nop 178 000000A4 90 nop 179 000000A5 90 nop 180 000000A6 90 nop 181 000000A7 90 nop 182 000000A8 EBF7 jmp short haltsys 183 184 singleuser: 185 i1: 186 help: 187 sys _close, 0 ; close input file/tty 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 000000AA BB00000000 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 000000AF B806000000 <1> mov eax, %1 107 000000B4 CD30 <1> int 30h 188 ;jc short error 189 sys _close, 1 ; close output file/tty 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 000000B6 BB01000000 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 000000BB B806000000 <1> mov eax, %1 107 000000C0 CD30 <1> int 30h 190 ;jc short error 191 sys _open, ctty, 0 ; open control tty 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 000000C2 BB[54030000] <1> mov ebx, %2 99 <1> %if %0 >= 3 100 000000C7 B900000000 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 000000CC B805000000 <1> mov eax, %1 107 000000D1 CD30 <1> int 30h 192 ;jc short error 193 sys _open, ctty, 1 ; for read an write 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 000000D3 BB[54030000] <1> mov ebx, %2 99 <1> %if %0 >= 3 100 000000D8 B901000000 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 000000DD B805000000 <1> mov eax, %1 107 000000E2 CD30 <1> int 30h 194 ;jc short error 195 ; 196 sys _exec, shell, shellp 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 000000E4 BB[5E030000] <1> mov ebx, %2 99 <1> %if %0 >= 3 100 000000E9 B9[A2030000] <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 000000EE B80B000000 <1> mov eax, %1 107 000000F3 CD30 <1> int 30h 197 ; 198 000000F5 EBB3 jmp short i1 199 200 multiuser: 201 ; 20/03/2022 202 000000F7 BF[D2030000] mov edi, itabs 203 000000FC 31DB xor ebx, ebx 204 000000FE B901090000 mov ecx, 0901h ; return tty8 serial port status 205 sys _gtty 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000103 B820000000 <1> mov eax, %1 107 00000108 CD30 <1> int 30h 206 0000010A 7206 jc short multiuser_e ; device not responding ! 207 0000010C C60738 mov byte [edi], '8' 208 0000010F 83C704 add edi, 4 209 multiuser_e: 210 00000112 29DB sub ebx, ebx 211 00000114 B9010A0000 mov ecx, 0A01h ; return tty9 serial port status 212 sys _gtty 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000119 B820000000 <1> mov eax, %1 107 0000011E CD30 <1> int 30h 213 00000120 7205 jc short multiuser_s ; device not responding ! 214 00000122 C60739 mov byte [edi], '9' 215 00000125 EB1F jmp short multiuser_t 216 217 multiuser_s: 218 00000127 803D[D2030000]00 cmp byte [itabs], 0 219 0000012E 7716 ja short multiuser_t 220 221 multiuser_x: ; 25/02/2022 222 ;mov byte [itabs], 0 ; (disable serial port login) 223 224 ; 20/03/2022 225 ; (print serial port login disabled message) 226 sys _write, 1, td_msg, td_msg_size 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 00000130 BB01000000 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 00000135 B9[7E040000] <1> mov ecx, %3 101 <1> %if %0 = 4 102 0000013A BA3D000000 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 0000013F B804000000 <1> mov eax, %1 107 00000144 CD30 <1> int 30h 227 228 ;multiuser: 229 multiuser_t: ; 20/03/2022 230 sys _close, 0 ; close input file/tty 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 00000146 BB00000000 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 0000014B B806000000 <1> mov eax, %1 107 00000150 CD30 <1> int 30h 231 ;jc short error 232 sys _close, 1 ; close output file/tty 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 00000152 BB01000000 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000157 B806000000 <1> mov eax, %1 107 0000015C CD30 <1> int 30h 233 ;jc short error 234 235 sys _mount, fd1, usr 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 0000015E BB[6E030000] <1> mov ebx, %2 99 <1> %if %0 >= 3 100 00000163 B9[68030000] <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000168 B815000000 <1> mov eax, %1 107 0000016D CD30 <1> int 30h 236 ; root directory on mounted fd1 237 ; disk is /usr 238 ; 23/01/2022 239 ; truncate /tmp/utmp 240 sys _creat, utmp, 1A4h ; Retro UNIX 386 1.2 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 0000016F BB[78030000] <1> mov ebx, %2 99 <1> %if %0 >= 3 100 00000174 B9A4010000 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000179 B808000000 <1> mov eax, %1 107 0000017E CD30 <1> int 30h 241 ; (runix v2 fs inode flags) 242 ;sys _creat, utmp, 14 ; Retro UNIX 386 v1.1 243 ;jc short error ; (unix v1 fs inode flags) 244 245 sys _close, eax ; close it 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 00000180 89C3 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000182 B806000000 <1> mov eax, %1 107 00000187 CD30 <1> int 30h 246 247 ; 23/01/2022 248 00000189 C605[C4040000]78 mov byte [zero+8], 'x' 249 ;mov byte [zero+8], 0 ; put identifier 250 ; in output buffer 251 252 00000190 E85B010000 call wtmprec ; go to (call) write acting info 253 254 ; 23/10/2015 255 ; 256 ;; 10/12/2013 257 ;; 'Enable Multi Tasking' (Time-Out) 258 ;; system call (Retro UNIX 8086 v1 feature only !) 259 sys _emt, 1 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 00000195 BB01000000 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 0000019A B81D000000 <1> mov eax, %1 107 0000019F CD30 <1> int 30h 260 ;; 261 262 000001A1 BE[B2030000] mov esi, itab ; address of table to ESI 263 264 ; create shell processes 265 i2: 266 000001A6 66AD lodsw ; 'x', x=0, 1... to AX 267 000001A8 6621C0 and ax, ax 268 000001AB 7412 jz short pwait ; branch if table end 269 270 000001AD A2[94030000] mov [ttyx+8], al ; put symbol in ttyx 271 ; 02/03/2022 272 ;mov ecx, eax ; 18/02/2022 273 000001B2 89F7 mov edi, esi 274 000001B4 E8A1000000 call dfork ; go to make new init for this ttyx 275 ;mov eax, ecx ; 18/02/2022 276 000001B9 66AB stosw ; save child id in word offer 277 ; ; '0', '1',...etc. 278 000001BB 89FE mov esi, edi 279 000001BD EBE7 jmp short i2 ; set up next child 280 281 ; wait for process to die 282 pwait: 283 ;sys _write, 1, beep, 1 ; 10/12/2013 284 ; 285 sys _wait ; wait for user to terminate process 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 000001BF B807000000 <1> mov eax, %1 107 000001C4 CD30 <1> int 30h 286 ; 02/03/2022 287 000001C6 7305 jnc short i8 ; (eax = process ID of the child) 288 ; ERROR ! there is not a child process to wait ! 289 ; (This may be only viable option for now!) - 02/03/2022 - 290 000001C8 E9B7FEFFFF jmp error ; (print error message then terminate) 291 i8: 292 000001CD BE[B2030000] mov esi, itab ; initialize for search 293 ; 02/03/2022 294 ;mov dx, ax 295 ; 24/01/2022 296 000001D2 89C2 mov edx, eax ; (process ID of the child) 297 298 ; search for process id 299 i3: 300 000001D4 66AD lodsw ; bump ESI to child id location 301 000001D6 6609C0 or ax, ax 302 000001D9 74E4 jz short pwait ; ? something silly 303 304 000001DB 66AD lodsw 305 ; 24/01/2022 306 000001DD 39C2 cmp edx, eax 307 ;cmp dx, ax ; which process has terminated 308 000001DF 75F3 jne short i3 ; not this one 309 310 ; take name out of utmp 311 ;mov ecx, 4 312 ; 24/01/2022 313 000001E1 31C9 xor ecx, ecx 314 000001E3 B104 mov cl, 4 315 ;sub esi, 4 ; process is found, point x to 'x' 316 ; for it 317 000001E5 29CE sub esi, ecx ; 4 318 ;push esi ; save address on stack 319 000001E7 668B06 mov ax, [esi] ; move 'x' to AX 320 ; 24/01/2022 321 000001EA 2C30 sub al, '0' 322 ;sub ax, '0' ; remove zone bits from character 323 ;;shl ax, 4 ; generate proper offset for seek 324 000001EC 66D3E0 shl ax, cl ; 4 325 ;movzx edx, ax 326 ; 24/01/2022 327 000001EF 89C2 mov edx, eax 328 000001F1 BF[BC040000] mov edi, zero 329 000001F6 31C0 xor eax, eax ; 0 ; clear 330 ;mov ecx, 4 ; output buffer 331 000001F8 F3AB rep stosd 332 sys _open, utmp, 1 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 000001FA BB[78030000] <1> mov ebx, %2 99 <1> %if %0 >= 3 100 000001FF B901000000 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000204 B805000000 <1> mov eax, %1 107 00000209 CD30 <1> int 30h 333 ; open file for writing 334 0000020B 722E jc short i4 ; if can't open, create user anyway 335 ;movzx edi, ax ; save file desc 336 ; 24/01/2022 337 0000020D 89C7 mov edi, eax ; save file descriptor 338 sys _seek, eax, edx, 0 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 0000020F 89C3 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 00000211 89D1 <1> mov ecx, %3 101 <1> %if %0 = 4 102 00000213 BA00000000 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000218 B813000000 <1> mov eax, %1 107 0000021D CD30 <1> int 30h 339 ; move to proper pointer position 340 sys _write, edi, zero, 16 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 0000021F 89FB <1> mov ebx, %2 99 <1> %if %0 >= 3 100 00000221 B9[BC040000] <1> mov ecx, %3 101 <1> %if %0 = 4 102 00000226 BA10000000 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 0000022B B804000000 <1> mov eax, %1 107 00000230 CD30 <1> int 30h 341 ; zero this position in 342 sys _close, edi 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 00000232 89FB <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000234 B806000000 <1> mov eax, %1 107 00000239 CD30 <1> int 30h 343 ; close file 344 345 ; re-create user process 346 347 ; 19/03/2022 348 ; 02/03/2022 349 ;sub esi, 4 350 i4: 351 ;pop esi ; restore 'x' to ESI 352 0000023B 66AD lodsw ; move it to AX 353 0000023D 89F7 mov edi, esi 354 0000023F A2[94030000] mov [ttyx+8], al ; get correct ttyx 355 00000244 A2[C4040000] mov [zero+8], al 356 ; move identifier to output buffer 357 00000249 E8A2000000 call wtmprec ; go to write accting into 358 0000024E E807000000 call dfork ; fork 359 00000253 66AB stosw ; save id of child 360 ; 02/03/2022 361 ;; 25/02/2022 362 ;mov edx, eax ; save id of child 363 ; 364 00000255 E965FFFFFF jmp pwait ; go to wait for next process end 365 366 dfork: 367 0000025A BB[69020000] mov ebx, i5 ; return address for new process 368 sys _fork 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 0000025F B802000000 <1> mov eax, %1 107 00000264 CD30 <1> int 30h 369 00000266 72F2 jc short dfork ; try again 370 ; 25/02/2022 371 ; eax = process number of the child 372 ; Note: the child will return (from sysfork) 373 ; with process number of its parent 374 00000268 C3 retn 375 376 i5: ; to new copy of init 377 ;sys _quit, 0 ; disable quit (ctrl+brk) signal 378 ;sys _intr, 0 ; disable time-out function 379 ;sys _chown, ttyx, 0 380 ;;sys _chmod; ttyx, 15 381 ;sys _chmod; ttyx, 13 ; 23/01/2022 382 o0: 383 00000269 31DB xor ebx, ebx 384 ;xor ch, ch 385 ;mov cl, [ttyx+8] 386 0000026B 0FB60D[94030000] movzx ecx, byte [ttyx+8] 387 00000272 80E930 sub cl, '0' 388 ; 17/01/2014 389 ; 07/12/2013 390 ; set console tty for current process 391 ;mov dx, 0FF00h 392 ;mov dh, 0FFh ; do not set cursor position 393 ; do not set serial port parameters 394 ;mov edx, 0FF00h 395 ; 18/02/2022 396 00000275 29D2 sub edx, edx 397 00000277 FECE dec dh 398 ; edx = 0FF00h 399 sys _stty 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000279 B81F000000 <1> mov eax, %1 107 0000027E CD30 <1> int 30h 400 ;jc short terminate 401 ;; 19/03/2022 402 00000280 724D jc short o4 403 404 ;; temporary test code - 20/03/2022 405 ;jnc short o1 ; temporary - 20/03/2022 406 ;add cl, '0' 407 ;mov [termno], cl 408 ;sys _msg, tempor_msg, 255, 0Fh 409 ; 410 ;jmp short o4 411 o1: 412 ; 16/11/2015 413 sys _open, ttyx, 0 ; open this ttyx for reading 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 00000282 BB[8C030000] <1> mov ebx, %2 99 <1> %if %0 >= 3 100 00000287 B900000000 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 0000028C B805000000 <1> mov eax, %1 107 00000291 CD30 <1> int 30h 414 ; 19/03/2022 415 ;jnc short o2 416 ;call wait_for_terminal 417 ;jmp short o1 418 ; 17/11/2015 419 ;;jc short terminate 420 ; 19/03/2022 421 00000293 723A jc short o4 422 ; 18/02/2022 423 ;;;jc short help1 424 o2: 425 ; 16/11/2015 426 sys _open, ttyx, 1 ; open this ttyx for writing 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 00000295 BB[8C030000] <1> mov ebx, %2 99 <1> %if %0 >= 3 100 0000029A B901000000 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 0000029F B805000000 <1> mov eax, %1 107 000002A4 CD30 <1> int 30h 427 ; 19/03/2022 428 ;jnc short o3 429 ;call wait_for_terminal 430 ;jmp short o2 431 ; 17/11/2015 432 ;;jc short terminate 433 ; 19/03/2022 434 000002A6 7227 jc short o4 435 ; 18/02/2022 436 ;;;jc short help1 437 o3: 438 sys _exec, getty, gettyp ; getty types and 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 000002A8 BB[96030000] <1> mov ebx, %2 99 <1> %if %0 >= 3 100 000002AD B9[AA030000] <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 000002B2 B80B000000 <1> mov eax, %1 107 000002B7 CD30 <1> int 30h 439 ; executes login which logs user 440 ; in and executes sh- 441 ; 14/10/2015 442 sys _msg, getty_error_msg, 255, 0Ch 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 000002B9 BB[67040000] <1> mov ebx, %2 99 <1> %if %0 >= 3 100 000002BE B9FF000000 <1> mov ecx, %3 101 <1> %if %0 = 4 102 000002C3 BA0C000000 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 000002C8 B823000000 <1> mov eax, %1 107 000002CD CD30 <1> int 30h 443 ; error msg with red color 444 445 ;; temporary test code - 20/03/2022 446 ;mov al, '?' 447 ;jmp terminate2 448 449 o4: 450 ; 19/03/2022 451 ;movzx ecx, byte [ttyx+8] 452 000002CF 8A0D[94030000] mov cl, [ttyx+8] 453 o5: 454 000002D5 80E930 sub cl, '0' 455 000002D8 C0E102 shl cl, 2 ; * 4 456 000002DB 31C0 xor eax, eax 457 000002DD C681[B2030000]00 mov byte [itab+ecx], 0 458 459 ;; temporary test code - 20/03/2022 460 ;terminate: 461 ; mov al, [ttyx+8] 462 ;terminate2: 463 ; mov [termno], al 464 ; sys _msg, tempor_msg, 255, 0Ch 465 466 terminate: 467 sys _exit ; HELP! 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 000002E4 B801000000 <1> mov eax, %1 107 000002E9 CD30 <1> int 30h 468 ;help1: 469 000002EB E9BAFDFFFF jmp help 470 471 ;; temporary test code - 20/03/2022 472 ;tempor_msg: db 0Dh, 0Ah 473 ; db 'Error on tty' 474 ; termno: db '!' 475 ; db 20h, 0Dh, 0ah, 0 476 477 ;wait_for_terminal: 478 ; ; 19/03/2022 479 ; ; 16/11/2015 480 ; ; 24/10/2015 481 ; mov cl, [ttyx+8] 482 ; ;sub cl, '0' 483 ; ;cmp cl, 8 484 ; cmp cl, '8' 485 ; jb short sysexit 486 ; sys _sleep 487 ; retn 488 ;sysexit: 489 ; pop eax ; return address 490 ; ;jmp short terminate 491 ; ; 19/03/2022 492 ; jmp short o5 493 494 wtmprec: 495 ; 18/02/2022 496 ; 24/01/2022 497 ; 23/10/2015 (wtmp_err) 498 499 sys _time ; get time 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 000002F0 B80D000000 <1> mov eax, %1 107 000002F5 CD30 <1> int 30h 500 000002F7 A3[C6040000] mov [zero+10], eax ; move to output buffer 501 502 000002FC 803D[CC040000]00 cmp byte [wtmp_err], 0 503 00000303 7744 ja short i6 ; 18/02/2022 504 505 sys _open, wtmp, 1 ; open accounting file 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 00000305 BB[82030000] <1> mov ebx, %2 99 <1> %if %0 >= 3 100 0000030A B901000000 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 0000030F B805000000 <1> mov eax, %1 107 00000314 CD30 <1> int 30h 506 00000316 7232 jc short i7 ; 18/02/2022 507 ; 24/01/2022 508 ;jc short i6 509 510 00000318 89C6 mov esi, eax ; save file descriptor 511 512 sys _seek, eax, 0, 2 ; move pointer to end of file 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 0000031A 89C3 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 0000031C B900000000 <1> mov ecx, %3 101 <1> %if %0 = 4 102 00000321 BA02000000 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000326 B813000000 <1> mov eax, %1 107 0000032B CD30 <1> int 30h 513 ;;push esi ; save file descriptor 514 ;jc short i7 515 516 sys _write, esi, zero, 16 ; write accting info 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 0000032D 89F3 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 0000032F B9[BC040000] <1> mov ecx, %3 101 <1> %if %0 = 4 102 00000334 BA10000000 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000339 B804000000 <1> mov eax, %1 107 0000033E CD30 <1> int 30h 517 ;;pop ebx ; restore file descriptor 518 ;jc short i7 519 520 sys _close, esi ; close file 94 <1> 95 <1> 96 <1> 97 <1> %if %0 >= 2 98 00000340 89F3 <1> mov ebx, %2 99 <1> %if %0 >= 3 100 <1> mov ecx, %3 101 <1> %if %0 = 4 102 <1> mov edx, %4 103 <1> %endif 104 <1> %endif 105 <1> %endif 106 00000342 B806000000 <1> mov eax, %1 107 00000347 CD30 <1> int 30h 521 i6: 522 00000349 C3 retn 523 i7: 524 0000034A FE05[CC040000] inc byte [wtmp_err] ; 23/10/2015 525 00000350 C3 retn 526 527 ; 23/01/2022 528 ;here: 529 ; hlt ; General Protection Fault ! 17/09/2015 530 ; ;jmp short here 531 ; jmp haltsys 532 533 00000351 90 align 2 534 00000352 00 tchar: db 0 535 00000353 90 align 2 536 00000354 2F6465762F74747900 ctty: db "/dev/tty", 0 537 0000035D 90 align 2 538 0000035E 2F62696E2F736800 shell: db "/bin/sh", 0 539 00000366 2D00 shellm: db "-", 0 540 ;align 2 541 00000368 2F75737200 usr: db "/usr",0 542 0000036D 90 align 2 543 0000036E 2F6465762F66643100 fd1: db "/dev/fd1", 0 544 ; 545 00000377 90 align 2 546 00000378 2F746D702F75746D70- utmp: db "/tmp/utmp", 0 546 00000381 00 547 00000382 2F746D702F77746D70- wtmp: db "/tmp/wtmp", 0 547 0000038B 00 548 0000038C 2F6465762F74747978- ttyx: db "/dev/ttyx", 0 548 00000395 00 549 00000396 2F6574632F67657474- getty: db "/etc/getty",0 549 0000039F 7900 550 551 000003A1 90 align 2 552 ; 27/08/2015 (dw -> dd) 553 000003A2 [66030000] shellp: dd shellm 554 000003A6 00000000 dd 0 555 000003AA [96030000] gettyp: dd getty 556 000003AE 00000000 dd 0 557 itab: 558 000003B2 30000000 db '0',0, 0,0 559 000003B6 31000000 db '1',0, 0,0 560 000003BA 32000000 db '2',0, 0,0 561 000003BE 33000000 db '3',0, 0,0 562 000003C2 34000000 db '4',0, 0,0 563 000003C6 35000000 db '5',0, 0,0 564 000003CA 36000000 db '6',0, 0,0 565 000003CE 37000000 db '7',0, 0,0 566 ;itabs: ; 25/02/2022 567 ; serial ports (COM1, COM2) 568 ;db '8',0, 0,0 569 ;db '9',0, 0,0 570 ;dw 0 571 itabs: 572 ; 20/03/2022 573 000003D2 00000000 dd 0 574 000003D6 00000000 dd 0 575 000003DA 0000 dw 0 576 577 ;----------------------------------------------------------------- 578 ; messages 579 ;----------------------------------------------------------------- 580 581 msg_te: 582 000003DC 0D0A db 0Dh, 0Ah 583 000003DE 5479706520454E5445- db 'Type ENTER to start in multi user mode', 0Dh, 0Ah 583 000003E7 5220746F2073746172- 583 000003F0 7420696E206D756C74- 583 000003F9 692075736572206D6F- 583 00000402 64650D0A 584 00000406 6F7220747970652045- db 'or type ESC to start in single user mode.' 584 0000040F 534320746F20737461- 584 00000418 727420696E2073696E- 584 00000421 676C65207573657220- 584 0000042A 6D6F64652E 585 0000042F 0D0A db 0Dh, 0Ah 586 sizeof_mte equ $ - msg_te 587 00000431 00 db 0 588 copy_right_msg: 589 00000432 286329204572646F67- db '(c) Erdogan TAN - 20/03/2022' 589 0000043B 616E2054414E202D20- 589 00000444 32302F30332F323032- 589 0000044D 32 590 0000044E 0D0A00 db 0Dh, 0Ah, 0 591 error_msg: 592 00000451 0D0A07 db 0Dh, 0Ah, 07h 593 00000454 2F6574632F696E6974- db '/etc/init error ! ' 593 0000045D 206572726F72202120 594 00000466 00 db 0 595 596 getty_error_msg: 597 ; 14/10/2015 598 00000467 0D0A07 db 0Dh, 0Ah, 07h 599 0000046A 2F6574632F67657474- db '/etc/getty error ! ' 599 00000473 79206572726F722021- 599 0000047C 20 600 0000047D 00 db 0 601 602 ; 20/03/2022 603 0000047E 0D0A td_msg: db 0Dh, 0Ah 604 00000480 53657269616C20506F- db 'Serial Port (Terminal) login feature has been disabled..' 604 00000489 727420285465726D69- 604 00000492 6E616C29206C6F6769- 604 0000049B 6E2066656174757265- 604 000004A4 20686173206265656E- 604 000004AD 2064697361626C6564- 604 000004B6 2E2E 605 000004B8 200D0A00 db 20h, 0Dh, 0Ah, 0 606 607 td_msg_size equ ($ - td_msg) - 1 608 609 ; 23/10/2015 610 align 2 611 zero: 612 000004BC 00 times 8 db 0 613 000004C4 00 times 6 db 0 614 000004CA 00 times 2 db 0 615 616 wtmp_err: 617 000004CC 00 db 0 618 619 ; 23/01/2022 620 621 ;----------------------------------------------------------------- 622 ; Original UNIX v1 - /etc/init source code (init.s) 623 ; in PDP-11 (unix) assembly language 624 ;----------------------------------------------------------------- 625 626 ;/ init -- process control initialization 627 ; 628 ;mount = 21. 629 ; 630 ; sys intr; 0 / turn off interrupts 631 ; sys quit; 0 632 ; cmp csw,$73700 / single user? 633 ; bne 1f / no 634 ;help: 635 ; clr r0 / yes 636 ; sys close / close current read 637 ; mov $1,r0 / and write 638 ; sys close / files 639 ; sys open; ctty; 0 / open control tty 640 ; sys open; ctty; 1 / for read and write 641 ; sys exec; shell; shellp / execute shell 642 ; br help / keep trying 643 ;1: 644 ; mov $'0,r1 / prepare to change 645 ;1 : 646 ; movb r1,tapx+8 / mode of dec tape drive x, where 647 ; sys chmod; tapx; 17 / x=0 to 7, to read/write by owner or 648 ; inc r1 / non-owner mode 649 ; cmp r1,$'8 / finished? 650 ; blo 1b / no 651 ; sys mount; rk0; usr / yes, root file on mounted rko5 652 ; / disk ls /usr 653 ; sys creat; utmp; 16 / truncate /tmp/utmp 654 ; sys close / close it 655 ; movb $'x,zero+8. / put identifier in output buffer 656 ; jsr pc,wtmprec / go to write accting info 657 ; mov $itab,r1 / address of table to r1 658 ; 659 ;/ create shell processes 660 ; 661 ;1: 662 ; mov (r1)+,r0 / 'x, x=0, 1... to r0 663 ; beq 1f / branch if table end 664 ; movb r0,ttyx+8 / put symbol in ttyx 665 ; jsr pc,dfork / go to make new init for this ttyx 666 ; mov r0,(r1)+ / save child id in word offer '0, '1,...etc. 667 ; br 1b / set up next child 668 ; 669 ;/ wait for process to die 670 ; 671 ;1: 672 ; sys wait / wait for user to terminate process 673 ; mov $itab,r1 / initialize for search 674 ; 675 ;/ search for process id 676 ; 677 ;2: 678 ; tst (r1)+ / bump r1 to child id location 679 ; beq 1b / ? something silly 680 ; cmp r0,(r1)+ / which process has terminated 681 ; bne 2b / not this one 682 ; 683 ;/ take name out of utmp 684 ; 685 ; sub $4, r1 / process is found, point x' to 'x 686 ; / for it 687 ; mov r1,-(sp) / save address on stack 688 ; mov (r1),r1 / move 'x to r1 689 ; sub $'0,r1 / remove zone bits from character 690 ; asl r1 / generate proper 691 ; asl r1 / offset 692 ; asl r1 / for 693 ; asl r1 / seek 694 ; mov r1,0f / move it to offset loc for seek 695 ; mov $zero,r1 696 ;2: 697 ; clr (r1)+ / ccear- 698 ; cmp r1,$zero+16. / output buffer 699 ; blo 2b / area 700 ; sys open; utmp; 1 / open file for writing 701 ; bes 2f / if can't open, create user anyway 702 ; mov r0,r1 / save file desc 703 ; sys seek; 0:..; 0 / move to proper pointer position 704 ; mov r1,r0 / not required 705 ; sys write; zero; 16. / zero this position in 706 ; mov r1,r0 / restore file descriptor 707 ; sys close / close file 708 ; 709 ;/ re-create user process 710 ; 711 ;2: 712 ; mov (sp)+,r1 / restore 'x to r1 713 ; mov (r1)+,r0 / move it to r0 714 ; movb r0,ttyx+8 / get correct ttyx 715 ; movb r0,zero+8 / move identifier to output buffer 716 ; jsr pc,wtmprec / go to write accting into 717 ; jsr pc,dfork / fork 718 ; mov r0,(r1)+ / save id of child 719 ; br 1b / go to wait for next process end 720 ; 721 ;dfork: 722 ; mov r1,r2 723 ; sub $itab+2,r2 / left over 724 ; asl r2 / from previous 725 ; asl r2 / version of code 726 ; mov r2,offset 727 ; sys fork 728 ; br 1f / to new copy of init 729 ; bes dfork / try again 730 ; rts pc / return 731 ;1 : 732 ; sys quit; 0 / new init turns off 733 ; sys intr; 0 / interrupts 734 ; sys chown; ttyx; 0 / change owner to super user 735 ; sys chmod; ttyx; 15 / changemode to read/write owner, 736 ; / write non-owner 737 ; sys open; ttyx; 0 / open this ttyx for reading 738 ; / and wait until someone calls 739 ; bes help1 / branch if trouble 740 ; sys open; ttyx; 1 / open this ttyx for writing after 741 ; / user call 742 ; bes help1 / branch if trouble 743 ; sys exec; getty; gettyp / getty types and 744 ; / executes login which logs user 745 ; / in and executes sh- 746 ; sys exit / HELP! 747 ; 748 ;help1: 749 ; jmp help / trouble 750 ; 751 ;wtmprec: 752 ; sys time / get time 753 ; mov ac,zero+10. / more to output 754 ; mov mq,zero+12. / buffer 755 ; sys open; wtmp; 1 / open accounting file 756 ; bes 2f 757 ; mov r0,r2 / save file descriptor 758 ; sys seek; 0; 2 / move pointer to end of file 759 ; mov r2,r0 / not required 760 ; sys write; zero; 16. / write accting info 761 ; mov r2,r0 / restore file descriptor 762 ; sys close / close file 763 ;2: 764 ; rts pc 765 ; 766 ;ctty: 767 ;shell: 768 ;shellm: <-\0> 769 ;tapx: 770 ;rk0: 771 ;utmp: 772 ;wtmp: 773 ;ttyx: 774 ;getty: 775 ;usr: 776 ; .even 777 ; 778 ;shellp: shellm 779 ; 0 780 ;gettyp: getty 781 ; 0 782 ;itab: 783 ; '0; .. 784 ; '1; .. 785 ; '2; .. 786 ; '3; .. 787 ; '4; .. 788 ; '5; .. 789 ; '6; .. 790 ; '7; .. 791 ; 0 792 ; 793 ;offset: .=.+2 794 ;zero: .=.+8; .=.+6; .=.+2 795 796 ; 23/01/2022 797 798 ;----------------------------------------------------------------- 799 ; Original UNIX v2 - /etc/init source code (init.s) 800 ; in PDP-11 (unix) assembly language 801 ;----------------------------------------------------------------- 802 803 ; / init -- process control initialization 804 ; 805 ; sys intr; 0 806 ; sys quit; 0 807 ; sys 38. / get console switches 808 ; cmp r0,$173030 809 ; bne 1f 810 ;help: 811 ; clr r0 812 ; sys close 813 ; mov $1,r0 814 ; sys close 815 ; sys open; ctty; 0 816 ; sys open; ctty; 1 817 ; sys exec; shell; shellp 818 ; br help 819 ;1: 820 ; sys mount; rk1; usr 821 ; sys mount; rk2; ssys 822 ; sys mount; rk3; crp 823 ; mov $'0,r1 824 ;1: 825 ; movb r1,tapx+8 826 ; sys chmod; tapx; 17 827 ; inc r1 828 ; cmp r1,$'8 829 ; blo 1b 830 ; sys creat; utmp; 16 831 ; sys close 832 ; sys unlink; dpdlock 833 ; sys fork 834 ; br daemon 835 ; sys fork 836 ; br dirass 837 ; sys fork 838 ; br dds 839 ; movb $'x,zero+8. 840 ; jsr pc,wtmprec 841 ; mov $itab,r1 842 ; br 1f 843 ; 844 ;daemon: 845 ; sys exec; etcdpd; etcdpdp 846 ; sys exit 847 ; 848 ;dirass: 849 ; sys chdir; usrmel 850 ; sys exec; melda; meldap 851 ; sys exit 852 ; 853 ;dds: 854 ; sys exec; usrdd; usrddp 855 ; sys exit 856 ; 857 ;/ create shell processes 858 ; 859 ;1: 860 ; mov (r1)+,r0 861 ; beq pwait 862 ; movb r0,ttyx+8 863 ; jsr pc,dfork 864 ; mov r0,(r1)+ 865 ; br 1b 866 ; 867 ;/ wait for process to die 868 ; 869 ;pwait: 870 ; sys wait 871 ; mov $itab,r1 872 ; 873 ;/ search for process id 874 ; 875 ;2: 876 ; tst (r1)+ 877 ; beq pwait 878 ; cmp r0,(r1)+ 879 ; bne 2b 880 ; 881 ;/ take name out of utmp 882 ; 883 ; sub $4,r1 884 ; mov r1,-(sp) 885 ; mov (r1),r1 886 ; sub $'0,r1 887 ; cmp r1,$'a-'0 888 ; blo 2f 889 ; sub $'a-'0-10.,r1 / map a-z into 10. on 890 ;2: 891 ; asl r1 892 ; asl r1 893 ; asl r1 894 ; asl r1 895 ; mov r1,0f 896 ; mov $zero,r1 897 ;2: 898 ; clr (r1)+ 899 ; cmp r1,$zero+16. 900 ; blo 2b 901 ; sys open; utmp; 1 902 ; bes 2f 903 ; mov r0,r1 904 ; sys seek; 0:..; 0 905 ; mov r1,r0 906 ; sys write; zero; 16. 907 ; mov r1,r0 908 ; sys close 909 ; 910 ;/ re-create user process 911 ; 912 ;2: 913 ; mov (sp)+,r1 914 ; mov (r1)+,r0 915 ; movb r0,ttyx+8 916 ; movb r0,zero+8. 917 ; jsr pc,wtmprec 918 ; jsr pc,dfork 919 ; mov r0,(r1)+ 920 ; br pwait 921 ; 922 ;dfork: 923 ; sys fork 924 ; br 1f 925 ; bes dfork 926 ; rts pc 927 ;1: 928 ; sys quit; 0 929 ; sys intr; 0 930 ; sys chown; ttyx; 0 931 ; sys chmod; ttyx; 15 932 ; sys open; ttyx; 0 933 ; bes help1 934 ; sys open; ttyx; 1 935 ; bes help1 936 ; sys exec; getty; gettyp 937 ; sys exit / HELP! 938 ; 939 ;help1: 940 ; jmp help 941 ; 942 ;wtmprec: 943 ; mov r1,-(sp) 944 ; sys time 945 ; mov r0,zero+10. 946 ; mov r1,zero+12. 947 ; sys open; wtmp; 1 948 ; bes 2f 949 ; mov r0,r2 950 ; sys seek; 0; 2 951 ; mov r2,r0 952 ; sys write; zero; 16. 953 ; mov r2,r0 954 ; sys close 955 ;2: 956 ; mov (sp)+,r1 957 ; rts pc 958 ; 959 ;etcdpdp: 960 ; etcdpd; 0 961 ;meldap: 962 ; melda; 0 963 ;usrddp: 964 ; usrdd; 0 965 ;usrdd: 966 ;melda: 967 ;usrmel: 968 ;rk1: 969 ;rk2: 970 ;rk3: 971 ;usr: 972 ;ssys: 973 ;crp: 974 ;ctty: 975 ;shell: 976 ;shellm:<-\0> 977 ;dpdlock: 978 ; 979 ;etcdpd: 980 ; 981 ;tapx: 982 ;utmp: 983 ;wtmp: 984 ;ttyx: 985 ;getty: 986 ; .even 987 ; 988 ;shellp:shellm 989 ; 0 990 ;gettyp:getty 991 ; 0 992 ;itab: 993 ; '0; .. 994 ; '1; .. 995 ; '2; .. 996 ; '3; .. 997 ; '4; .. 998 ; '5; .. 999 ; '6; .. 1000 ; '7; .. 1001 ; '8; .. 1002 ; 'a; .. 1003 ; 'b; .. 1004 ; 0 1005 ; 1006 ; .bss 1007 ;offset:.=.+2 1008 ;zero: .=.+8.; .=.+6; .=.+2.