<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120134</guid>
        <pubDate>Mon, 22 Apr 2002 23:25:22 +0000</pubDate>
        <title>Такты, время выполнения....</title>
        <link>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120134</link>
        <description><![CDATA[Kernel_Panic: Ну, блин.. Так недалеко и до RISC-овых машин. Типа: а выровняла ли ты на ночь адреса переменных, Дездемона??.. А если не выровняла - то полный, прошу пардону, писец ей, в виде страшных мук в аду процессорных исключений..<br><br>Короче, вот приблизительная инструкция по спариваемости (вы уж извините за двусмысленность слова) инструкций процессора (скомунизжено не помню откуда):<br><br><div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&#60;br&#62;Pairing Pentium Instructions&#60;br&#62;&#60;br&#62;1. Both instructions must be simple.&#60;br&#62;&#60;br&#62;2. Shifts or rotates can only pair in the U pipe. &#60;br&#62; &nbsp; (SHL, SHR, SAL, SAR, ROL, ROR, RCL or RCR)&#60;br&#62;&#60;br&#62;3. ADC and SBB can only pair in the U pipe.&#60;br&#62;&#60;br&#62;4. JMP, CALL and Jcc can only pair in the V pipe. (Jcc = jump on condition code).&#60;br&#62;&#60;br&#62;5. Neither instruction can contain BOTH a displacement and an immediate operand. For example:&#60;br&#62;&#60;br&#62;mov &nbsp; &nbsp; [bx+2], 3 &nbsp;; 2 is a displacement, 3 is immediate&#60;br&#62;mov &nbsp; &nbsp; mem1, 4 &nbsp; &nbsp;; mem1 is a displacement, 4 is immediate&#60;br&#62;&#60;br&#62;6. Prefixed instructions can only pair in the U pipe. This includes extended instructions that start with 0Fh except for the special case of the 16-bit conditional jumps of the 386 and above. Examples of prefixed instructions:&#60;br&#62;&#60;br&#62;mov &nbsp; &nbsp; ES:[bx],&#60;br&#62;mov &nbsp; &nbsp; eax, [si] &nbsp;; 32-bit operand in 16-bit code segment&#60;br&#62;mov &nbsp; &nbsp; ax, [esi] &nbsp;; 16-bit operand in 32-bit code segment&#60;br&#62;&#60;br&#62;7. The U pipe instruction must be only 1 byte in length or it will not pair until the second time it executes from the cache.&#60;br&#62;&#60;br&#62;8. There can be no read-after-write or write-after-write register dependencies between the instructions except for special cases for the flags register and the stack pointer (rules 9 and 10).&#60;br&#62;&#60;br&#62;mov &nbsp; &nbsp; ebx, 2 &nbsp; ; writes to EBX&#60;br&#62;add &nbsp; &nbsp; ecx, ebx ; reads EBX and ECX, writes to ECX&#60;br&#62; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; EBX is read after being written, no pairing&#60;br&#62;mov &nbsp; &nbsp; ebx, 1 &nbsp; ; writes to EBX&#60;br&#62;mov &nbsp; &nbsp; ebx, 2 &nbsp; ; writes to EBX&#60;br&#62; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; write after write, no pairing&#60;br&#62;&#60;br&#62;9. The flags register exception allows an ALU instruction to be paired with a Jcc even though the ALU instruction writes the flags and Jcc reads the flags. For example:&#60;br&#62;&#60;br&#62;cmp &nbsp; &nbsp; al, 0 &nbsp; &nbsp;; CMP modifies the flags&#60;br&#62;je &nbsp; &nbsp; &nbsp;addr &nbsp; &nbsp; ; JE reads the flags, but pairs&#60;br&#62;dec &nbsp; &nbsp; cx &nbsp; &nbsp; &nbsp; ; DEC modifies the flags&#60;br&#62;jnz &nbsp; &nbsp; loop1 &nbsp; &nbsp;; JNZ reads the flags, but pairs&#60;br&#62;&#60;br&#62;10. The stack pointer exception allows two PUSHes or two POPs to be paired even though they both read and write to the SP (or ESP) register.&#60;br&#62;&#60;br&#62;push &nbsp; &nbsp;eax &nbsp; &nbsp; &nbsp;; ESP is read and modified&#60;br&#62;push &nbsp; &nbsp;ebx &nbsp; &nbsp; &nbsp;; ESP is read and modified, but still pairs&#60;br&#62;&#60;br&#62;Simple Instructions (for Pentium pairing)&#60;br&#62;&#60;br&#62;The following is a list of simple instructions, as required by rule #1 above.&#60;br&#62;&#60;br&#62;Instruction format 16-bit example &nbsp; &nbsp; 32-bit example&#60;br&#62;------------------------------------------------------------&#60;br&#62;MOV reg, reg &nbsp; &nbsp; &nbsp; mov ax, bx &nbsp; &nbsp; &nbsp; &nbsp; mov eax, edx&#60;br&#62;MOV reg, mem &nbsp; &nbsp; &nbsp; mov ax, [bx] &nbsp; &nbsp; &nbsp; mov eax, [edx]&#60;br&#62;MOV reg, imm &nbsp; &nbsp; &nbsp; mov ax, 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mov eax, 1&#60;br&#62;MOV mem, reg &nbsp; &nbsp; &nbsp; mov [bx], ax &nbsp; &nbsp; &nbsp; mov [edx], eax&#60;br&#62;MOV mem, imm &nbsp; &nbsp; &nbsp; mov [bx], 1 &nbsp; &nbsp; &nbsp; &nbsp;mov [edx], 1&#60;br&#62;alu reg, reg &nbsp; &nbsp; &nbsp; &nbsp; add ax, bx &nbsp; &nbsp; &nbsp; &nbsp; cmp eax, edx&#60;br&#62;alu reg, mem &nbsp; &nbsp; &nbsp; add ax, [bx] &nbsp; &nbsp; &nbsp; cmp eax, [edx]&#60;br&#62;alu reg, imm &nbsp; &nbsp; &nbsp; add ax, 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cmp eax, 1&#60;br&#62;alu mem, reg &nbsp; &nbsp; &nbsp; add [bx], ax &nbsp; &nbsp; &nbsp; cmp [edx], eax&#60;br&#62;alu mem, imm &nbsp; &nbsp; &nbsp; add [bx], 1 &nbsp; &nbsp; &nbsp; &nbsp;cmp [edx], 1&#60;br&#62;&#60;br&#62;where alu = add, adc, and, or, xor, sub, sbb, cmp, test&#60;br&#62;&#60;br&#62;INC &nbsp;reg &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inc &nbsp;ax &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;inc &nbsp;eax&#60;br&#62;INC &nbsp;mem &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inc &nbsp;var1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;inc &nbsp;[eax]&#60;br&#62;DEC &nbsp;reg &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dec &nbsp;bx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dec &nbsp;ebx&#60;br&#62;DEC &nbsp;mem &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dec &nbsp;[bx] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dec &nbsp;var2&#60;br&#62;PUSH reg &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; push ax &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;push eax&#60;br&#62;POP &nbsp;reg &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pop &nbsp;ax &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pop &nbsp;eax&#60;br&#62;LEA &nbsp;reg, mem &nbsp; &nbsp; &nbsp;lea &nbsp;ax, [si+2] &nbsp; &nbsp;lea &nbsp;eax, [eax+4*esi+8]&#60;br&#62;JMP &nbsp;near &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;jmp &nbsp;label &nbsp; &nbsp; &nbsp; &nbsp; jmp &nbsp;lable2&#60;br&#62;CALL near &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;call proc &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;call proc2&#60;br&#62;Jcc &nbsp;near &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;jz &nbsp; lbl &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jnz &nbsp;lbl2&#60;br&#62;&#60;br&#62;where Jcc = ja, jae, jb, jbe, jg, jge, jl, jle, je, jne, jc, js,&#60;br&#62; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;jnp, jo, jp, jnbe, jnb, jnae, jna, jnle, jnl, jnge,&#60;br&#62; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;jng, jz, jnz, jnc, jns, jpo, jno, jpe&#60;br&#62;&#60;br&#62;NOP &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nop &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nop&#60;br&#62;shift reg, 1 &nbsp; &nbsp; &nbsp; shl &nbsp;ax, 1 &nbsp; &nbsp; &nbsp; &nbsp; rcl &nbsp;eax, 1&#60;br&#62;shift mem, 1 &nbsp; &nbsp; &nbsp; shr &nbsp;[bx], 1 &nbsp; &nbsp; &nbsp; rcr &nbsp;[ebx], 1&#60;br&#62;shift reg, imm &nbsp; &nbsp; sal &nbsp;ax, 2 &nbsp; &nbsp; &nbsp; &nbsp; rol &nbsp;esi, 2&#60;br&#62;shift mem, imm &nbsp; &nbsp; sar &nbsp;ax, 15 &nbsp; &nbsp; &nbsp; &nbsp;ror &nbsp;[esi], 31&#60;br&#62;&#60;br&#62;where shift = shl, shr, sal, sar, rcl, rcr, rol, ror&#60;br&#62;&#60;br&#62;Notes:&#60;br&#62;&#60;br&#62;rcl and rcr are not pairable with immediate counts other than 1&#60;br&#62;all memory-immediate (mem, imm) instructions are not pairable with a displacement in the memory operand&#60;br&#62;instructions with segment registers are not pairable.&#60;br&#62;</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script>]]></description>
        <author>Kernel_Panic</author>
        <category>Assembler</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120133</guid>
        <pubDate>Mon, 22 Apr 2002 17:30:18 +0000</pubDate>
        <title>Такты, время выполнения....</title>
        <link>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120133</link>
        <description><![CDATA[server_mouse: Да, 'за один такт' -- выражение образное. Команды-то будут выполняться вместе, но вот если один из операндов одной из команд находится в памяти и почему-то незакэшировался -- получи 2-5 тактов штрафа. Нюансов там ещё много...]]></description>
        <author>server_mouse</author>
        <category>Assembler</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120132</guid>
        <pubDate>Mon, 22 Apr 2002 17:18:47 +0000</pubDate>
        <title>Такты, время выполнения....</title>
        <link>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120132</link>
        <description><![CDATA[server_mouse: Ну ссылку не скажу - не знаю. Но есть у меня тетрадка, куда я в раннем младенчестве сию инфу передрал. Вот коротенький её пример:<br><br>ADC PU<br>ADD UV<br>AND UV<br>CALL PV<br>CMP UV<br>DEC UV<br>INC UV<br><br>... и гэтак далей.<br>Что сие означает. Есть 2 конвейера -- U и V.<br>PU - команда парабельна с конвейером U<br>PV - команда парабельна с конвейером V<br>UV - команда парабельна с любым конвейером.<br><br>Например:<br>ADD ax,bx<br>AND &nbsp;cx,1<br>выполнятся за один такт, поскольку полностью парабельны.<br><br>ADC ax,bx<br>CALL [bx] <br>тоже за один проход. ADC парабельна для U, а CALL для V<br><br>И т.д. в том же духе....<br>Я точно не помню, там вроде были ограничения на то, что бы команды не изменяли одни и теже регистры... это надо уточнить.]]></description>
        <author>server_mouse</author>
        <category>Assembler</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120131</guid>
        <pubDate>Sat, 20 Apr 2002 17:58:12 +0000</pubDate>
        <title>Такты, время выполнения....</title>
        <link>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120131</link>
        <description><![CDATA[7in: Премного благодарен.......<br>Почитаем ;D]]></description>
        <author>7in</author>
        <category>Assembler</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120130</guid>
        <pubDate>Sat, 20 Apr 2002 03:54:30 +0000</pubDate>
        <title>Такты, время выполнения....</title>
        <link>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120130</link>
        <description><![CDATA[m: http://emanual.ru/download/1200.html]]></description>
        <author>m</author>
        <category>Assembler</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120129</guid>
        <pubDate>Wed, 17 Apr 2002 19:36:56 +0000</pubDate>
        <title>Такты, время выполнения....</title>
        <link>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120129</link>
        <description><![CDATA[7in: Может, адресок подскажете (про спаренности, пайпы и т.д)?<br><strong class='tag-b'>Мышки на сервере</strong>, ты про какой конвейер говоришь? Конвейер на пне?]]></description>
        <author>7in</author>
        <category>Assembler</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120128</guid>
        <pubDate>Wed, 17 Apr 2002 09:04:43 +0000</pubDate>
        <title>Такты, время выполнения....</title>
        <link>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120128</link>
        <description><![CDATA[server_mouse: Вообще есть ещё таблица парабельности команд. Для первого пня -- в два конвейера. Для других невидел.]]></description>
        <author>server_mouse</author>
        <category>Assembler</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120127</guid>
        <pubDate>Tue, 16 Apr 2002 20:41:41 +0000</pubDate>
        <title>Такты, время выполнения....</title>
        <link>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120127</link>
        <description><![CDATA[Kernel_Panic: Не знаю, у меня в мануалах написано, что rdtsc занимает от 20 до 24 циклов, а xchg ax,reg16 - 3 цикла. Может, в этом проблема?<br><br>В общем, две инструкции могут выполняться за один такт, если это простые инструкции, обе не содержат одновременно и явного адреса, и непосредственного значения.. И там ещё куча условий.. Поищи доки..]]></description>
        <author>Kernel_Panic</author>
        <category>Assembler</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120126</guid>
        <pubDate>Tue, 16 Apr 2002 19:56:36 +0000</pubDate>
        <title>Такты, время выполнения....</title>
        <link>https://forum.sources.ru/index.php?showtopic=14142&amp;view=findpost&amp;p=120126</link>
        <description><![CDATA[7in: Люди, скажите мне, пожалуйста, может ли за 1 такт выполниться несколько инструкций?<br><br><div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">.MODEL Tiny&#60;br&#62;.586&#60;br&#62;.CODE&#60;br&#62;ORG &nbsp; &nbsp; 100h&#60;br&#62;&#60;br&#62;rdtsc &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; macro&#60;br&#62; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;db &nbsp; &nbsp; &nbsp;0Fh,31h&#60;br&#62;endm&#60;br&#62;&#60;br&#62;Start:&#60;br&#62;&#60;br&#62; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cli&#60;br&#62; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rdtsc&#60;br&#62; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xchg &nbsp; &nbsp;cx,ax&#60;br&#62;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xor &nbsp; &nbsp; bx,bx&#60;br&#62; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rdtsc&#60;br&#62; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sub &nbsp; &nbsp; ax,cx&#60;br&#62; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sub &nbsp; &nbsp; ax,21h&#60;br&#62; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int &nbsp; &nbsp; 29h&#60;br&#62; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mov &nbsp; &nbsp; al,ah&#60;br&#62; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int &nbsp; &nbsp; 29h&#60;br&#62; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sti&#60;br&#62; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int &nbsp; &nbsp; 20h&#60;br&#62;&#60;br&#62;END Start</div></ol></div></div></div></div><br><br>Программа вычисляет число тактов со-процессора, прошедших между 2-мя <strong class='tag-b'>rdtsc</strong>. Из этого числа вычитается 21h (время выполнения xchg+rdtsc.... по крайней мере, у меня). Соответственно, на экран выводятся 2 нуля (2 байта с кодом 0). Но! Если раскомментировать <strong class='tag-b'>xor bx,bx</strong> выведутся два символа с кодом 0FFh (т.е. время выполнения <strong class='tag-b'>xor bx,bx</strong> = -1 такт). Что это за глюк?<br>А если <strong class='tag-b'>xor bx,bx</strong> заменить на 1 или 2 <strong class='tag-b'>xor ax,ax</strong>, то получится 0, а если на 3 раза по <strong class='tag-b'>xor ax,ax</strong>, то будет 1. Но! Если поставить 4 инструкции <strong class='tag-b'>xor ax,ax</strong>, то результат опять будет нулевым..... Как это понимать?<br><br><strong class='tag-b'>Kernel Panic</strong> что-то говорил о пайпах.... Можно поподробнее на эту тему?]]></description>
        <author>7in</author>
        <category>Assembler</category>
      </item>
	
      </channel>
      </rss>
	