- UID
- 74123
注册时间2014-2-24
阅读权限10
最后登录1970-1-1
周游历练
该用户从未签到
|
if...else..
伪指令形式 .if 条件表达式
表达式为"真"时执行的指令
[.else]
表达式为"假"时执行的指令
.endif
.if 条件表达式1
表达式1为"真"时执行的指令
[.elseif 条件表达式2]
表达式2为"真"时执行的指令
[.elseif 条件表达式3]
表达式3为"真"时执行的指令
...
[.else]
所有表达式为"假"时执行的指令
.endif
注意:关键字if/elseif/else/endif的前面有个小数点,如果不加小数点,就变成宏汇编中的条件汇编伪操作了,结果可是天差地别。
.if eax && (ebx >= dwX) || !(dwY != ecx)
mov esi,1
.elseif edx
mov esi,2
.elseif esi & 1
mov esi,3
.elseif ZERO? && CARRY?
mov esi,4
.endif
然后反汇编,得到了以下的汇编指令:
; .if eax
:00401000 0BC0 or eax, eax
:00401002 7408 je 0040100C
; (ebx >= dwX)
:00401004 3B1D00304000 cmp ebx, dword ptr [00403000]
:0040100A 7308 jnb 00401014
; (dwY != ecx)
:0040100C 390D04304000 cmp dword ptr [00403004], ecx
:00401012 7507 jne 0040101B
:00401014 BE01000000 mov esi, 00000001
:00401019 EB23 jmp 0040103E
; elseif edx
:0040101B 0BD2 or edx, edx
:0040101D 7407 je 00401026
:0040101F BE02000000 mov esi, 00000002
:00401024 EB18 jmp 0040103E
; elseif esi & 1
:00401026 F7C601000000 test esi, 00000001
:0040102C 7407 je 00401035
:0040102E BE03000000 mov esi, 00000003
:00401033 EB09 jmp 0040103E
; ZERO?
:00401035 7507 jne 0040103E
; CARRY?
:00401037 7305 jnb 0040103E
:00401039 BE04000000 mov esi, 00000004
:0040103E …(Windows环境下32位汇编语言程序设计(典藏版))
以下是一个C++程序分支语句反汇编之后的结果
00401500 push ebp
00401501 mov ebp,esp
00401503 sub esp,44h
00401506 push ebx
00401507 push esi
00401508 push edi
00401509 lea edi,[ebp-44h]
0040150C mov ecx,11h
00401511 mov eax,0CCCCCCCCh
00401516 rep stos dword ptr [edi] // 初始化
32: int x=3;
00401518 mov dword ptr [ebp-4],3 // 局部变量ebp-4赋值
33: if (5>x)
0040151F cmp dword ptr [ebp-4],5 // 局部变量和5比较
00401523 jge Grammar_if_else_if+45h (00401545) // 大于等于则跳向下一个个分支语句.否则继续向下执行
34: {
35: cout<<"小于"<<endl;
00401525 push offset @ILT+40(std::endl) (0040102d) // 相等则输出相等
0040152A push offset string "\xd0\xa1\xd3\xda" (00432034)
0040152F push offset std::cout (00439528)
00401534 call @ILT+170(std::operator<<) (004010af)
00401539 add esp,8
0040153C mov ecx,eax
0040153E call @ILT+120(std::basic_ostream<char,std::char_traits<char> >::operator<<) (0040107d)
36: }
37: else if (5<x)
00401543 jmp Grammar_if_else_if+89h (00401589) // 输出相等后直接跳向分支语句结束
00401545 cmp dword ptr [ebp-4],5 // 继续和5比较
00401549 jle Grammar_if_else_if+6Bh (0040156b) // 小于等于则跳向下一条分支语句处,否则继续向下执行
38: {
39: cout<<"大于"<<endl;
0040154B push offset @ILT+40(std::endl) (0040102d)
00401550 push offset string "\xb4\xf3\xd3\xda" (0043202c)
00401555 push offset std::cout (00439528)
0040155A call @ILT+170(std::operator<<) (004010af)
0040155F add esp,8
00401562 mov ecx,eax
00401564 call @ILT+120(std::basic_ostream<char,std::char_traits<char> >::operator<<) (0040107d)
40: }
41: else
00401569 jmp Grammar_if_else_if+89h (00401589) // 输出大于后直接跳向分支语句结束
42: {
43: cout<<"相等"<<endl;
0040156B push offset @ILT+40(std::endl) (0040102d) // 以上分支条件都不满足,则执行else语句
00401570 push offset string "\xcf\xe0\xb5\xc8" (0043201c)
00401575 push offset std::cout (00439528)
0040157A call @ILT+170(std::operator<<) (004010af)
0040157F add esp,8
00401582 mov ecx,eax
00401584 call @ILT+120(std::basic_ostream<char,std::char_traits<char> >::operator<<) (0040107d)
44: }
45: }
00401589 pop edi // 平衡堆栈
0040158A pop esi
0040158B pop ebx
0040158C add esp,44h
0040158F cmp ebp,esp
00401591 call __chkesp (004091d0)
00401596 mov esp,ebp
00401598 pop ebp
00401599 ret // 返回给调用者
(该段代码转自网络)
每个结构都有一张脸 认清这张脸的结构以后看到很轻易就能认识
2014.3.17.zip
(1.84 KB, 下载次数: 11)
|
|