I need to check whether good amount of arguments is given. Currently my program knows when there are no arguments and when there are more than two arguments given. If one is given, then it is bad, but my program doesn't recognise it. I can't do simple check because there is one possibility when it is allowed (when /? is argument) and cx changes with loop. For example, if I call it prog /?, it should print description, when I call it prog arg1 arg2, it should be allowed, but prog arg1 shouldn't. How can I check that?
mov ch, 0h
mov cl, [es:0080h]
push cx
cmp cx, 0
je print_description
mov bx, 81h
jmp search_help
jmp exit
search_help:
cmp [es:bx], '?/'
je print_description
inc bx
loop search_help
pop cx
cmp cx, 2
jne print_description
mov bx, 82h
mov si, offset input_filename
mov cx, 255
search_input_filename:
mov dl, [es:bx]
inc bx
cmp dl, 20h
je search_output_filename_prep
mov ds:[si], dl
inc si
loop search_input_filename
search_output_filename_prep:
mov si, offset output_filename
search_output_filename:
mov dl, [es:bx]
inc bx
cmp dl, 0Dh
je program
cmp dl, 20h
je print_description
mov ds:[si], dl
inc si
loop search_output_filename
Two errors:
1) My TASM 5.0 doesn't like
[ES:xxxx]
. The segment override has to be written asES:[xxxx]
.2)
ES:[0080h]
contains the length of the command line, not the count of the arguments. Thus this lines don't do what you think:You can use my
get_argc
function instead. Following test case works (hopefully):