-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmdline.asm
110 lines (80 loc) · 2.5 KB
/
cmdline.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
; Simple command line examination routine.
.DOSSEG
.MODEL small, c, os_dos
.386
.CODE
INCLUDE constant.inc
; parse the command line
; entry: none
; exit: DS:DX to the 1st supplied item on the command line
; (other than an optional "/V" or "/v" before it)
; AH = "Y" if a "/V" or "/v" parameter was specified as the first parameter
; AH = "N" if no more than one parameter was specified
processCmdline proc public
push bx
push si
mov ah, 51h
int 21h
mov ds, bx
mov si, 80h
movzx bx, byte ptr[si]
add si, bx
inc si
mov byte ptr[si], NULL ;zero terminate
mov si, 81h
cmdlineloop:
lodsb
cmp al, NULL ; found end of line?
jz exitpc
cmp al, "/" ; found a slash?
jnz no_slash
call forward_slash_detected
no_slash:
cmp al, " " ; found a space?
jz cmdlineloop
; must be the filename here.
exitpc:
dec si ; point to start of filename
mov dx, si
pop si
pop bx
; Store the value of change_volume in AH before returning
push ds
mov ax,@data
mov ds,ax
mov ah,byte ptr[change_volume]
pop ds
ret
processCmdline endp
forward_slash_detected:
; read the character right after the slash
lodsb
cmp al, "v" ; /v ?
jz volume_change_requested
cmp al, "V" ; /V ?
jz volume_change_requested
jmp slash_parameter_evaluated
volume_change_requested:
push ds
push ax
push dx
; Print message acknowledging volume change request
lea dx, volume_change_requested_msg
mov ax,@data
mov ds,ax
mov ah, 9
int 21h
; Set change_volume variable to YES
mov byte ptr[change_volume],"Y"
pop dx
pop ax
pop ds
slash_parameter_evaluated:
; read the next character before returning
lodsb
ret
.DATA
volume_change_requested_msg db "Volume change requested.",CR,LF,"$"
; Variable that determines whether or not to adjust the sound output volume
change_volume db "N"
end