; The OS/K Team licenses this file to you under the MIT license. ; See the LICENSE file in the project root for more information. .try_exec: ; try without appending ".com" mov eax, Sys.OpenFile mov ax0, argv0 trap 0 ; we good? blte zero, eax, .do_exec ; nope, append ".com" and try again sub ecx, argbuf.size, 5 scasb ax0, zero ; find null-term mov b[ax0+0], '.' ; ".com" mov b[ax0+1], 'c' mov b[ax0+2], 'o' mov b[ax0+3], 'm' nul b[ax0+4] ; try again mov eax, Sys.OpenFile mov ax0, argv0 trap 0 ; still no good? bltz eax, .exec_not_found .do_exec: ; load file into memory mov ax0, eax mov ax1, FILE_LOADP mov ax2, FILE_MAXSZ mov eax, Sys.ReadFile trap 0 ; save load address mov ecx, eax ; close file mov eax, Sys.CloseFile trap 0 ; read anything? bltz ecx, .couldnt_read jecxz .empty_file ; all good, let's go mov eax, Sys.ExecuteInFrame mov ax0, FILE_LOADP mov ax1, 5 trap 0 ; unreachable jmp abort