     1                                  ; ****************************************************************************
     2                                  ; inittest.s (init386.s)
     3                                  ; ----------------------------------------------------------------------------
     4                                  ;
     5                                  ; Retro UNIX 386 v1.2 Kernel - /etc/init file executing test (30/11/2021)
     6                                  ;
     7                                  ; [ Last Modification: 30/11/2021 ]
     8                                  ;
     9                                  ; ****************************************************************************
    10                                  ; (modified from 'init0.s', 24/10/2015, Retro UNIX 386 v1 /etc/init test file)
    11                                  ; ----------------------------------------------------------------------------
    12                                  ; nasm inittest.s -l inittest.txt -o init386 -Z error.txt
    13                                  
    14                                  ; 30/11/2021
    15                                  ; 07/08/2015
    16                                  ; 30/06/2015
    17                                  ; 14/07/2013
    18                                  ; UNIX v1 system calls
    19                                  _rele 	equ 0
    20                                  _exit 	equ 1
    21                                  _fork 	equ 2
    22                                  _read 	equ 3
    23                                  _write	equ 4
    24                                  _open	equ 5
    25                                  _close 	equ 6
    26                                  _wait 	equ 7
    27                                  _creat 	equ 8
    28                                  _link 	equ 9
    29                                  _unlink	equ 10
    30                                  _exec	equ 11
    31                                  _chdir	equ 12
    32                                  _time 	equ 13
    33                                  _mkdir 	equ 14
    34                                  _chmod	equ 15
    35                                  _chown	equ 16
    36                                  _break	equ 17
    37                                  _stat	equ 18
    38                                  _seek	equ 19
    39                                  _tell 	equ 20
    40                                  _mount	equ 21
    41                                  _umount	equ 22
    42                                  _setuid	equ 23
    43                                  _getuid	equ 24
    44                                  _stime	equ 25
    45                                  _quit	equ 26	
    46                                  _intr	equ 27
    47                                  _fstat	equ 28
    48                                  _emt 	equ 29
    49                                  _mdate 	equ 30
    50                                  _stty 	equ 31
    51                                  _gtty	equ 32
    52                                  _ilgins	equ 33
    53                                  _sleep	equ 34 ; Retro UNIX 8086 v1 feature only !
    54                                  _msg    equ 35 ; Retro UNIX 386 v1 feature only !
    55                                  
    56                                  %macro sys 1-4
    57                                      ; 13/04/2015
    58                                      ; Retro UNIX 386 v1 system call.		
    59                                      mov eax, %1
    60                                      %if %0 >= 2   
    61                                          mov ebx, %2
    62                                          %if %0 >= 3    
    63                                              mov ecx, %3
    64                                              %if %0 = 4
    65                                                 mov edx, %4   
    66                                              %endif
    67                                          %endif
    68                                      %endif
    69                                      int 30h	   
    70                                  %endmacro
    71                                  
    72                                  [BITS 32] ; We need 32-bit intructions for protected mode
    73                                  
    74                                  [ORG 0] 
    75                                  
    76                                  START_CODE:
    77                                  	;sys _msg, copy_right_msg, 255, 0Fh ; copy right message with white color
    78                                  	sys _msg, running_msg, sizeof_msg, 0Fh
    79                              <1> 
    80                              <1> 
    81 00000000 B823000000          <1>  mov eax, %1
    82                              <1>  %if %0 >= 2
    83 00000005 BB[20000000]        <1>  mov ebx, %2
    84                              <1>  %if %0 >= 3
    85 0000000A B98E000000          <1>  mov ecx, %3
    86                              <1>  %if %0 = 4
    87 0000000F BA0F000000          <1>  mov edx, %4
    88                              <1>  %endif
    89                              <1>  %endif
    90                              <1>  %endif
    91 00000014 CD30                <1>  int 30h
    92                                  
    93                                  	sys _exit
    94                              <1> 
    95                              <1> 
    96 00000016 B801000000          <1>  mov eax, %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 0000001B CD30                <1>  int 30h
   107                                  
   108                                  haltsys:
   109 0000001D F4                      	hlt
   110 0000001E EBFD                    	jmp short haltsys
   111                                  
   112                                  ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   113                                  ;  messages
   114                                  ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   115                                  
   116                                  running_msg:
   117 00000020 0D0A07                      		db 0Dh, 0Ah, 07h
   118 00000023 526574726F20554E49-                     db 'Retro UNIX 386 v1.2 Kernel Function Test : <sysexec> Function is OK!'
   119 0000002C 58203338362076312E-
   120 00000035 32204B65726E656C20-
   121 0000003E 46756E6374696F6E20-
   122 00000047 54657374203A203C73-
   123 00000050 7973657865633E2046-
   124 00000059 756E6374696F6E2069-
   125 00000062 73204F4B21         
   126 00000067 0D0A                                    db 0Dh, 0Ah
   127 00000069 0D0A                                    db 0Dh, 0Ah
   128 0000006B 526574726F20554E49-                     db 'Retro UNIX 386 v1.2 </etc/init> loading and running test is OK!'
   129 00000074 58203338362076312E-
   130 0000007D 32203C2F6574632F69-
   131 00000086 6E69743E206C6F6164-
   132 0000008F 696E6720616E642072-
   133 00000098 756E6E696E67207465-
   134 000000A1 7374206973204F4B21 
   135 000000AA 0D0A                    		db  0Dh, 0Ah
   136 000000AC 0D0A                    		db  0Dh, 0Ah	
   137                                  sizeof_msg equ $ - running_msg 
   138 000000AE 00                              	db 0
   139                                  
   140                                  copy_right_msg:
   141 000000AF 286329204572646F67-                     db  '(c) Erdogan TAN - 30/11/2021'
   142 000000B8 616E2054414E202D20-
   143 000000C1 33302F31312F323032-
   144 000000CA 31                 
   145 000000CB 0D0A00                  		db  0Dh, 0Ah, 0
