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