     1                                  ; ****************************************************************************
     2                                  ; invalid.s - TRDOS 386 (TRDOS v2.0) Kernel - 'sysexec' exit code test
     3                                  ; ----------------------------------------------------------------------------
     4                                  ;
     5                                  ; 20/08/2024
     6                                  ;
     7                                  ; [ Last Modification: 20/08/2024 ]
     8                                  ;
     9                                  ; ****************************************************************************
    10                                  ; invalid system call test
    11                                  ; (program will be terminated and exit code will be -1)
    12                                  
    13                                  ; 20/08/2024 ; TRDOS 386 v2.0.9 (exit code)
    14                                  ; 20/08/2017
    15                                  ; 01/03/2017
    16                                  ; 16/10/2016
    17                                  ; 29/04/2016
    18                                  ; TRDOS 386 system calls (temporary list!)
    19                                  _ver 	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                                  _video 	equ 31
    51                                  _audio	equ 32
    52                                  _timer	equ 33
    53                                  _sleep	equ 34
    54                                  _msg    equ 35
    55                                  _geterr	equ 36
    56                                  _fpsave	equ 37
    57                                  _pri	equ 38
    58                                  _rele	equ 39
    59                                  _fff	equ 40
    60                                  _fnf	equ 41
    61                                  _alloc	equ 42
    62                                  _dalloc equ 43
    63                                  _calbac equ 44
    64                                  _dma	equ 45
    65                                  _stdio  equ 46	;  TRDOS 386 v2.0.9
    66                                  
    67                                  %macro sys 1-4
    68                                      ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)	
    69                                      ; 03/09/2015	
    70                                      ; 13/04/2015
    71                                      ; Retro UNIX 386 v1 system call.	
    72                                      %if %0 >= 2   
    73                                          mov ebx, %2
    74                                          %if %0 >= 3    
    75                                              mov ecx, %3
    76                                              %if %0 = 4
    77                                                 mov edx, %4   
    78                                              %endif
    79                                          %endif
    80                                      %endif
    81                                      mov eax, %1
    82                                      ;int 30h
    83                                      int 40h ; TRDOS 386 (TRDOS v2.0)	   
    84                                  %endmacro
    85                                  
    86                                  ; TRDOS 386 (and Retro UNIX 386 v1) system call format:
    87                                  ; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
    88                                  
    89                                  ;========================================================================
    90                                  ; EXEC TEST - CODE
    91                                  ;========================================================================
    92                                  
    93                                  [BITS 32] ; 32-bit intructions
    94                                  
    95                                  [ORG 0] 
    96                                  
    97                                  START_CODE:
    98                                  	sys	_msg, sysexit_test_hdr, 255, 0Bh
    68                              <1> 
    69                              <1> 
    70                              <1> 
    71                              <1> 
    72                              <1>  %if %0 >= 2
    73 00000000 BB[8F000000]        <1>  mov ebx, %2
    74                              <1>  %if %0 >= 3
    75 00000005 B9FF000000          <1>  mov ecx, %3
    76                              <1>  %if %0 = 4
    77 0000000A BA0B000000          <1>  mov edx, %4
    78                              <1>  %endif
    79                              <1>  %endif
    80                              <1>  %endif
    81 0000000F B823000000          <1>  mov eax, %1
    82                              <1> 
    83 00000014 CD40                <1>  int 40h
    99                                  
   100                                  	sys	_msg, sysexit_test_msg1, 255, 0Fh	
    68                              <1> 
    69                              <1> 
    70                              <1> 
    71                              <1> 
    72                              <1>  %if %0 >= 2
    73 00000016 BB[C8000000]        <1>  mov ebx, %2
    74                              <1>  %if %0 >= 3
    75 0000001B B9FF000000          <1>  mov ecx, %3
    76                              <1>  %if %0 = 4
    77 00000020 BA0F000000          <1>  mov edx, %4
    78                              <1>  %endif
    79                              <1>  %endif
    80                              <1>  %endif
    81 00000025 B823000000          <1>  mov eax, %1
    82                              <1> 
    83 0000002A CD40                <1>  int 40h
   101                                  	sys	_msg, sysexit_test_msg2, 255, 0Fh
    68                              <1> 
    69                              <1> 
    70                              <1> 
    71                              <1> 
    72                              <1>  %if %0 >= 2
    73 0000002C BB[2F010000]        <1>  mov ebx, %2
    74                              <1>  %if %0 >= 3
    75 00000031 B9FF000000          <1>  mov ecx, %3
    76                              <1>  %if %0 = 4
    77 00000036 BA0F000000          <1>  mov edx, %4
    78                              <1>  %endif
    79                              <1>  %endif
    80                              <1>  %endif
    81 0000003B B823000000          <1>  mov eax, %1
    82                              <1> 
    83 00000040 CD40                <1>  int 40h
   102                                  	sys	_msg, sysexit_test_msg3, 255, 0Fh
    68                              <1> 
    69                              <1> 
    70                              <1> 
    71                              <1> 
    72                              <1>  %if %0 >= 2
    73 00000042 BB[87010000]        <1>  mov ebx, %2
    74                              <1>  %if %0 >= 3
    75 00000047 B9FF000000          <1>  mov ecx, %3
    76                              <1>  %if %0 = 4
    77 0000004C BA0F000000          <1>  mov edx, %4
    78                              <1>  %endif
    79                              <1>  %endif
    80                              <1>  %endif
    81 00000051 B823000000          <1>  mov eax, %1
    82                              <1> 
    83 00000056 CD40                <1>  int 40h
   103                                  getchar:
   104 00000058 30E4                    	xor	ah, ah
   105 0000005A CD32                    	int	32h
   106                                  
   107 0000005C 3C1B                    	cmp	al, 1Bh ; ESC key
   108 0000005E 740B                    	je	short child_ok_exit
   109                                  
   110 00000060 3C0D                    	cmp	al, 0Dh ; ENTER (CR) key
   111 00000062 75F4                    	jne	short getchar
   112                                  
   113                                  	_INVALID equ 255 ; > 46 
   114                                  			 ; (the last system call number for v2.0.9)
   115                                  	sys	_INVALID
    68                              <1> 
    69                              <1> 
    70                              <1> 
    71                              <1> 
    72                              <1>  %if %0 >= 2
    73                              <1>  mov ebx, %2
    74                              <1>  %if %0 >= 3
    75                              <1>  mov ecx, %3
    76                              <1>  %if %0 = 4
    77                              <1>  mov edx, %4
    78                              <1>  %endif
    79                              <1>  %endif
    80                              <1>  %endif
    81 00000064 B8FF000000          <1>  mov eax, %1
    82                              <1> 
    83 00000069 CD40                <1>  int 40h
   116                                  
   117                                  child_ok_exit:
   118                                  	sys	_msg, msg_ok, 255, 07h
    68                              <1> 
    69                              <1> 
    70                              <1> 
    71                              <1> 
    72                              <1>  %if %0 >= 2
    73 0000006B BB[06020000]        <1>  mov ebx, %2
    74                              <1>  %if %0 >= 3
    75 00000070 B9FF000000          <1>  mov ecx, %3
    76                              <1>  %if %0 = 4
    77 00000075 BA07000000          <1>  mov edx, %4
    78                              <1>  %endif
    79                              <1>  %endif
    80                              <1>  %endif
    81 0000007A B823000000          <1>  mov eax, %1
    82                              <1> 
    83 0000007F CD40                <1>  int 40h
   119                                  terminate:
   120 00000081 BB18000000              	mov	ebx, 24 ; 'programmed in 2024' signature
   121                                  	sys	_exit
    68                              <1> 
    69                              <1> 
    70                              <1> 
    71                              <1> 
    72                              <1>  %if %0 >= 2
    73                              <1>  mov ebx, %2
    74                              <1>  %if %0 >= 3
    75                              <1>  mov ecx, %3
    76                              <1>  %if %0 = 4
    77                              <1>  mov edx, %4
    78                              <1>  %endif
    79                              <1>  %endif
    80                              <1>  %endif
    81 00000086 B801000000          <1>  mov eax, %1
    82                              <1> 
    83 0000008B CD40                <1>  int 40h
   122                                  
   123 0000008D EBF2                    	jmp	short terminate
   124                                  
   125                                  ;-----------------------------------------------------------------
   126                                  ;  messages
   127                                  ;-----------------------------------------------------------------
   128                                  
   129                                  sysexit_test_hdr:
   130 0000008F 0D0A                    		db 0Dh, 0Ah
   131 00000091 5452444F5320333836-     		db "TRDOS 386 v2.0.9 - <sysexit> exit code -return- test"
   131 0000009A 2076322E302E39202D-
   131 000000A3 203C73797365786974-
   131 000000AC 3E206578697420636F-
   131 000000B5 6465202D7265747572-
   131 000000BE 6E2D2074657374     
   132 000000C5 0D0A00                  		db 0Dh, 0Ah, 0
   133                                  sysexit_test_msg1:
   134 000000C8 0D0A                    		db 0Dh, 0Ah
   135 000000CA 507265737320454E54-     		db "Press ENTER to get INVALID SYSTEM CALL response."
   135 000000D3 455220746F20676574-
   135 000000DC 20494E56414C494420-
   135 000000E5 53595354454D204341-
   135 000000EE 4C4C20726573706F6E-
   135 000000F7 73652E             
   136 000000FA 0D0A                    		db 0Dh, 0Ah
   137 000000FC 284578697420636F64-     		db "(Exit code will be 0FFh or 255. It means error.)" 
   137 00000105 652077696C6C206265-
   137 0000010E 2030464668206F7220-
   137 00000117 3235352E204974206D-
   137 00000120 65616E73206572726F-
   137 00000129 722E29             
   138 0000012C 0D0A00                  		db 0Dh, 0Ah, 0
   139                                  sysexit_test_msg2:
   140 0000012F 0D0A                    		db 0Dh, 0Ah
   141 00000131 507265737320455343-     		db "Press ESC to skip INVALID SYSTEM CALL test."
   141 0000013A 20746F20736B697020-
   141 00000143 494E56414C49442053-
   141 0000014C 595354454D2043414C-
   141 00000155 4C20746573742E     
   142 0000015C 0D0A                    		db 0Dh, 0Ah
   143 0000015E 285573657227732065-     		db "(User's exit code will be 018h or 24.)"
   143 00000167 78697420636F646520-
   143 00000170 77696C6C2062652030-
   143 00000179 313868206F72203234-
   143 00000182 2E29               
   144 00000184 0D0A00                  		db 0Dh, 0Ah, 0
   145                                  sysexit_test_msg3:
   146 00000187 0D0A                    		db 0Dh, 0Ah
   147 00000189 4E4F54453A20496620-     		db "NOTE: If this program is run as a child"
   147 00000192 746869732070726F67-
   147 0000019B 72616D206973207275-
   147 000001A4 6E2061732061206368-
   147 000001AD 696C64             
   148 000001B0 0D0A                    		db 0Dh, 0Ah
   149 000001B2 202020202020627920-     		db "      by the exit code test program as parent,"
   149 000001BB 746865206578697420-
   149 000001C4 636F64652074657374-
   149 000001CD 2070726F6772616D20-
   149 000001D6 617320706172656E74-
   149 000001DF 2C                 
   150 000001E0 0D0A                    		db 0Dh, 0Ah
   151 000001E2 202020202020796F75-     		db "      you will see the exit code."
   151 000001EB 2077696C6C20736565-
   151 000001F4 207468652065786974-
   151 000001FD 20636F64652E       
   152 00000203 0D0A00                  		db 0Dh, 0Ah, 0
   153                                  msg_ok:
   154 00000206 0D0A                            	db 0Dh, 0Ah
   155 00000208 4F4B2E20                        	db "OK. "
   156 0000020C 0D0A                            	db 0Dh, 0Ah
   157                                  sizeof_ok 	equ $ - msg_ok 
   158 0000020E 00                              	db 0
