使用四种寻址方式设计指令格式,七种寻址方式特点举例

首页 > 实用技巧 > 作者:YD1662023-11-11 02:25:07

串传送指令 MOVS

串比较指令 CMPS

串扫描指令 SCANS

串加载指令 LODS

串保存指令 STOS

这些指令可以有选择地使用REP/REPE/REPZ/REPNE和REPNZ的前缀以连续操作。

3.9 其它指令

如处理机控制类指令、数据转换类指令。

4 C代码与汇编指令

可以在代码中设置断点进行调试然后查看调试窗口(Alt 8),即可看到C语言与汇编代码的对照。

1: #include <iostream>

2: using namespace std;

3: int max(int a,int b)

4: {

00401550 push ebp

00401551 mov ebp,esp

00401553 sub esp,40h

00401556 push ebx

00401557 push esi

00401558 push edi

00401559 lea edi,[ebp-40h]

0040155C mov ecx,10h

00401561 mov eax,0CCCCCCCCh

00401566 rep stos dword ptr [edi]

5: if(a>=b)

00401568 mov eax,dword ptr [ebp 8]

0040156B cmp eax,dword ptr [ebp 0Ch]

0040156E jl max 25h (00401575)

6: return a;

00401570 mov eax,dword ptr [ebp 8]

00401573 jmp max 28h (00401578)

7: else

8: return b;

00401575 mov eax,dword ptr [ebp 0Ch]

9: }

00401578 pop edi

00401579 pop esi

0040157A pop ebx

0040157B mov esp,ebp

0040157D pop ebp

0040157E ret

10: void main()

11: {

00401590 push ebp

00401591 mov ebp,esp

00401593 sub esp,44h

00401596 push ebx

00401597 push esi

00401598 push edi

00401599 lea edi,[ebp-44h]

0040159C mov ecx,11h

004015A1 mov eax,0CCCCCCCCh

004015A6 rep stos dword ptr [edi]

12: int i = 0;

004015A8 mov dword ptr [ebp-4],0

13: i=max(3,4);

004015AF push 4

004015B1 push 3

004015B3 call @ILT 500(max) (004011f9)

004015B8 add esp,8

004015BB mov dword ptr [ebp-4],eax

14: cout<<i;

004015BE mov eax,dword ptr [ebp-4]

004015C1 push eax

004015C2 mov ecx,offset std::cout (0047be90)

004015C7 call @ILT 245(std::basic_ostream<char,std::char_traits<char> >::operator<<) (004010fa)

15:

16: }

004015CC pop edi

004015CD pop esi

004015CE pop ebx

004015CF add esp,44h

004015D2 cmp ebp,esp

004015D4 call __chkesp (00420310)

004015D9 mov esp,ebp

004015DB pop ebp

004015DC ret

-End-

上一页1234末页

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.