Skip to content

Commit

Permalink
Site updated: 2024-11-23 16:44:08
Browse files Browse the repository at this point in the history
  • Loading branch information
duckcone committed Nov 23, 2024
1 parent de6fcbd commit c271e4a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions 2024/11/23/利用RDTSC量測時脈週期/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://hackmd.io/_uploads/SkCyz4qM1e.png">
<meta property="article:published_time" content="2024-11-23T08:15:36.000Z">
<meta property="article:modified_time" content="2024-11-23T08:29:36.894Z">
<meta property="article:modified_time" content="2024-11-23T08:43:34.895Z">
<meta property="article:author" content="Duck Cone">
<meta property="article:tag" content="Linux">
<meta property="article:tag" content="C">
Expand Down Expand Up @@ -244,7 +244,7 @@ <h1 class="post-title" itemprop="name headline">

<div class="post-body" itemprop="articleBody"><p>在進行程式的時間測量時,可以透過 <code>rdtsc</code> 指令取得時脈週期。 <code>rdtsc</code> 會返回 CPU 啟動之後所經歷的時脈週期數量,因此我們可以透過該指令在兩個區段相減過後的值來計算一段時間,例如量測執行一段程式碼所花費的時間。</p>
<span id="more"></span>
<p>在 CPU 啟動之後,會自動累積週期數,並且會將值紀錄在 EDX 和 EAX 暫存器, &#x3D;&#x3D;EDX 為高位元, EAX 為低位元&#x3D;&#x3D;</p>
<p>在 CPU 啟動之後,會自動累積週期數,並且會將值紀錄在 EDX 和 EAX 暫存器, <mark>EDX 為高位元, EAX 為低位元</mark></p>
<h1 id="EDX-和-EAX-暫存器"><a href="#EDX-和-EAX-暫存器" class="headerlink" title="EDX 和 EAX 暫存器"></a>EDX 和 EAX 暫存器</h1><p>暫存器分為 32 位元以及 64 位元暫存器。RDX 和 RAX 皆為 64 位元暫存器,對應的 EDX 與 EAX 則為 32 位元暫存器。32 位元和 64 位元暫存器並不是獨立的暫存器,以 RAX 與 EAX 為例, EAX 佔了 RAX 的低位 32 位元,<a target="_blank" rel="noopener" href="https://stackoverflow.com/questions/44972293/how-is-rax-different-from-eax">因此對 EAX 暫存器修改時也會影響到 RAX 暫存器。</a><br><img src="https://hackmd.io/_uploads/SkCyz4qM1e.png" alt="image"></p>
<blockquote>
<p>參考資料:<a target="_blank" rel="noopener" href="https://ithelp.ithome.com.tw/articles/10241159">Day6 - 為什麼要使用暫存器?</a></p>
Expand Down
2 changes: 1 addition & 1 deletion css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ pre code {
vertical-align: middle;
}
.links-of-author a::before {
background: #09ffff;
background: #28a34f;
display: inline-block;
margin-right: 3px;
transform: translateY(-2px);
Expand Down

0 comments on commit c271e4a

Please sign in to comment.