📄 cmdline.asm
字号:
;/*
; * Microsoft Confidential
; * Copyright (C) Microsoft Corporation 1991
; * All Rights Reserved.
; */
include bambi.inc
public parse_command_line
public display_status
zseg segment public 'CODE'
assume cs:zseg
;
; data from text.asm
;
extrn help_text :byte
extrn statistics1 :byte
extrn statistics2 :byte
extrn statistics3 :byte
extrn statistics4 :byte
extrn statistics5 :byte
extrn drivestring1 :byte
extrn drivestring2 :byte
extrn drivestring3 :byte
extrn msg_cannot_cache :byte
extrn bufferstring1 :byte
extrn bufferstring2 :byte
extrn bufferstring3 :byte
extrn extrastatus1 :byte
extrn extrastatus2 :byte
extrn extrastatus3 :byte
extrn extrastatus4 :byte
extrn extrastatus5 :byte
extrn magicdrvstring :byte
extrn whatsanasterisk :byte
;
; data from rdata.asm
;
extrn cache_block_bytes :word
extrn cache_block_words :word
extrn commitflag :byte
extrn dosinfo :word
;
; data from tdata.asm
;
extrn drives_to_cache :byte
extrn first_instance :byte
extrn number_of_cache_elements:word
extrn number_of_cache_elements_win:word
;
; routines from int2fini.asm
;
extrn call_bambi :near
extrn init_bambi_io :near
;
; routines from queueman.asm
;
extrn commit_all_dirty :near
;
; routines from bambi.asm
;
;
; data from bambinit.asm
;
extrn target_buffer_size :word
;
; routine from dec_out.asm
;
extrn display_dec_dword :near
;
; data from bambinit.asm
;
extrn dos_size :word
extrn win_size :word
;
; routines from drvtype.asm
;
extrn IsMagicDrive :near
extrn get_drive_type :near
;
; routines from logphys.asm
;
extrn logical_to_physical :near
extrn log_phys_list :byte
;
; routines from xms.asm
;
extrn query_free_xms_memory :near
extrn initialize_xms :near
;
; routines from stacker.asm
;
extrn detect_stacker :near
extrn detect_stacker_volume :near
extrn stacker_dd_pointer :near
display_asterisk_message db 0
be_quiet dw 1 ;default to quiet start up
load_low db 0
PUBLIC load_low
PUBLIC be_quiet
;locals
dos_size_done dw 0
extra_status db 0
init_command_line_parsing proc near
mov bx,COMMAND_LINE_OFFSET
clc
ret
init_command_line_parsing endp
at_eol proc near
cmp bx,COMMAND_LINE_OFFSET+MAX_COMMAND_LINE_LENGTH
jae is_at_eol
mov al,BYTE PTR es:[bx]
cmp al,COMMAND_LINE_TERMINATOR
je is_at_eol
clc
ret
is_at_eol:
;be sure future calls always return carry
mov bx,COMMAND_LINE_OFFSET+MAX_COMMAND_LINE_LENGTH
stc
ret
at_eol endp
get_next_char proc near
inc bx
call at_eol
jc eol
mov al,BYTE PTR es:[bx]
cmp al,COMMAND_LINE_TERMINATOR
je eol
clc
ret
eol:
stc
ret
get_next_char endp
ascii_to_hex proc near
cmp al,'9'
ja letter
cmp al,'0'
jb not_hex_char
sub al,'0'
clc
ret
letter:
cmp al,'F'
ja not_hex_char
cmp al,'A'
jb not_hex_char
sub al,'A'-10
clc
ret
not_hex_char:
stc
ret
ascii_to_hex endp
ascii_to_dec proc near
cmp al,'9'
ja not_dec
cmp al,'0'
jb not_dec
sub al,'0'
xor ah,ah
clc
ret
not_dec:
stc
ret
ascii_to_dec endp
;
; INPUT
; al = binary number
; OUTPUT
; ax = two ascci chars
;
hex_to_ascii proc near
push cx
mov ah,al
and al,0Fh
add al,90h
daa
adc al,40h
daa
xchg al,ah
mov cl,4
shr al,cl
add al,90h
daa
adc al,40h
daa
pop cx
ret
hex_to_ascii endp
;
; INPUT
; al = char to output
;
output_char proc near
push dx
push ax
mov dl,al
mov ah,2
int 21h
pop ax
pop dx
ret
output_char endp
parse_number proc near
xor cx,cx
call get_next_char ;get next digit in number
jc not_a_number
get_number:
call ascii_to_dec ;turn into binary number
jc get_number_done ;error means this is not a hex digit
; multiply accumlated value by 10
push dx
add cx,cx
mov dx,cx
add cx,cx
add cx,cx
add cx,dx
pop dx
add cx,ax ;add in this digit
call get_next_char ;get next digit in number
jc get_number_done
jmp short get_number
get_number_done:
clc
ret
not_a_number:
;stc
ret
parse_number endp
;
; INPUT
; DX:BX
; USES
; AX
display_hex_dword proc near
mov al,dh
call hex_to_ascii
call output_char
xchg al,ah
call output_char
mov al,dl
call hex_to_ascii
call output_char
xchg al,ah
call output_char
mov al,bh
call hex_to_ascii
call output_char
xchg al,ah
call output_char
mov al,bl
call hex_to_ascii
call output_char
xchg al,ah
call output_char
ret
display_hex_dword endp
display_status:
mov ax,BAMBI_GET_STATS
call call_bambi
cmp ax,BAMBI_SIGNATURE
je do_display_status
jmp display_help_text ;bug bug
do_display_status:
cmp be_quiet,0
je not_quiet
jmp done_stats
not_quiet:
push dx
mov dx,offset statistics1
mov ah,09h
int 21h
pop dx
cmp extra_status,0
je no_extra_status
push dx
mov dx,offset extrastatus1
mov ah,09h
int 21h
pop dx
mov ax,BAMBI_GET_INFO
call call_bambi
push cx
xor dx,dx
call display_dec_dword
push dx
mov dx,offset extrastatus2
mov ah,09h
int 21h
pop dx
pop cx
mov bx,cx
xor dx,dx
call display_dec_dword
push dx
mov dx,offset extrastatus3
mov ah,09h
int 21h
pop dx
mov ax,BAMBI_GET_STATS
call call_bambi
push di
push si
call display_dec_dword
mov dx,offset extrastatus4
mov ah,09h
int 21h
pop bx
pop dx
call display_dec_dword
push dx
mov dx,offset extrastatus5
mov ah,09h
int 21h
pop dx
no_extra_status:
push dx
mov dx,offset statistics2
mov ah,09h
int 21h
pop dx
mov ax,BAMBI_GET_INFO
call call_bambi
push cx
push dx
;calculate actual cache size by multiplying number*size
mov ax,cx
mul bx
mov bx,ax
call display_dec_dword
mov dx,offset statistics3
mov ah,09h
int 21h
pop dx
pop cx
mov ax,cx
mov bx,dx
mul bx
mov bx,ax
call display_dec_dword
push dx
mov dx,offset statistics4
mov ah,09h
int 21h
pop dx
push bp
push bx
push dx
mov bp,-1 ; start at unit zero,-1 for next inc
push bp
drive_loop:
pop bp
inc bp
push bp
cmp bp,26 ;bug bug
jb not_done_drives
jmp done_drives
not_done_drives:
push bp
mov dx,bp
call IsMagicDrive
pop bp
jz NotMagicDriveReadout
and bx,7Fh ;mask off all but host drive letter
push bx
mov dx,bx
call isMagicDrive
pop ax
jz notswappedhost
and bx,7Fh
jmp short isswappedhost
notswappedhost:
mov bx,ax
isswappedhost:
mov bp,bx
NotMagicDriveReadout:
mov ax,BAMBI_CACHE_DRIVE
xor dl,dl ; get cache state
call call_bambi
jnc not_done_drives2 ; bug bug
jmp done_drives
not_done_drives2:
test dl,80h ; read caching enabled?
jnz drive_loop
mov bx,offset drivestring2 ;yes,no
test dl,40h ; write caching enabled?
jnz read_cache_only
mov bx,offset drivestring1 ;yes,yes
read_cache_only:
pop dx ;get actual drive letter
push dx
mov byte ptr [bx+04],dl
add byte ptr [bx+04],'A'
mov byte ptr [bx+06],' '
cmp dx,bp ;remapped dblspace drive?
je noasterisk
mov cs:display_asterisk_message,1
mov byte ptr [bx+06],'*'
noasterisk:
push dx
mov dx,bx
mov ah,09h
int 21h
pop dx
push es
push di
push dx
mov dx,bp
; call logical_to_physical
push bx
mov bl,dl
xor bh,bh
mov dl,log_phys_list[bx]
pop bx
test dl,80h ;harddisk?
jz print_no
mov ax,MULT_BAMBI
mov bx,BAMBI_GET_BUFFER_INFO
int 2fh ;get pointer to safedsk's drive list
cmp ax,BAMBI_SIGNATURE
jne print_no
and dl,NOT 80h ;mask off high bit to get array index
xor bh,bh
mov bl,dl
;;;es:di points to safedsk table
cmp byte ptr es:[bx+di],-1
jne do_we_know
push dx
mov dx,offset bufferstring1
mov ah,09h
int 21h
pop dx
jmp short print_done
do_we_know:
cmp byte ptr es:[bx+di],0
je print_dont_know
print_no:
push dx
mov dx,offset bufferstring2
mov ah,09h
int 21h
pop dx
jmp short print_done
print_dont_know:
push dx
mov dx,offset bufferstring3
mov ah,09h
int 21h
pop dx
print_done:
pop dx
pop di
pop es
jmp drive_loop
done_drives:
pop bp ;pop off extra bp on stack from drive loop entry
pop dx
pop bx
pop bp
cmp cs:display_asterisk_message,1
jne no_asterisks
push dx
mov dx,offset whatsanasterisk
mov ah,09h
int 21h
pop dx
no_asterisks:
push dx
mov dx,offset statistics5
mov ah,09h
int 21h
pop dx
if 0
push dx
mov dx,offset statistics2
mov ah,09h
int 21h
pop dx
push bx
push dx
push cx
push di
push si
mov ax,BAMBI_GET_INFO
call call_bambi
;display block size
push bx
mov bx,cx
xor dx,dx
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -