diff --git a/defs.inc b/defs.inc index 94efb71..8d8773a 100644 --- a/defs.inc +++ b/defs.inc @@ -49,6 +49,8 @@ _AL = REG_RAX or _BYTE _EAX = REG_RAX or _DWORD _RAX = REG_RAX or _QWORD +_ECX = REG_RCX or _DWORD + _blue: .tib dq 0 .tib_len dd 0 diff --git a/dictionary.inc b/dictionary.inc index 1f5f344..73f01ee 100644 --- a/dictionary.inc +++ b/dictionary.inc @@ -58,6 +58,7 @@ macro _ose e { _core_words: .prev_word = 0 + _wi 'ecx', 3, se_reg_ecx, 0, 0 _wi 'eax', 3, se_reg_eax, 0, 0 .se_reg_latest = .prev_word @@ -146,9 +147,9 @@ _find_from: jne .next inc rdi - dec ecx - js .check_word - + dec cl + jnz .check_word + pop rax jmp .done @@ -426,3 +427,16 @@ se_reg_eax: stosb ret + +se_reg_ecx: + mov rax, _ECX + mov rdi, [_dictionary.here] + stosq + + mov rdi, [_dictionary.latest] + add rdi, 2 + mov al, byte [rdi] + inc al + stosb + + ret diff --git a/dictionary_test.inc b/dictionary_test.inc index bfdaf6a..282ecef 100644 --- a/dictionary_test.inc +++ b/dictionary_test.inc @@ -36,6 +36,24 @@ macro tc2 word, in_len, word_len { ok } +macro tc3 word, from { + mov [_blue.tib], _core_words.##word + _dictionary.word_offset + mov [_blue.tib_len], _core_words.##word + 1 + mov [_blue.tib_in], 0 + + t 'finds the expected word' + + call parser_next_word + + mov rdi, from + call _find_from + + cmp rax, _core_words.##word + jne failure + + ok +} + dictionary_test: call dictionary_init @@ -141,6 +159,12 @@ dictionary_test: tc1 word_d_comma, 2, _core_words.d_comma tc1 word_q_comma, 2, _core_words.q_comma tc1 word_base, 4, _core_words.base + + tc3 seX_o_parse, _core_words.se_parse_latest + tc3 seX_parse_end, _core_words.se_parse_latest + + tc3 se_reg_eax, _core_words.se_reg_latest + tc3 se_reg_ecx, _core_words.se_reg_latest call dictionary_deinit