extern fopen
extern fread
extern fclose
extern printf
extern scanf
section .bss
;каждая строка 10 + 1 =11 11 округлим до 12 байт
;12 * 500 = 6000
dict resb 6000
temp_srt resb 12 ;временный буфер для чтения строки
unique_count resd 1 ;сколько уникальных строк
dict_size resd 1
now_size resd 1
N resd 1
section .data
fmt_scan db "10%s", 0
section .text
global main
check_equal: ;сравниваются равние строки
mov esi, temp_str
cmp edi, 0
jne .loop
inc edi
inc [now_size]
;edi - начало сравниваемой строки
;тут не нужен esp, так как не трогаем стек
.loop:
mov al, byte [esi] ; esi - temp_str
mov bl, byte [edi] ; edi - dict
cmp al, bl
jne .not_equal
cmp al, 0
je .equal
inc esi
inc edi
inc [now_size]
jmp .loop
.equal:
ret
.not_equal:
mov eax, [now_size]
cmp eax, [dict_size]
jge .copy_string
;надо узнать кол-во символов в dict
;чтобы написать copy_string
cmp edi, 0
je .check_edual
inc edi
inc [now_size]
jmp .not_equal
copy_string: ; dict push temp_str
; esi - temp_str
; edi - dict
mov byte[esi], temp_str
mov al, byte[esi]
mov byte[edi], al
cmp al, 0
je .done
inc esi
inc edi
inc [dict_size]
jmp copy_string
.done:
ret
main:
call io_get_dec
mov [N], eax
.resd_string:
;scanf("%10s", temp_str)
sub esp, 8
push temp_str
push fmt_scan
cmp eax, 1 ;проверяю заканчивается ли строка
jne .end
call scanf
add esp, 16
mov byte[edi], dict
call check_equal
jmp .read_string
.end:
mov eax, [unique_count]
call io_print_dec
xor eax, eax
ret