|
Prev: It works... now what?
Next: Check out POASM
From: slover on 2 Jan 2006 07:45 Hello, I try to translate library written in Nasm to c-code, but I have problem with this construction: shmulti1: xor eax, eax lodsb mul bl movzx ecx, mult add eax, DWORD PTR out_text_m_index[ecx*4] push esi mov esi, eax rep movsb pop esi dec dx jnz SHORT shmulti1 out_text_m_index and out_text_m_table is define such as: out_text_m_index DD 00000h + OFFSET out_text_m_table DD 00009h + OFFSET out_text_m_table DD 00023h + OFFSET out_text_m_table out_text_m_table DB 000h DB 000h,000h,000h,000h DB 01Fh,000h,000h,03Fh DB 001h,0FFh,000h,00Ch Can you help me with meaning? Thank you Pavel Slavik
From: randyhyde@earthlink.net on 2 Jan 2006 11:11 Are there no comments telling you what this code is supposed to be doing? Cheers, Randy Hyde slover wrote: > Hello, > I try to translate library written in Nasm to c-code, but I have > problem with this construction: > > shmulti1: > xor eax, eax > lodsb > > mul bl > movzx ecx, mult > add eax, DWORD PTR out_text_m_index[ecx*4] > > push esi > mov esi, eax > rep movsb > pop esi > > dec dx > jnz SHORT shmulti1 > > out_text_m_index and out_text_m_table is define such as: > out_text_m_index DD 00000h + OFFSET out_text_m_table > DD 00009h + OFFSET out_text_m_table > DD 00023h + OFFSET out_text_m_table > > out_text_m_table DB 000h > DB 000h,000h,000h,000h > DB 01Fh,000h,000h,03Fh > DB 001h,0FFh,000h,00Ch > > Can you help me with meaning? > Thank you > Pavel Slavik
From: Herbert Kleebauer on 2 Jan 2006 16:00 slover wrote: > I try to translate library written in Nasm to c-code, but I have > problem with this construction: Doesn't make much sense. If ecx=0 is not allowed, then the first entry in out_text_m_index is not used and therefore the first 9 bytes in out_text_m_table are wasted. But if ecx=0 then "rep movsb" does nothing, so again the first 9 bytes in out_text_m_table are wasted. But a more interesting question for the NASM (or Intel syntax user): How do you know what the instruction "movzx ecx, mult" does? Is it a byte-to-long or a word-to-long move? What is "mult"? It can't be a constant and if it is an address, why isn't there a [mult] or BYTE PTR mult? Or is there somewhere in the source a line like %define mult [ebp+8] and without knowing this line you can't understand what "movzx ecx, mult" does? And that really is called assembly programming? > shmulti1: > xor eax, eax > lodsb > > mul bl > movzx ecx, mult > add eax, DWORD PTR out_text_m_index[ecx*4] > > push esi > mov esi, eax > rep movsb > pop esi > > dec dx > jnz SHORT shmulti1 > > out_text_m_index and out_text_m_table is define such as: > out_text_m_index DD 00000h + OFFSET out_text_m_table > DD 00009h + OFFSET out_text_m_table > DD 00023h + OFFSET out_text_m_table > > out_text_m_table DB 000h > DB 000h,000h,000h,000h > DB 01Fh,000h,000h,03Fh > DB 001h,0FFh,000h,00Ch
From: greg.johnston on 2 Jan 2006 17:45 "mult d[x] [y]" must be somewhere else in the source, assuming usual FASM/NASM-like behavior of the assembler. It looks like part of the difficulty with this code is that it's not complete (lack of shmult1 label, for example).
|
Pages: 1 Prev: It works... now what? Next: Check out POASM |