汇编语言中的低级别控制结构
1. 间接跳转表优化
在汇编语言中,为了让条件跳转指令保持简短,我们可以将大量字节的表移到程序的其他位置。以下是一个示例代码:
; Assume expression has been computed and is sitting in EAX/RAX
; at this point...
cmp eax, 100
jb try0_13
cmp eax, 103
ja try1000_1003
lea rcx, jt100
jmp qword ptr [rcx][rax * 8 – 100 * 8]
try0_13: cmp ecx, 13 ; Handle cases 0 to 13 here
ja defaultCase
lea rcx, jt0_13
jmp qword ptr [rcx][rax * 8]
try1000_1003:
cmp eax, 1000 ; Handle cases 1000 to 1003 here
jb defaultCase
cmp eax, 1003
ja defaultCase
lea rcx, jt1000
jmp qword ptr [rcx][rax * 8 – 1000 * 8]
defaultCase:
P
超级会员免费看
订阅专栏 解锁全文
1399

被折叠的 条评论
为什么被折叠?



