store_buff_nop.xm
来自「代码优化,有效使用内存,透视优化技术,对比优化方法,如果你在追求代码效率的最大化」· XM 代码 · 共 39 行
XM
39 行
; N_ITER EQU ? ;// <-- !auto gen!
; /*--------------------------------------------------------------------------
; *
; * macro that automatically duplicates its body N times
; *
; ---------------------------------------------------------------------------*/
STORE_BUFF MACRO N
_N = N
_A = 0
WHILE _A NE _N
NOP ; <-- MACRO BODY
_A = _A + 1
ENDM
ENDM
; /*--------------------------------------------------------------------------
; *
; * DEMONSTRATION OF BUFFER UNLOADING DURING BUS IDLE TIME
; *
; ---------------------------------------------------------------------------*/
MOV [ESI], ECX ; *p = a; <- here we write some value into *p
; <- first of all, this value
; <- goes to the store buffer
STORE_BUFF N_ITER ; ... <- one or more NOPs
; ... in parallel with NOP execution
; ... buffer contents is unloaded into L1 (AMD)
; ... or L2 (Intel) cache
MOV EDX, [ESI] ; b=*p; <- reading the contents of the *p cell
; if by that moment the buffer corresponding to it
; us not unloaded, it will be read as fast as
; possible; otherwise the delay would occur
ADD ESI, 32*20 ; (int)p+32 <- move the pointer to the next buffer
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?