-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprints out the command line parameters.asm
63 lines (45 loc) · 1.27 KB
/
prints out the command line parameters.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
; this sample prints out the command line parameters.
; in dos you simply add this line after an executable, for example:
; paramexe p1 p2 p3
; it is possible to set parameter in emulator
; by selecting "set command line parameters" from the "file" menu.
name "paramexe"
data segment
msg db 'no command line parameters!', 0Dh,0Ah, '$'
ends
stack segment
db 20 dup(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov si, 80h ; cmd parameters offset.
; copy command line to our buffer:
xor cx, cx ; zero cx register.
mov cl, es:[si] ; get command line size.
cmp cx, 0 ; cx = 0 ?
jz no_param ; then skip the copy.
inc si ; start printing from second byte.
next_char:
mov al, es:[si]
mov ah, 0eh ; print out in teletype mode
int 10h
inc si
loop next_char
jmp exit ; skip error message.
no_param:
; print out the error message:
lea dx, msg
mov ah, 09h
int 21h
exit:
; wait for any key press...
mov ah, 0
int 16h
; return control to the operating system:
mov ah, 4ch
int 21h
ends
end start