--- /dev/null
+;******************************************************************************
+; @file ll.asm
+;******************************************************************************
+%define CAPACITY_INCREMENT 256
+
+%ifndef HEX
+% define HEX(y) 0x##y
+%endif
+
+;******************************************************************************
+; @function _load_line
+;******************************************************************************
+global _load_line
+_load_line:
+
+ push bp
+
+ mov bp, sp
+ sub sp, 12
+
+ push bx
+ push cx
+ push dx
+ push si
+ push di
+ push es
+ push ds
+
+ mov bx, word ptr [bp + 12]
+
+ and bx, bx
+ jz .L18
+
+ mov cx, ds
+
+ push es
+ push ds
+ push si
+ push di
+
+ mov es, cx
+ mov ds, bx
+
+ mov di, offset _load_line_data
+ xor si, si
+
+ mov cx, 14
+ rep movsb
+
+ pop di
+ pop si
+ pop ds
+ pop es
+
+ mov ax, ss
+ mov es, ax
+
+ xor ax, ax
+ lea di, word ptr [bp - 12]
+
+ mov cx, 12
+ rep stosb
+
+ mov cx, word ptr [_load_line_data + 12]
+
+ and cx, cx
+ jz .L1
+
+ push es
+ push ds
+
+ mov ax, word ptr [_load_line_data + 8]
+ sub ax, word ptr [_load_line_data + 12]
+
+ push ax
+
+ mov ax, word ptr [_load_line_data + 2]
+ xor dx, dx
+
+ mov cx, 16
+ mul cx
+
+ add ax, word ptr [_load_line_data + 12]
+ adc dx, 0
+
+ div cx
+ push dx
+
+ xor bx, bx
+ push bx
+
+ mov bx, word ptr [_load_line_data + 2]
+ mov es, bx
+
+ mov ds, ax
+
+ call _memmove
+ add sp, 6
+
+ pop ds
+ pop es
+
+ mov cx, word ptr [_load_line_data + 12]
+ sub word ptr [_load_line_data + 8], cx
+
+.L1:
+
+ mov ax, word ptr [_load_line_data + 4]
+
+ cmp ax, word ptr [bp - 12]
+ jb .L2
+
+ cmp ax, word ptr [bp - 8]
+ ja .L3
+
+.L2:
+
+ mov ax, word ptr [_load_line_data + 4]
+ xor dx, dx
+
+ add ax, CAPACITY_INCREMENT
+ mov word ptr [_load_line_data + 4], ax
+
+ mov bx, ax
+ xor cx, cx
+
+ add bx, 2
+ adc cx, 0
+
+ push ax
+ push dx
+
+ push bx
+ push cx
+ push word ptr word ptr [_load_line_data + 0]
+
+ call _xrealloc
+ add sp, 6
+
+ mov word ptr [_load_line_data + 0], ax
+ pop dx
+ pop ax
+
+ mov bx, ax
+ mov cx, dx
+
+ add bx, 1
+ adc cx, 0
+
+ push ax
+ push dx
+
+ push bx
+ push cx
+ push word ptr word ptr [_load_line_data + 2]
+
+ call _xrealloc
+ add sp, 6
+
+ mov word ptr [_load_line_data + 2], ax
+ pop dx
+ pop ax
+
+.L3:
+
+ mov ax, word ptr [_load_line_data + 8]
+
+ cmp ax, word ptr [bp - 8]
+ ja .L4
+
+ push ds
+ push word ptr [bp + 10]
+
+ mov ax, word ptr [_load_line_data + 4]
+ sub ax, word ptr [bp - 8]
+
+ push ax
+
+ mov ax, 1
+ push ax
+
+ mov ax, word ptr [_load_line_data + 2]
+ xor dx, dx
+
+ mov cx, 16
+ mul cx
+
+ add ax, word ptr [bp - 8]
+ adc dx, 0
+
+ div cx
+
+ mov ds, ax
+ push dx
+
+ call _fread
+ add sp, 8
+
+ pop ds
+ jc .L5
+
+ add ax, word ptr [bp - 8]
+ mov word ptr [_load_line_data + 8], ax
+
+ mov ax, word ptr [_load_line_data + 2]
+ xor dx, dx
+
+ mov cx, 16
+ mul cx
+
+ add ax, word ptr [_load_line_data + 8]
+ adc dx, 0
+
+ div cx
+
+ push es
+ push di
+
+ mov es, ax
+ mov di, dx
+
+ xor al, al
+ mov es:[di], al
+
+ pop di
+ pop es
+
+.L15:
+
+ cmp word ptr [bp - 4], 1
+ jne .L4
+
+.L17:
+
+ mov ax, word ptr [_load_line_data + 8]
+
+ cmp ax, word ptr [bp - 8]
+ jb .L4
+
+ mov ax, word ptr [_load_line_data + 2]
+ xor dx, dx
+
+ mov cx, 16
+ mul cx
+
+ add ax, word ptr [bp - 8]
+ adc dx, 0
+
+ div cx
+
+ push es
+ push di
+
+ mov es, ax
+ mov di, dx
+
+ mov bl, es:[di]
+ pop di
+ pop es
+
+ cmp bl, HEX (0A)
+ jne .L16
+
+ mov word ptr [bp - 4], 0
+ jmp .L4
+
+.L16:
+
+ add word ptr [bp - 8], 1
+ jmp .L17
+
+.L4:
+
+ mov ax, word ptr [_load_line_data + 8]
+
+ cmp ax, word ptr [bp - 8]
+ jbe .L6
+
+.L10:
+
+ mov ax, word ptr [_load_line_data + 4]
+
+ cmp ax, word ptr [bp - 12]
+ jbe .L6
+
+.L11:
+
+ push es
+ push di
+
+ mov ax, word ptr [_load_line_data + 2]
+ xor dx, dx
+
+ mov cx, 16
+ mul cx
+
+ add ax, word ptr [bp - 8]
+ adc dx, 0
+
+ div cx
+
+ mov es, ax
+ mov di, dx
+
+ mov bl, es:[di]
+ pop di
+ pop es
+
+ add word ptr [bp - 8], 1
+
+ push es
+ push di
+
+ mov ax, word ptr [_load_line_data + 0]
+ xor dx, dx
+
+ mov cx, 16
+ mul cx
+
+ add ax, word ptr [bp - 12]
+ adc dx, 0
+
+ div cx
+
+ mov es, ax
+ mov di, dx
+
+ mov es:[di], bl
+
+ pop di
+ pop es
+
+ cmp bl, '#'
+ jne .L14
+
+ mov word ptr [bp - 4], 1
+ jmp .L15
+
+.L14:
+
+ cmp bl, HEX (0A)
+ jne .L7
+
+ mov si, word ptr [bp - 12]
+
+ and si, si
+ jz .L12
+
+ dec si
+
+ mov ax, word ptr [_load_line_data + 0]
+ xor dx, dx
+
+ mov cx, 16
+ mul cx
+
+ add ax, si
+ adc dx, 0
+
+ inc si
+ div cx
+
+ push es
+ push di
+
+ mov es, ax
+ mov di, dx
+
+ mov bl, es:[di]
+ pop di
+ pop es
+
+ cmp bl, HEX (0D)
+ jne .L13
+
+ push es
+ push di
+
+ mov es, ax
+ mov di, dx
+
+ mov bl, HEX (0A)
+ mov es:[di], bl
+
+ pop di
+ pop es
+
+ mov word ptr [bp - 12], si
+
+.L13:
+
+ and si, si
+ jz .L12
+
+ dec si
+
+ mov ax, word ptr [_load_line_data + 0]
+ xor dx, dx
+
+ mov cx, 16
+ mul cx
+
+ add ax, si
+ adc dx, 0
+
+ div cx
+
+ push es
+ push di
+
+ mov es, ax
+ mov di, dx
+
+ mov bl, es:[di]
+ pop di
+ pop es
+
+ cmp bl, ' '
+ jne .L12
+
+ push es
+ push di
+
+ mov es, ax
+ mov di, dx
+
+ mov bl, HEX (0A)
+ mov es:[di], bl
+
+ pop di
+ pop es
+
+ mov word ptr [bp - 12], si
+ jmp .L13
+
+.L12:
+
+ mov bx, word ptr [bp - 12]
+ inc bx
+
+ mov ax, word ptr [_load_line_data + 0]
+ xor dx, dx
+
+ mov cx, 16
+ mul cx
+
+ add ax, bx
+ adc dx, 0
+
+ div cx
+
+ push es
+ push di
+
+ mov es, ax
+ mov di, dx
+
+ xor al, al
+ mov es:[di], al
+
+ pop di
+ pop es
+
+ mov bx, word ptr [bp - 8]
+ mov word ptr [_load_line_data + 12], bx
+
+ mov bx, word ptr [bp + 4]
+
+ mov ax, word ptr [_load_line_data + 0]
+ mov [bx], ax
+
+ jmp .L8
+
+.L7:
+
+ add word ptr [bp - 12], 1
+ jmp .L4
+
+.L6:
+
+ push word ptr [bp + 10]
+
+ call _feof
+ add sp, 2
+
+ and ax, ax
+ jz .L1
+
+ mov cx, word ptr [_load_line_data + 8]
+
+ and cx, cx
+ jz .L5
+
+ mov ax, word ptr [_load_line_data + 0]
+ xor dx, dx
+
+ mov cx, 16
+ mul cx
+
+ add ax, word ptr [bp - 12]
+ adc dx, 0
+
+ div cx
+
+ push es
+ push di
+
+ mov es, ax
+ mov di, dx
+
+ mov al, HEX (0A)
+ mov es:[di], al
+
+ pop di
+ pop es
+
+ mov bx, word ptr [bp - 12]
+ inc bx
+
+ mov ax, word ptr [_load_line_data + 0]
+ xor dx, dx
+
+ mov cx, 16
+ mul cx
+
+ add ax, bx
+ adc dx, 0
+
+ push es
+ push di
+
+ mov es, ax
+ mov di, dx
+
+ xor ax, ax
+ mov es:[di], al
+
+ pop di
+ pop es
+
+ mov word ptr [_load_line_data + 12], ax
+ mov word ptr [_load_line_data + 8], ax
+
+ mov bx, word ptr [bp + 4]
+
+ mov ax, word ptr [_load_line_data + 0]
+ mov [bx], ax
+
+ jmp .L8
+
+.L5:
+
+ mov ax, word ptr [bp + 12]
+ mov es, ax
+
+ mov si, offset _load_line_data
+ xor di, di
+
+ mov cx, 14
+ rep movsb
+
+.L18:
+
+ mov ax, 1
+
+ pop ds
+ pop es
+ pop di
+ pop si
+ pop dx
+ pop cx
+ pop bx
+
+ add sp, 12
+ stc
+
+ pop bp
+ ret
+
+.L8:
+
+ mov ax, word ptr [bp + 12]
+ mov es, ax
+
+ mov si, offset _load_line_data
+ xor di, di
+
+ mov cx, 14
+ rep movsb
+
+ xor ax, ax
+
+ pop ds
+ pop es
+ pop di
+ pop si
+ pop dx
+ pop cx
+ pop bx
+
+ add sp, 12
+ clc
+
+ pop bp
+ ret
+
+;******************************************************************************
+; @function _load_line_create_internal_data
+;******************************************************************************
+global _load_line_create_internal_data
+_load_line_create_internal_data:
+
+ push dx
+
+.L19:
+
+ mov ax, 16
+ xor dx, dx
+
+ push ax
+ push dx
+
+ call _xmalloc
+ add sp, 4
+
+.L20:
+
+ pop dx
+ ret
+
+;******************************************************************************
+; @function _load_line_destroy_internal_data
+;******************************************************************************
+global _load_line_destroy_internal_data
+_load_line_destroy_internal_data:
+
+ push bp
+ mov bp, sp
+
+ push es
+ push bx
+ push si
+
+ mov bx, word ptr [bp + 4]
+
+ and bx, bx
+ jz .L21
+
+ mov es, bx
+ xor bx, bx
+
+ mov si, es:[bx + 0]
+
+ and si, si
+ jz .L22
+
+ push si
+
+ call _free
+ add sp, 2
+
+.L22:
+
+ mov si, es:[bx + 2]
+
+ and si, si
+ jz L23
+
+ push si
+
+ call _free
+ add sp, 2
+
+L23:
+
+ push es
+
+ call _free
+ add sp, 2
+
+.L21:
+
+ pop si
+ pop bx
+ pop es
+ pop bp
+ ret
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Data area.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+_load_line_data: db 14 dup (0)
mov bx, offset _welcome_message
call _writestr
+
+ xor ax, ax
+ push ax
+
+ mov bx, offset _autoexec
+ push bx
+
+ call _read_batch
+ add sp, 4
.L5:
.L21:
- mov di, offset _formatted_command
- push di
-
- xor al, al
-
- mov cx, 255
- rep stosb
-
mov bx, offset _scratch
push bx
- call _expand_vars
- add sp, 4
+ call _process_line
+ add sp, 2
- mov bx, offset _formatted_command
+ jmp .L5
+
+.L1:
+
+ and ch, ch
+ jz .L67
- call _get_command
- jc .L23
+ push ax
+ push bx
+ push cx
+ push dx
- mov si, bx
- xor ax, ax
+ xor ah, ah
+ mov al, cs:[_curr_col]
- lodsb
+ xor dx, dx
- and al, al
- jz .L7
+ mov cl, ch
+ xor ch, ch
- push bx
- xor bx, bx
+ add ax, cx
- or al, HEX (20)
- mov bl, al
-
-.L28:
-
- lodsb
+ mov di, offset _scratch
+ add di, cx
- or al, al
- jz .L31
+ mov cx, 80
+ div cx
- mov cl, 5
- rol bx, cl
+ mov dh, cs:[_curr_row]
+ add dh, al
- or al, HEX (20)
- xor bx, ax
+ mov ax, HEX (0200)
+ xor bx, bx
+ int HEX (10)
- jmp .L28
+ pop dx
+ pop cx
+ pop bx
+ pop ax
-.L31:
+.L67:
- mov di, bx
- pop bx
-
- mov si, offset _cmd_table
- mov cx, offset _cmd_count
+ call _history_up
+ jmp .L11
-.L29:
+.L2:
- lodsw
+ and ch, ch
+ jz .L66
- cmp di, ax
- je .L30
+ push ax
+ push bx
+ push cx
+ push dx
- lodsw
- lodsw
- loop .L29
+ xor ah, ah
+ mov al, cs:[_curr_col]
- jmp .L23
-
-.L30:
-
- push bx
+ xor dx, dx
- call _strlen
- add sp, 2
+ mov cl, ch
+ xor ch, ch
- add bx, ax
- inc bx
-
-.L33:
-
- cmp byte ptr [bx], 0
- je .L32
+ add ax, cx
- cmp byte ptr [bx], ' '
- ja .L32
+ mov di, offset _scratch
+ add di, cx
- inc bx
- jmp .L33
+ mov cx, 80
+ div cx
+
+ mov dh, cs:[_curr_row]
+ add dh, al
+
+ mov ax, HEX (0200)
+ xor bx, bx
+ int HEX (10)
+
+ pop dx
+ pop cx
+ pop bx
+ pop ax
-.L32:
+.L66:
- lodsw
-
- call cs:[si]
- jmp .L5
+ call _history_down
+ jmp .L11
-.L23:
+.L75:
- mov di, offset _app_path
+ and ch, ch
+ jz .L11
- mov ax, '\\'
push ax
-
- mov si, bx
push bx
+ push cx
+ push dx
- call _strrchr
- add sp, 4
+ xor ah, ah
+ mov al, cs:[_curr_col]
- and ax, ax
- jz .L27
+ xor dx, dx
- mov bx, ax
- mov byte ptr [bx], 0
+ mov cl, ch
+ xor ch, ch
- call _format_path
+ add ax, cx
- mov al, '\\'
- stosb
+ mov di, offset _scratch
+ add di, cx
- inc bx
+ mov cx, 80
+ div cx
+
+ mov dh, cs:[_curr_row]
+ add dh, al
+
+ mov ax, HEX (0200)
+ xor bx, bx
+ int HEX (10)
+
+ pop dx
+ pop cx
+ pop bx
+ pop ax
+
+ jmp .L11
-.L27:
+.L74:
- mov ax, '.'
push ax
-
- mov si, bx
push bx
+ push cx
+ push dx
- call _strrchr
- add sp, 4
+ mov dh, cs:[_curr_row]
+ mov dl, cs:[_curr_col]
- and ax, ax
- jnz .L24
+ mov ax, HEX (0200)
+ xor bx, bx
+ int HEX (10)
+
+ mov di, offset _scratch
+ pop dx
+ pop cx
+ pop bx
+ pop ax
+
+ jmp .L11
-.L26:
+;******************************************************************************
+; @function _concat_exec
+;******************************************************************************
+_concat_exec:
+ push bp
+ mov bp, sp
+
+ push ax
push bx
+ push cx
+ push dx
+ push si
+ push di
+ push es
- call _strlen
- add sp, 2
+ mov ax, ds
+ mov es, ax
- mov cx, ax
- rep movsb
+ mov di, offset _full_path
- mov word ptr cs:[_need_ext], 1
- add bx, ax
+ mov si, word ptr [bp + 4]
+ call _format_path
- mov al, '.'
+ mov al, '\\'
stosb
- mov al, 'c'
- stosb
+ mov si, word ptr [bp + 6]
+ call _format_path
- mov al, 'o'
- stosb
+ mov dx, offset _full_path
+ inc bx
+ mov di, bx
- mov al, 'm'
- stosb
+ mov bx, offset _param_blk
- jmp .L25
+ mov word ptr [bx + 2], di
+ mov word ptr [bx + 4], ds
+
+ mov ax, HEX (4B00)
+ int HEX (21)
-.L24:
+_concat_exec.done:
- push bx
-
- call _strlen
- add sp, 2
-
- mov cx, ax
- rep movsb
-
- add bx, ax
+ pop es
+ pop di
+ pop si
+ pop dx
+ pop cx
+ pop bx
+ pop ax
+ pop bp
+ ret
-.L25:
+;******************************************************************************
+; @function _concat_read
+;******************************************************************************
+_concat_read:
- xor al, al
- stosb
+ push bp
+ mov bp, sp
+ push ax
push bx
+ push cx
+ push dx
+ push si
+ push di
+ push es
- mov dx, offset _app_path
- inc bx
- mov di, bx
+ mov ax, ds
+ mov es, ax
- mov bx, offset _param_blk
+ mov di, offset _full_path
- mov word ptr [bx + 2], di
- mov word ptr [bx + 4], ds
+ mov si, word ptr [bp + 4]
+ call _format_path
- mov ax, HEX (4B00)
- int HEX (21)
- pop bx
- jnc .L5
+ mov al, '\\'
+ stosb
- mov ax, '\\'
+ mov si, word ptr [bp + 6]
+ call _format_path
+
+ mov ax, 1
push ax
- mov ax, offset _app_path
+ mov ax, offset _full_path
push ax
- call _strrchr
+ call _read_batch
+ jc _concat_read.err
+
add sp, 4
+ clc
- and ax, ax
- jnz .L98
+ jmp _concat_read.done
-.L99:
+_concat_read.err:
- call _get_paths
+ add sp, 4
+ stc
+
+_concat_read.done:
+
+ pop es
+ pop di
+ pop si
+ pop dx
+ pop cx
+ pop bx
+ pop ax
+ pop bp
+ ret
+
+;******************************************************************************
+; @function _get_env
+;******************************************************************************
+_get_env:
+
+ push bp
+ mov bp, sp
- push ax
push bx
push cx
+ push dx
+ push si
push di
push es
- mov ax, cs:[_vec_paths]
- mov es, ax
- mov cx, cs:[_vec_paths + 4]
+ mov si, cs:[_vec_env]
+ mov cx, cs:[_vec_env + 4]
+ mov es, si
xor di, di
-.L96:
+.L91:
and cx, cx
- jz .L97
+ jz .L92
- mov ax, offset _app_path
+ push es
+ mov ax, es:[di]
+
+ mov es, ax
+ push es
+
+ xor bx, bx
+ mov ax, es:[bx]
+
+ push cx
+ push es
+ push ds
+
+ mov cx, cs
+ mov es, cx
+ mov ds, ax
+
+ push es
+ push di
+
+ mov di, offset _temp
+ xor al, al
+
+ mov cx, 255
+ rep stosb
+
+ pop di
+ pop es
+
+ xor ax, ax
push ax
- mov ax, es:[di]
+ mov ax, offset _temp
push ax
- call _concat_exec
- jnc .L100
+ call _strcpy
add sp, 4
- add di, 2
- dec cx
+ mov ax, word ptr [bp + 4]
+ push ax
- jmp .L96
-
-.L100:
-
+ mov ax, offset _temp
+ push ax
+
+ call _strcmp
add sp, 4
+ pop ds
pop es
- pop di
pop cx
- pop bx
+
+ and ax, ax
+ jz .L93
+
pop ax
+ pop es
- jmp .L5
+ add di, 2
+ dec cx
+
+ jmp .L91
-.L97:
+.L93:
+
+ pop ax
+ pop es
+
+ jmp .L90
+
+.L92:
+
+ xor ax, ax
+
+.L90:
pop es
pop di
+ pop si
+ pop dx
pop cx
pop bx
- pop ax
+ pop bp
+ ret
-.L98:
+;******************************************************************************
+; @function _expand_vars
+;******************************************************************************
+_expand_vars:
- mov bx, offset _err_invalid
- call _writestr
-
- cmp word ptr cs:[_need_ext], 1
- jb .L34
+ push bp
+ mov bp, sp
- mov ax, '.'
push ax
-
- mov bx, offset _app_path
push bx
+ push cx
+ push dx
+ push si
+ push di
- call _strrchr
- add sp, 4
+ mov di, word ptr [bp + 6]
+ mov si, word ptr [bp + 4]
- mov bx, ax
- mov byte ptr [bx], 0
+ mov dx, di
-.L34:
+.L87:
- mov bx, offset _app_path
- call _writestr
- call _crlf
+ cmp byte ptr [si], 0
+ je .L84
- jmp .L5
-
-.L1:
-
- and ch, ch
- jz .L67
+ mov cx, di
+ sub cx, dx
- push ax
- push bx
- push cx
- push dx
+ cmp cx, 255
+ jae .L84
- xor ah, ah
- mov al, cs:[_curr_col]
+ cmp byte ptr [si], '%'
+ jne .L85
- xor dx, dx
+ inc si
- mov cl, ch
- xor ch, ch
+ cmp byte ptr [si], 0
+ jne .L86
- add ax, cx
+ mov al, '%'
+ stosb
- mov di, offset _scratch
- add di, cx
+ jmp .L87
+
+.L86:
+
+ cmp byte ptr [si], '%'
+ je .L85
- mov cx, 80
- div cx
+ mov ax, '%'
+ push ax
- mov dh, cs:[_curr_row]
- add dh, al
+ push si
- mov ax, HEX (0200)
- xor bx, bx
- int HEX (10)
+ call _strchr
+ add sp, 4
- pop dx
- pop cx
- pop bx
- pop ax
-
-.L67:
-
- call _history_up
- jmp .L11
+ and ax, ax
+ jnz .L88
+
+ ;mov al, '%'
+ ;stosb
+
+ jmp .L87
-.L2:
+.L88:
- and ch, ch
- jz .L66
+ mov bx, ax
+ mov byte ptr [bx], 0
- push ax
- push bx
- push cx
- push dx
+ push si
- xor ah, ah
- mov al, cs:[_curr_col]
+ call _get_env
+ add sp, 2
- xor dx, dx
+ and ax, ax
+ jz .L89
- mov cl, ch
- xor ch, ch
+ push si
+ push ds
- add ax, cx
+ mov ds, ax
+ xor si, si
- mov di, offset _scratch
- add di, cx
+ mov ax, [si + 2]
+ mov ds, ax
+
+.L94:
+
+ mov cx, di
+ sub cx, dx
- mov cx, 80
- div cx
+ cmp cx, 255
+ jae .L95
- mov dh, cs:[_curr_row]
- add dh, al
+ lodsb
- mov ax, HEX (0200)
- xor bx, bx
- int HEX (10)
+ and al, al
+ jz .L95
- pop dx
- pop cx
- pop bx
- pop ax
+ stosb
+ jmp .L94
-.L66:
+.L95:
- call _history_down
- jmp .L11
+ pop ds
+ pop si
+
+ jmp .L84
-.L75:
+.L89:
- and ch, ch
- jz .L11
-
- push ax
- push bx
- push cx
- push dx
-
- xor ah, ah
- mov al, cs:[_curr_col]
-
- xor dx, dx
-
- mov cl, ch
- xor ch, ch
-
- add ax, cx
-
- mov di, offset _scratch
- add di, cx
-
- mov cx, 80
- div cx
-
- mov dh, cs:[_curr_row]
- add dh, al
-
- mov ax, HEX (0200)
- xor bx, bx
- int HEX (10)
-
- pop dx
- pop cx
- pop bx
- pop ax
+ mov si, bx
+ inc si
- jmp .L11
+ jmp .L87
-.L74:
+.L85:
- push ax
- push bx
- push cx
- push dx
-
- mov dh, cs:[_curr_row]
- mov dl, cs:[_curr_col]
-
- mov ax, HEX (0200)
- xor bx, bx
- int HEX (10)
-
- mov di, offset _scratch
+ movsb
+ jmp .L87
+
+.L84:
+
+ pop di
+ pop si
pop dx
pop cx
pop bx
pop ax
-
- jmp .L11
+ pop bp
+ ret
;******************************************************************************
-; @function _concat_exec
+; @function _format_path
;******************************************************************************
-_concat_exec:
+_format_path:
- push bp
- mov bp, sp
-
push ax
push bx
push cx
push dx
- push si
- push di
- push es
- mov ax, ds
- mov es, ax
+ mov dx, di
+ jmp short _format_path.loop
+
+_format_path.store:
+
+ stosb
- mov di, offset _full_path
+ cmp al, '\\'
+ jne _format_path.loop
+
+_format_path.skip:
+
+ lodsb
- mov si, word ptr [bp + 4]
- call _format_path
+ cmp al, '\\'
+ je _format_path.skip
- mov al, '\\'
- stosb
+ dec si
+
+_format_path.loop:
+
+ mov ax, di
+ sub ax, dx
- mov si, word ptr [bp + 6]
- call _format_path
+ cmp ax, 250
+ ja _format_path.done
- mov dx, offset _full_path
- inc bx
- mov di, bx
+ lodsb
- mov bx, offset _param_blk
+ and al, al
+ jz _format_path.done
- mov word ptr [bx + 2], di
- mov word ptr [bx + 4], ds
+ cmp al, 127
+ ja _format_path.done
- mov ax, HEX (4B00)
- int HEX (21)
+ cmp al, 32
+ jb _format_path.done
+
+ jmp short _format_path.store
-_concat_exec.done:
+_format_path.done:
- pop es
- pop di
- pop si
pop dx
pop cx
pop bx
pop ax
- pop bp
ret
;******************************************************************************
-; @function _get_env
+; @function _get_command
;******************************************************************************
-_get_env:
+_get_command:
push bp
+
mov bp, sp
+ sub sp, 2
- push bx
- push cx
- push dx
push si
- push di
- push es
-
- mov si, cs:[_vec_env]
- mov cx, cs:[_vec_env + 4]
+ push ax
+ push dx
- mov es, si
- xor di, di
+ mov word ptr [bp - 2], 0
+ mov si, offset _formatted_command
-.L91:
+_get_command.loop:
- and cx, cx
- jz .L92
+ lodsb
- push es
- mov ax, es:[di]
+ and al, al
+ jz _get_command.done
- mov es, ax
- push es
+ cmp al, ' '
+ jbe _get_command.null
- xor bx, bx
- mov ax, es:[bx]
+ cmp al, ':'
+ je _get_command.not_internal
- push cx
- push es
- push ds
+ cmp al, '\\'
+ je _get_command.not_internal
- mov cx, ds
- mov es, cx
- mov ds, ax
+ cmp al, '.'
+ je _get_command.not_internal
+
+_get_command.check:
+
+ xor ah, ah
- push es
- push di
+ mov dx, ax
+ push dx
- mov di, offset _temp
- xor al, al
-
- mov cx, 255
- rep stosb
-
- pop di
- pop es
-
- xor ax, ax
- push ax
-
- mov ax, offset _temp
- push ax
-
- call _strcpy
- add sp, 4
-
- pop ds
-
- mov ax, ds
- mov es, ax
-
- mov ax, word ptr [bp + 4]
- push ax
-
- mov ax, offset _temp
- push ax
-
- call _strcmp
- add sp, 4
-
- pop es
- pop cx
+ call _isalpha
+ add sp, 2
and ax, ax
- jz .L93
+ jz _get_command.loop
- pop ax
- pop es
+ push dx
- add di, 2
- dec cx
+ call _tolower
+ add sp, 2
- jmp .L91
+ mov [si - 1], al
+ jmp _get_command.loop
-.L93:
+_get_command.not_internal:
- pop ax
- pop es
-
- jmp .L90
+ mov word ptr [bp - 2], 1
+ jmp _get_command.loop
-.L92:
+_get_command.null:
- xor ax, ax
+ mov byte ptr [si - 1], 0
-.L90:
+_get_command.done:
- pop es
- pop di
- pop si
+ mov bx, word ptr [bp - 2]
+
pop dx
- pop cx
- pop bx
+ pop ax
+ pop si
+
+ add sp, 2
+ clc
+
pop bp
+
+ and bx, bx
+ jz _get_command.ret
+
+ stc
+
+_get_command.ret:
+
+ mov bx, offset _formatted_command
ret
;******************************************************************************
-; @function _expand_vars
+; @function _handle_backspace
;******************************************************************************
-_expand_vars:
+_handle_backspace:
- push bp
- mov bp, sp
+ and ch, ch
+ jz .L12
+
+ xor ah, ah
+ mov al, cs:[_curr_col]
- push ax
push bx
push cx
push dx
- push si
- push di
- mov di, word ptr [bp + 6]
- mov si, word ptr [bp + 4]
+ xor dx, dx
- mov dx, di
-
-.L87:
-
- cmp byte ptr [si], 0
- je .L84
+ mov cl, ch
+ xor ch, ch
- mov cx, di
- sub cx, dx
+ add ax, cx
- cmp cx, 255
- jae .L84
+ mov cx, 80
+ div cx
- cmp byte ptr [si], '%'
- jne .L85
+ xchg ax, dx
+ pop dx
+ pop cx
+ pop bx
- inc si
+ and ax, ax
+ jnz .L13
- cmp byte ptr [si], 0
- jne .L86
+ push ax
+ push bx
+ push dx
+ push cx
- mov al, '%'
- stosb
+ mov ax, HEX (0300)
+ xor bx, bx
+ int HEX (10)
- jmp .L87
-
-.L86:
-
- cmp byte ptr [si], '%'
- je .L85
+ pop cx
+ dec dh
- mov ax, '%'
- push ax
+ mov ax, HEX (0200)
+ xor bx, bx
+ mov dl, HEX (50)
+ int HEX (10)
- push si
+ call _erase_char
- call _strchr
- add sp, 4
+ mov ax, HEX (0200)
+ xor bx, bx
+ mov dl, HEX (4F)
+ int HEX (10)
- and ax, ax
- jnz .L88
+ pop dx
+ pop bx
+ pop ax
- ;mov al, '%'
- ;stosb
+ dec ch
+ dec di
- jmp .L87
+ mov byte ptr es:[di], 0
+ ret
-.L88:
+.L13:
- mov bx, ax
- mov byte ptr [bx], 0
+ call _erase_char
- push si
+ dec ch
+ dec di
- call _get_env
- add sp, 2
+ mov byte ptr es:[di], 0
+
+.L12:
+
+ ret
+
+;******************************************************************************
+; @function _handler_cls
+;******************************************************************************
+_handler_cls:
+
+ mov ax, HEX (0600)
+ mov bh, HEX (07)
+ xor cx, cx
+ mov dx, HEX (184F)
+ int HEX (10)
- and ax, ax
- jz .L89
+ mov ax, HEX (0200)
+ xor bx, bx
+ xor dx, dx
+ int HEX (10)
+ ret
+
+;******************************************************************************
+; @function _handler_echo
+;******************************************************************************
+_handler_echo:
+
+ push ax
+ push dx
push si
- push ds
-
- mov ds, ax
- xor si, si
- mov ax, [si + 2]
- mov ds, ax
+ mov si, bx
-.L94:
+_handler_echo.check:
- mov cx, di
- sub cx, dx
-
- cmp cx, 255
- jae .L95
+ cmp word ptr cs:[_cbreak], 1
+ je _handler_echo.done
lodsb
and al, al
- jz .L95
+ jz _handler_echo.newline
- stosb
- jmp .L94
-
-.L95:
-
- pop ds
- pop si
-
-.L89:
-
- mov si, bx
- inc si
+ mov ah, HEX (02)
+ mov dl, al
+ int HEX (21)
- jmp .L87
+ jmp _handler_echo.check
-.L85:
+_handler_echo.newline:
- movsb
- jmp .L87
+ mov ah, HEX (02)
+ mov dl, HEX (0D)
+ int HEX (21)
+
+ mov ah, HEX (02)
+ mov dl, HEX (0A)
+ int HEX (21)
-.L84:
+_handler_echo.done:
- pop di
pop si
pop dx
- pop cx
- pop bx
pop ax
- pop bp
ret
;******************************************************************************
-; @function _format_path
+; @function _handler_help
;******************************************************************************
-_format_path:
+_handler_help:
push ax
push bx
- push cx
- push dx
+ push ds
- mov dx, di
- jmp short _format_path.loop
+ mov ax, cs
+ mov ds, ax
+
+ mov bx, offset _handler_help.msg
+ call _writestr
-_format_path.store:
+_handler_help.done:
- stosb
+ pop ds
+ pop bx
+ pop ax
+ ret
+
+_handler_help.msg:
+
+ db "CD Change the current directory to the specified path.", HEX (0D), HEX (0A)
+ db "CLS Clears the screen.", HEX (0D), HEX (0A)
+ db "DATE Displays the system date.", HEX (0D), HEX (0A)
+ db "DEL Delete the specified files.", HEX (0D), HEX (0A)
+ db "DIR Displays a list of files and subdirectories in a directory.", HEX (0D), HEX (0A)
+ db "ECHO Specifies the text to display to the screen.", HEX (0D), HEX (0A)
+ db "EXIT Exit the current shell if it's not the last instance.", HEX (0D), HEX (0A)
+ db "MKDIR Create a new directory.", HEX (0D), HEX (0A)
+ db "REBOOT Reboots the machine.", HEX (0D), HEX (0A)
+ db "RMDIR Delete an empty directory.", HEX (0D), HEX (0A)
+ db "SET Display, enable or disable environment variables.", HEX (0D), HEX (0A)
+ db "TIME Displays the system time.", HEX (0D), HEX (0A)
+ db "TOUCH Create a new file if it doesn't already exist.", HEX (0D), HEX (0A)
+ db "TYPE Displays the contents of a text file.", HEX (0D), HEX (0A)
- cmp al, '\\'
- jne _format_path.loop
+ db HEX (00)
-_format_path.skip:
+;******************************************************************************
+; @function _handler_reboot
+;******************************************************************************
+_handler_reboot:
- lodsb
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ ;; Disable interrupts.
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ cli
- cmp al, '\\'
- je _format_path.skip
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ ;; Stop floppy motor.
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ mov dx, HEX (03F2)
+ xor al, al
+ out dx, al
- dec si
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ ;; Reset console.
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ mov ax, HEX (0003)
+ int HEX (10)
+
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ ;; Cold reboot.
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ xor ax, ax
+ mov es, ax
+
+ mov bx, HEX (0472)
+ mov word ptr es:[bx], 0
+
+ jmp HEX (F000) : HEX (FFF0)
-_format_path.loop:
+;******************************************************************************
+; @function _process_line
+;******************************************************************************
+global _process_line
+_process_line:
- mov ax, di
- sub ax, dx
+ push bp
+ mov bp, sp
- cmp ax, 250
- ja _format_path.done
+ push ax
+ push bx
+ push cx
+ push dx
+ push si
+ push di
+ push es
+ push ds
+
+ mov ax, cs
+ mov es, ax
+
+.L102:
+
+ mov di, offset _formatted_command
+ push di
+
+ xor al, al
+
+ mov cx, 255
+ rep stosb
+
+ mov bx, word ptr [bp + 4]
+ push bx
+
+ call _expand_vars
+ add sp, 4
+
+ mov ax, cs
+ mov ds, ax
+
+ mov bx, offset _formatted_command
+
+ call _get_command
+ jc .L23
+
+ mov si, bx
+ xor ax, ax
lodsb
and al, al
- jz _format_path.done
+ jz .L101
- cmp al, 127
- ja _format_path.done
+ push bx
+ xor bx, bx
- cmp al, 32
- jb _format_path.done
+ or al, HEX (20)
+ mov bl, al
+
+.L28:
+
+ lodsb
- jmp short _format_path.store
+ or al, al
+ jz .L31
+
+ mov cl, 5
+ rol bx, cl
+
+ or al, HEX (20)
+ xor bx, ax
+
+ jmp .L28
-_format_path.done:
+.L31:
- pop dx
- pop cx
+ mov di, bx
pop bx
- pop ax
- ret
+
+ mov si, offset _cmd_table
+ mov cx, offset _cmd_count
-;******************************************************************************
-; @function _get_command
-;******************************************************************************
-_get_command:
+.L29:
- push bp
+ lodsw
- mov bp, sp
- sub sp, 2
+ cmp di, ax
+ je .L30
- push si
- push ax
- push dx
+ lodsw
+ lodsw
+ loop .L29
- mov word ptr [bp - 2], 0
- mov si, offset _formatted_command
+ jmp .L23
-_get_command.loop:
+.L30:
- lodsb
+ push bx
- and al, al
- jz _get_command.done
+ call _strlen
+ add sp, 2
- cmp al, ' '
- jbe _get_command.null
+ add bx, ax
+ inc bx
+
+.L33:
+
+ cmp byte ptr [bx], 0
+ je .L32
- cmp al, ':'
- je _get_command.not_internal
+ cmp byte ptr [bx], ' '
+ ja .L32
- cmp al, '\\'
- je _get_command.not_internal
+ inc bx
+ jmp .L33
+
+.L32:
+
+ lodsw
- cmp al, '.'
- je _get_command.not_internal
+ call cs:[si]
+ jmp .L101
-_get_command.check:
+.L23:
- xor ah, ah
+ mov di, offset _app_path
- mov dx, ax
- push dx
+ mov ax, '\\'
+ push ax
- call _isalpha
- add sp, 2
+ mov si, bx
+ push bx
+
+ call _strrchr
+ add sp, 4
and ax, ax
- jz _get_command.loop
+ jz .L27
- push dx
+ mov bx, ax
+ mov byte ptr [bx], 0
- call _tolower
- add sp, 2
+ call _format_path
- mov [si - 1], al
- jmp _get_command.loop
-
-_get_command.not_internal:
-
- mov word ptr [bp - 2], 1
- jmp _get_command.loop
-
-_get_command.null:
-
- mov byte ptr [si - 1], 0
+ mov al, '\\'
+ stosb
+
+ inc bx
-_get_command.done:
+.L27:
- mov bx, word ptr [bp - 2]
-
- pop dx
- pop ax
- pop si
-
- add sp, 2
- clc
+ mov ax, '.'
+ push ax
- pop bp
+ mov si, bx
+ push bx
- and bx, bx
- jz _get_command.ret
+ call _strrchr
+ add sp, 4
- stc
-
-_get_command.ret:
-
- mov bx, offset _formatted_command
- ret
+ and ax, ax
+ jnz .L24
-;******************************************************************************
-; @function _handle_backspace
-;******************************************************************************
-_handle_backspace:
+.L26:
- and ch, ch
- jz .L12
+ push bx
- xor ah, ah
- mov al, cs:[_curr_col]
+ call _strlen
+ add sp, 2
- push bx
- push cx
- push dx
+ mov cx, ax
+ rep movsb
- xor dx, dx
+ mov word ptr cs:[_need_ext], 1
+ add bx, ax
- mov cl, ch
- xor ch, ch
+ push di
- add ax, cx
+ mov al, '.'
+ stosb
- mov cx, 80
- div cx
+ mov al, 'c'
+ stosb
- xchg ax, dx
- pop dx
- pop cx
- pop bx
+ mov al, 'o'
+ stosb
- and ax, ax
- jnz .L13
+ mov al, 'm'
+ stosb
+ jmp .L25
+
+.L24:
+
push ax
push bx
- push dx
- push cx
- mov ax, HEX (0300)
- xor bx, bx
- int HEX (10)
+ call _strlen
+ add sp, 2
- pop cx
- dec dh
+ mov cx, ax
+ rep movsb
- mov ax, HEX (0200)
- xor bx, bx
- mov dl, HEX (50)
- int HEX (10)
+ add bx, ax
+
+.L25:
+
+ xor al, al
+ stosb
- call _erase_char
+ mov word ptr cs:[_in_batch], 0
- mov ax, HEX (0200)
- xor bx, bx
- mov dl, HEX (4F)
- int HEX (10)
+ mov ax, offset _ext_batch
+ push ax
- pop dx
- pop bx
- pop ax
+ call _strcmp
+ add sp, 4
- dec ch
- dec di
+ and ax, ax
+ jnz .L104
- mov byte ptr es:[di], 0
- ret
+ mov word ptr cs:[_in_batch], 1
+
+ mov ax, 1
+ push ax
+
+ mov ax, offset _app_path
+ push ax
+
+ call _read_batch
+ jc .L107
+
+ add sp, 4
+ jmp .L101
-.L13:
+.L104:
- call _erase_char
+ push bx
- dec ch
- dec di
+ mov dx, offset _app_path
+ inc bx
+ mov di, bx
- mov byte ptr es:[di], 0
+ mov bx, offset _param_blk
+
+ mov word ptr [bx + 2], di
+ mov word ptr [bx + 4], ds
+
+ mov ax, HEX (4B00)
+ int HEX (21)
+ pop bx
+ jnc .L101
+
+ jmp .L103
-.L12:
+.L107:
- ret
+ add sp, 4
-;******************************************************************************
-; @function _handler_cls
-;******************************************************************************
-_handler_cls:
+.L103:
- mov ax, HEX (0600)
- mov bh, HEX (07)
- xor cx, cx
- mov dx, HEX (184F)
- int HEX (10)
+ mov ax, '\\'
+ push ax
- mov ax, HEX (0200)
- xor bx, bx
- xor dx, dx
- int HEX (10)
+ mov ax, offset _app_path
+ push ax
- ret
+ call _strrchr
+ add sp, 4
+
+ and ax, ax
+ jnz .L98
-;******************************************************************************
-; @function _handler_echo
-;******************************************************************************
-_handler_echo:
+.L99:
+ call _get_paths
+
push ax
- push dx
- push si
+ push bx
+ push cx
+ push di
+ push es
- mov si, bx
+ mov ax, cs:[_vec_paths]
+ mov es, ax
+ mov cx, cs:[_vec_paths + 4]
+
+ xor di, di
-_handler_echo.check:
+.L96:
- cmp word ptr cs:[_cbreak], 1
- je _handler_echo.done
+ and cx, cx
+ jz .L97
- lodsb
+ mov ax, offset _app_path
+ push ax
- and al, al
- jz _handler_echo.newline
+ mov ax, es:[di]
+ push ax
- mov ah, HEX (02)
- mov dl, al
- int HEX (21)
+ cmp word ptr cs:[_in_batch], 1
+ jne .L105
- jmp _handler_echo.check
+ call _concat_read
+ jnc .L100
+ add sp, 4
+
+ add di, 2
+ dec cx
+
+ jmp .L96
-_handler_echo.newline:
+.L105:
- mov ah, HEX (02)
- mov dl, HEX (0D)
- int HEX (21)
+ call _concat_exec
+ jnc .L100
+ add sp, 4
+
+ add di, 2
+ dec cx
+
+ jmp .L96
+
+.L100:
+
+ add sp, 4
- mov ah, HEX (02)
- mov dl, HEX (0A)
- int HEX (21)
+ pop es
+ pop di
+ pop cx
+ pop bx
+ pop ax
+
+ jmp .L101
-_handler_echo.done:
+.L97:
- pop si
- pop dx
+ pop es
+ pop di
+ pop cx
+ pop bx
pop ax
- ret
-;******************************************************************************
-; @function _handler_help
-;******************************************************************************
-_handler_help:
+.L98:
+ mov bx, offset _err_invalid
+ call _writestr
+
+ cmp word ptr cs:[_need_ext], 1
+ jb .L34
+
+ mov ax, '.'
push ax
+
+ mov bx, offset _app_path
push bx
- push ds
- mov ax, cs
- mov ds, ax
+ call _strrchr
+ add sp, 4
- mov bx, offset _handler_help.msg
+ mov bx, ax
+ mov byte ptr [bx], 0
+
+.L34:
+
+ mov bx, offset _app_path
call _writestr
+ call _crlf
-_handler_help.done:
+.L101:
pop ds
+ pop es
+ pop di
+ pop si
+ pop dx
+ pop cx
pop bx
pop ax
+ pop bp
ret
-_handler_help.msg:
-
- db "CD Change the current directory to the specified path.", HEX (0D), HEX (0A)
- db "CLS Clears the screen.", HEX (0D), HEX (0A)
- db "DATE Displays the system date.", HEX (0D), HEX (0A)
- db "DEL Delete the specified files.", HEX (0D), HEX (0A)
- db "DIR Displays a list of files and subdirectories in a directory.", HEX (0D), HEX (0A)
- db "ECHO Specifies the text to display to the screen.", HEX (0D), HEX (0A)
- db "EXIT Exit the current shell if it's not the last instance.", HEX (0D), HEX (0A)
- db "MKDIR Create a new directory.", HEX (0D), HEX (0A)
- db "REBOOT Reboots the machine.", HEX (0D), HEX (0A)
- db "RMDIR Delete an empty directory.", HEX (0D), HEX (0A)
- db "SET Display, enable or disable environment variables.", HEX (0D), HEX (0A)
- db "TIME Displays the system time.", HEX (0D), HEX (0A)
- db "TOUCH Create a new file if it doesn't already exist.", HEX (0D), HEX (0A)
- db "TYPE Displays the contents of a text file.", HEX (0D), HEX (0A)
-
- db HEX (00)
-
-;******************************************************************************
-; @function _handler_reboot
-;******************************************************************************
-_handler_reboot:
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Disable interrupts.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- cli
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Stop floppy motor.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- mov dx, HEX (03F2)
- xor al, al
- out dx, al
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Reset console.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- mov ax, HEX (0003)
- int HEX (10)
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Cold reboot.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- xor ax, ax
- mov es, ax
-
- mov bx, HEX (0472)
- mov word ptr es:[bx], 0
-
- jmp HEX (F000) : HEX (FFF0)
-
;******************************************************************************
; @function _prompt
;******************************************************************************
pop ax
ret
+;******************************************************************************
+; @function _read_batch
+;******************************************************************************
+global _read_batch
+_read_batch:
+
+ push bp
+
+ mov bp, sp
+ sub sp, 6
+
+ push ax
+ push bx
+ push cx
+ push dx
+ push si
+ push di
+ push es
+ push ds
+
+ mov word ptr [bp - 6], 0
+ mov word ptr [bp - 4], 0
+ mov word ptr [bp - 2], 0
+
+_read_batch.open:
+
+ mov ax, offset _batch_flags
+ push ax
+
+ mov ax, word ptr [bp + 4]
+ push ax
+
+ call _fopen
+ add sp, 4
+
+ and ax, ax
+ jz _read_batch.err
+
+ mov word ptr [bp - 4], ax
+
+_read_batch.parse:
+
+ call _load_line_create_internal_data
+
+ and ax, ax
+ jz _read_batch.close
+
+ mov word ptr [bp - 2], ax
+
+_read_batch.read_line:
+
+ mov ax, word ptr [bp - 2]
+ push ax
+
+ mov ax, word ptr [bp - 4]
+ push ax
+
+ xor ax, ax
+ push ax
+ push ax
+
+ lea ax, word ptr [bp - 6]
+ push ax
+
+ call _load_line
+ add sp, 10
+
+ and ax, ax
+ jnz _read_batch.close
+
+ push ax
+ push bx
+ push ds
+
+ mov ax, word ptr [bp - 6]
+ mov ds, ax
+ xor bx, bx
+
+_read_batch.skip:
+
+ cmp byte ptr [bx], ' '
+ jne _read_batch.check
+
+ inc bx
+ jmp _read_batch.skip
+
+_read_batch.check:
+
+ cmp byte ptr [bx], HEX (0A)
+ je _read_batch.next
+
+ mov ax, ds
+ mov es, ax
+
+ mov di, bx
+ push di
+
+ call _strlen
+ add sp, 2
+
+ add di, ax
+ dec di
+
+ xor al, al
+ stosb
+
+ cmp word ptr [bp + 6], 0
+ je _read_batch.process
+
+ cmp byte ptr [bx], '@'
+ jne _read_batch.echo
+
+ inc bx
+
+_read_batch.skip2:
+
+ cmp byte ptr [bx], ' '
+ jne _read_batch.process
+
+ inc bx
+ jmp _read_batch.skip2
+
+_read_batch.echo:
+
+ call _writestr
+ call _crlf
+
+_read_batch.process:
+
+ push bx
+
+ call _process_line
+ add sp, 2
+
+_read_batch.next:
+
+ pop ds
+ pop bx
+ pop ax
+
+ jmp _read_batch.read_line
+
+_read_batch.close:
+
+ push word ptr [bp - 4]
+
+ call _fclose
+ add sp, 2
+
+_read_batch.free:
+
+ mov ax, word ptr [bp - 2]
+
+ and ax, ax
+ jz _read_batch.done
+
+ push ax
+
+ call _load_line_destroy_internal_data
+ add sp, 2
+
+_read_batch.done:
+
+ pop ds
+ pop es
+ pop di
+ pop si
+ pop dx
+ pop cx
+ pop bx
+ pop ax
+
+ add sp, 6
+ clc
+
+ pop bp
+ ret
+
+_read_batch.err:
+
+ pop ds
+ pop es
+ pop di
+ pop si
+ pop dx
+ pop cx
+ pop bx
+ pop ax
+
+ add sp, 6
+ stc
+
+ pop bp
+ ret
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Includes.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_app_path: db 256 dup (0)
_param_blk: db 16 dup (0)
-_full_path: db 256 dup (0)
-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Error messages.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+_err_segmentation: db "Segmentation fault", HEX (0D), HEX (0A), HEX (00)
_err_invalid: db "Bad command or file name - ", HEX (00)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Data area.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_formatted_command: db 256 dup (0)
-_fn_wild: db "*.*", HEX (00)
+_full_path: db 256 dup (0)
_temp: db 257 dup (0)
+_autoexec: db "AUTOEXEC.BAT", HEX (00)
+_batch_flags: db "r", HEX (00)
+
+_in_batch: dw HEX (0000)
+_ext_batch: db ".bat", HEX (00)
+
+_ll_scratch: dw HEX (0000)
+_fn_wild: db "*.*", HEX (00)
+
_dta_addr: dw HEX (0000)
_insert: dw HEX (0000)