From a first glance your code seems about right. I find the line mov ecx,SIZEOF tString
a little suspicious, make sure that returns the size of your string - I fear it just returns the size of the pointer. (But that should make the count less not more.)
Also, during the write loop, make sure that the various functions you call don't change any registers you depend on, particularly eax
is in danger.
Otherwise you should use a debugger to check whether the produced result is correct so you can tell whether it's the Freq
function or your printing loop that's faulty. Having found that, you should step through that part to see where it goes wrong.
Update
Your freqTable
is apparently made up of dwords (4 bytes each) but your indexing uses 1-byte units. You'll have to change inc dword ptr[edi+eax]
into inc dword ptr[edi+eax*4]
in the counting loop, and similarly the mov ebx, [edi + eax]
into mov ebx, [edi + eax*4]
in the printing loop.