You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
171 lines
4.9 KiB
171 lines
4.9 KiB
|
|
; This is the "program" to execute a program |
|
xex: |
|
pusha ; save state before program |
|
sub sp, 512 |
|
mov [.program_executable_buffer], sp |
|
|
|
;mov [.program_executable_buffer], sp |
|
|
|
call os_clear_screen |
|
call lsfs_list_files_command |
|
|
|
; move cursor to the bootom |
|
xor ax, ax |
|
xor bx, bx |
|
mov ah, 0x02 |
|
mov bh, 0x00 ; page number 0 |
|
mov dh, 0x17 ; row zero |
|
mov dl, 0x00 ; coloumn zero |
|
int 0x10 |
|
|
|
mov si, .welcome_xex_enter_fileindex |
|
call print |
|
|
|
; Ask the user for the filename |
|
xor bx, bx |
|
xor cx, cx ; are going to be the counter |
|
xor dx, dx |
|
.enter_fileindex_loop: |
|
push cx |
|
.loop_no_push: |
|
mov ax, 0x10 ; BIOS call to wait for key |
|
int 0x16 |
|
cmp ax, 0x1c0d ; enter key |
|
je .fileindex_done |
|
cmp ax, 0x0e08 ; backspace |
|
jne .no_enter_fileindex |
|
cmp cx, 0 |
|
je .loop_no_push |
|
pop cx |
|
sub cx, 1 |
|
mov bx, [.program_executable_buffer] |
|
add bx, cx |
|
mov BYTE [bx], 0 |
|
; Go back one space |
|
mov ax, 0x0e08 ; ah=0x0e means teletype output. al=0x08 means backspace character. |
|
int 0x10 |
|
|
|
; Place a NULL |
|
mov al, 0x0 ; NULL |
|
int 0x10 |
|
|
|
; Go back one space again as the above print of NULL pushes the cursor forward again. |
|
mov ax, 0x0e08 |
|
int 0x10 |
|
jmp .enter_fileindex_loop |
|
|
|
.no_enter_fileindex: |
|
mov bh, 0x00 |
|
mov bl, 0x02 |
|
mov ah, 0x0E |
|
int 0x10 ; print char |
|
pop cx |
|
mov bx, [.program_executable_buffer] |
|
add bx, cx |
|
mov [bx], al |
|
add cx, 1 |
|
; fileindex must only be 120 chars |
|
cmp cx, 120 |
|
jae .fileindex_done |
|
|
|
jmp .enter_fileindex_loop |
|
|
|
.fileindex_done: |
|
pop cx ; Cleanup, and now contain filename size |
|
mov ax, cx |
|
add ax, [.program_executable_buffer] |
|
mov bx, ax |
|
mov BYTE [bx], 0 |
|
mov si, [.program_executable_buffer] |
|
call zstring_to_integer ; ax now contain the interger index for the file |
|
mov [.fileindex_for_open_file], ax ; save the file index |
|
|
|
|
|
mov ax, [.fileindex_for_open_file] |
|
mov bx, [.program_executable_buffer] |
|
|
|
.xex_lsfs_read_file: |
|
; INPUT ax = file index |
|
; INPUT bx = filebuffer |
|
pusha ; save all register state |
|
; We need to find the data pointers for the file. |
|
|
|
push bx |
|
|
|
mov dx, 24 ; LSFS_magic_start_sector |
|
add ax, dx ; senctor number, into the master Table. |
|
mov WORD [XEXPACK.db_addr_offset], xex_lsfs_loading_buffer |
|
mov WORD [XEXPACK.lba_addr_dw_low], ax |
|
mov WORD [XEXPACK.blkcnt], 0x1 ; Read to sectors, that is what the space is for the buffer in svim |
|
mov WORD [XEXPACK.db_addr_segment], 0x50 |
|
mov si, XEXPACK ; address of "disk address packet" |
|
mov ah, 0x42 ; READ |
|
mov dl, [global_disk_identifier] |
|
int 0x13 |
|
|
|
pop bx |
|
|
|
; Save the buffer addr |
|
mov bx, [xex_lsfs_loading_buffer + 288] ; this is the first data pointer |
|
mov ax, bx |
|
mov WORD [XEXPACK.lba_addr_dw_low], bx |
|
mov WORD [XEXPACK.blkcnt], 0x4 ; Read to sectors, that is what the space is for the buffer in svim |
|
mov WORD [XEXPACK.db_addr_segment], 0x2000 |
|
mov WORD [XEXPACK.db_addr_offset], 0x0 |
|
mov si, XEXPACK ; address of "disk address packet" |
|
mov ah, 0x42 ; READ |
|
mov dl, [global_disk_identifier] |
|
int 0x13 |
|
|
|
popa |
|
|
|
mov ax, [xex_lsfs_loading_buffer + 264] |
|
|
|
; I guess we should have something like |
|
push cs ; this gives us the correct code segment for the kernel |
|
push .this_place ; this gives the correct adress to come back from the program. |
|
push 0x2000 |
|
push 0x0 |
|
|
|
;push 0x0050 |
|
;push 0x0512 |
|
mov ax, 0x2000 |
|
mov ds, ax ; move data segment to the program start |
|
retf |
|
|
|
.this_place: |
|
push ax |
|
mov ax, 0x50 |
|
mov ds, ax ; Back to the kernel space |
|
call printCRLF |
|
mov si, .program_output_text |
|
call print |
|
pop ax |
|
call dumpax |
|
;mov bx, ss |
|
;call bx:ax ; here. We want to execute the file that we just have benn loaded in memory |
|
; The executable should make use of the global systemcall table. |
|
; That is what we are trying to get to work here. |
|
|
|
add sp, 512 |
|
popa ; retore |
|
ret |
|
|
|
|
|
.welcome_xex_enter_fileindex db 'Enter program index to execute: ', 0 |
|
.program_output_text db 'Program has terminated with return value: ', 0 |
|
.fileindex_for_open_file dw 0 |
|
.program_executable_buffer dw 0 |
|
|
|
align 2 |
|
xex_lsfs_loading_buffer times 512 db 0 |
|
|
|
XEXPACK: |
|
.dap_Size: db 0x10 ; This is always 16 bytes (0x10) |
|
.rev_byte: db 0x0 ; reserved byte, should always be zero |
|
.blkcnt: dw 0x0 ; int 13 resets this to # of blocks actually read/written |
|
.db_addr_offset: dw 0x0 ; memory buffer destination address (0:7c00) |
|
.db_addr_segment: dw 0x0 ; in memory page zero |
|
.lba_addr_dw_low: dd 0x0 ; put the lba to read in this spot |
|
.lba_addr_dw_high: dd 0x0 ; more storage bytes only for big lba's ( > 4 bytes ) |