extern scanf, printf, strcmp, strcpy
section .data
fmt_n db "%u", 0
fmt_s db "%10s", 0
fmt_out db "%u", 10, 0
section .bss
n resd 1
i resd 1
j resd 1
unique_cnt resd 1
temp resb 11
strings resb 500 * 11
section .text
global main
main:
push ebp
mov ebp, esp
push n
push fmt_n
call scanf
add esp, 8
mov dword [unique_cnt], 0
mov dword [i], 0
read_loop:
mov eax, [i]
cmp eax, [n]
jge finish
push temp
push fmt_s
call scanf
add esp, 8
mov dword [j], 0
check_loop:
mov eax, [j]
cmp eax, [unique_cnt]
jge add_string
imul eax, 11
lea ebx, [strings + eax]
push temp
push ebx
call strcmp
add esp, 8
test eax, eax
jz already_exists
inc dword [j]
jmp check_loop
add_string:
mov eax, [unique_cnt]
imul eax, 11
lea ebx, [strings + eax]
push temp
push ebx
call strcpy
add esp, 8
inc dword [unique_cnt]
already_exists:
inc dword [i]
jmp read_loop
finish:
push dword [unique_cnt]
push fmt_out
call printf
add esp, 8
xor eax, eax
mov esp, ebp
pop ebp
ret