Add command line parsing
This commit is contained in:
parent
d157d8352b
commit
7af168618c
68
dosdl.asm
68
dosdl.asm
|
@ -9,9 +9,60 @@ args_area equ 0x81
|
||||||
section .code
|
section .code
|
||||||
|
|
||||||
parse_arguments:
|
parse_arguments:
|
||||||
; TODO: Implement argument parsing
|
|
||||||
xor ch, ch
|
xor ch, ch
|
||||||
mov cl, [args_length]
|
mov cl, [args_length]
|
||||||
|
mov si, args_area
|
||||||
|
|
||||||
|
; Skip leading spaces
|
||||||
|
.skip_leading_space:
|
||||||
|
test cx, cx
|
||||||
|
jz .leading_spaces_skipped
|
||||||
|
cmp byte [si], ' '
|
||||||
|
jne .leading_spaces_skipped
|
||||||
|
dec cx
|
||||||
|
inc si
|
||||||
|
jmp .skip_leading_space
|
||||||
|
|
||||||
|
.leading_spaces_skipped:
|
||||||
|
|
||||||
|
; See whether we have /h or /u
|
||||||
|
cmp cx, 2
|
||||||
|
jb .not_mode_option
|
||||||
|
cmp byte [si], '/'
|
||||||
|
jne .not_mode_option
|
||||||
|
|
||||||
|
cmp byte [si + 1], 'h'
|
||||||
|
jne .not_hard_mode
|
||||||
|
|
||||||
|
.hard_mode:
|
||||||
|
mov byte [hard_mode], 1
|
||||||
|
add si, 2
|
||||||
|
sub cx, 2
|
||||||
|
jmp .after_option_space
|
||||||
|
|
||||||
|
.not_hard_mode:
|
||||||
|
cmp byte [si + 1], 'u'
|
||||||
|
jne .not_ultra_hard_mode
|
||||||
|
|
||||||
|
.ultra_hard_mode:
|
||||||
|
mov byte [hard_mode], 1
|
||||||
|
mov byte [ultra_hard_mode], 1
|
||||||
|
add si, 2
|
||||||
|
sub cx, 2
|
||||||
|
|
||||||
|
.after_option_space:
|
||||||
|
test cx, cx
|
||||||
|
jz .option_done
|
||||||
|
cmp byte [si], ' '
|
||||||
|
jne .option_done
|
||||||
|
dec cx
|
||||||
|
inc si
|
||||||
|
jmp .after_option_space
|
||||||
|
|
||||||
|
.option_done:
|
||||||
|
|
||||||
|
.not_ultra_hard_mode:
|
||||||
|
.not_mode_option:
|
||||||
|
|
||||||
test cx, cx
|
test cx, cx
|
||||||
jz seed_rng_date
|
jz seed_rng_date
|
||||||
|
@ -243,10 +294,11 @@ check_targets:
|
||||||
loop .targets_loop
|
loop .targets_loop
|
||||||
|
|
||||||
word_not_found:
|
word_not_found:
|
||||||
|
mov si, not_found_str
|
||||||
|
|
||||||
|
print_error:
|
||||||
mov ah, 9
|
mov ah, 9
|
||||||
mov dx, space_dash_space_str
|
mov dx, si
|
||||||
int 0x21
|
|
||||||
mov dx, not_found_str
|
|
||||||
int 0x21
|
int 0x21
|
||||||
|
|
||||||
; Wait for a keypress
|
; Wait for a keypress
|
||||||
|
@ -262,7 +314,6 @@ word_not_found:
|
||||||
mov dx, erase_word_str
|
mov dx, erase_word_str
|
||||||
int 0x21
|
int 0x21
|
||||||
|
|
||||||
mov si, not_found_str
|
|
||||||
.clear_loop:
|
.clear_loop:
|
||||||
lodsb
|
lodsb
|
||||||
cmp al, '$'
|
cmp al, '$'
|
||||||
|
@ -274,7 +325,7 @@ word_not_found:
|
||||||
|
|
||||||
jmp .clear_loop
|
jmp .clear_loop
|
||||||
|
|
||||||
.done:
|
.done:
|
||||||
|
|
||||||
mov ah, 2
|
mov ah, 2
|
||||||
mov dl, 13
|
mov dl, 13
|
||||||
|
@ -780,6 +831,9 @@ guesses db 0
|
||||||
|
|
||||||
dictionary_entry times 5 db 0
|
dictionary_entry times 5 db 0
|
||||||
|
|
||||||
|
hard_mode db 0
|
||||||
|
ultra_hard_mode db 0
|
||||||
|
|
||||||
rng_seed dd 0
|
rng_seed dd 0
|
||||||
rng_t dd 0
|
rng_t dd 0
|
||||||
|
|
||||||
|
@ -801,7 +855,7 @@ section .rodata
|
||||||
greeting_str db 'Welcome to hello DOSdl. Run `dosdl /?` for help.', 13, 10, '$'
|
greeting_str db 'Welcome to hello DOSdl. Run `dosdl /?` for help.', 13, 10, '$'
|
||||||
|
|
||||||
space_dash_space_str db ' - $'
|
space_dash_space_str db ' - $'
|
||||||
not_found_str db 'word not found$'
|
not_found_str db ' - word not found$'
|
||||||
erase_word_str db ' $'
|
erase_word_str db ' $'
|
||||||
word_was_str db 'The word was: $'
|
word_was_str db 'The word was: $'
|
||||||
correct_in_str db 'Correct in $'
|
correct_in_str db 'Correct in $'
|
||||||
|
|
Loading…
Reference in New Issue