|
[求助]求教汇编的问题
[QUOTE=盛全;539969]实际上 [esp+9C]和 [esp+94] 是unsigned char变量,其值肯定不会大于0xFF 而且程序中有大量的连续的这代码段,在已经在以保证eax/acx 里除al/cl 里可能在数据,其它都是0的情况下 VC6.0为什么不把代码编译成 00402F00 |. 8B8424 9C000000 |mov al, byte ptr [esp+9C] 00402F07 |. 8B8C24 94000000 |mov cl, byte ptr [esp+94] 00402F19 |. 8A9441 90DD9900 |mov dl, byte ptr [ecx+eax*2+99DD90] 00402F20 |. 8A8448 90DD9900 |mov al, byte ptr [eax+ecx*2+99DD90] 这样程序看起会不会更高效呢?[/QUOTE] 请问楼主是学习计算机专业的吗? CPU按总线宽度执行地址对齐的存储器访问是效率最高的,只需要一个标准的总线周期即可完成。至于像and eax,0xff这样的指令,基本上可以认为所需要的时间与CPU主频差相同,只需要一个时钟周期。 对于非总线宽度的访存指令,比如字节操作,实际上不仅不会提高效率,反而有可能降低效率(不一定,需要视处理器的内部实现而定)。 虽然看上去你省掉了一条and指令的时间,但寄存器操作指令的速度与访存操作的速度相差至少几个数量级,而且CISC的处理器,几乎总会在访问非总线宽度的存储器时额外的操作,也就是说,即使软件不写成and 0xff,而写成字节的操作,但硬件实际上还是会执行一次位掩码操作,以保证指令的逻辑正确性。要知道,实际硬件是没有办法真正地实现“字节”宽度的总线操作周期的!总线宽度是32位的话,每个总线周期在总线上出现的数据总是32位! 另外,NOP指令当然要占CPU的指令周期了。你可以查看一下INTEL的指令手册,看看为NOP指令存在的必要性。 |
|
[求助]输入表里面的NAME是啥意思
错了,GetProcAddress用的是序号,是ordinal,这个hint是另外的作用,正如其名字,它只是个“提示”,你不可相信它。 请看:Crackme1.exe的导入表,User32.dll的wsprintfA函数的hint是684(0x2AC),但在User32.dll导出表中,该函数的实际序号是731(0x2DB), 而序号为0x2AC的函数是TranslateMessageEx,而且我们看到,该函数的ordinal和hint不相同!! |
|
|
|
[求助]qualified type
不知道你说是什么,大概是断章取义了。 qualified type,直接译为限定的类型,前面应该还有个其它词,比如在C++中我们说cv qualified type。 另外,DS是段寄存器,它里面的值叫“段选择子”,指向一种叫做“段描述符”的数据结构。不过在WIN32下汇编语言基本上不用管段寄存器。 哦,对了段寄存器是16位的,共有6个 CS,SS,DS,ES,FS,GS。这个东西实际是8086/88遗留下来的东西,在386以后线性可寻址4GB后,就基本只用flat内存模式,而不再使用分段模式了。 请查阅INTEL相关手册 。另外,不知道你看的书是哪本,可能你看的书与你现在的基础知识掌握程度不太符合,试着找找其它的教材,说不定就会恍然大悟了。 |
|
[讨论]ESP 和 EBP 的关系(以及对at&t和intel 的asm讨论)
寄存器重命名和寄存器窗口等技术,很多高端处理器都是有的。 但INTEL桌面计算机处理器是没戏了。 但面向高端的INTEL的ITANIUM处理器,确实让人很叹服它的设计,打破INTEL给人的复杂臃肿低效的印象,它具有足够多的寄存器,并且支持寄存器重命名(旋转寄存器),而且最妙的是,它具有一个“寄存器栈”,在需要的栈空间不多时,可以完全脱离内存栈,其性能提升可想而知(当然寄存器栈的设计还有很多其它的用处)。 我特别注意到它的指令,是叫做“指令束”的,具有三条并行的指令流! 试想如果X86构架没有“向前兼容”的包袱,我想当今桌面计算机的性能也绝对不是现在这个水平。。。 |
|
[讨论]ESP 和 EBP 的关系(以及对at&t和intel 的asm讨论)
狐狸你是没看过AT&T的汇编。看过之后就知道它是什么了。 如果是纯汇编的还好看,如果是C中内嵌的AT&T,就不同了,因为它不与机器码完全对应!!! 这是用AT&T写的纯汇编的程序,会看INTEL汇编的,只要记住它的源与目的操作数相反就能看懂。 _pg_dir: 17startup_32: 18 cld 19 movl $0x10,%eax 20 mov %ax,%ds 21 mov %ax,%es 22 mov %ax,%fs 23 mov %ax,%gs 24 lss _stack_start,%esp 25 call setup_idt 26 call setup_gdt 27 movl $0x10,%eax # reload all the segment registers 28 mov %ax,%ds # after changing gdt. CS was already 。。。 但你要是看下面的C中内嵌的汇编,看起来只有一条call指令,而实际上4个参数需要组合,所以编译器生成的绝不是一条指令! #define __get_user_x(size, ret, x, ptr) \ asm volatile("call __get_user_" #size \ : "=a" (ret),"=d" (x) \ : "0" (ptr)) \ 我现在拜读Linux内核就因为这些AT&T汇编太难理解而几乎读不下去,郁闷。。。 |
|
[讨论]ESP 和 EBP 的关系(以及对at&t和intel 的asm讨论)
编译器的寄存器分配策略,对编译代码的质量有着至关重要的影响。 有时候恰好由于少一个寄存器,编译器不得不使用栈帧上的内存,对于某些数学算法,局部变量和临时结果的访问非常频繁。有时仅仅因为一个寄存器不够,代码的效率会成倍地打折。 要知道内存的访问速度和寄存器的访问速度相差至少一个数量级!哪怕多了几条访存指令,程序的效率降低就非常明显。有些直接使用内存操作数的指令,比如add [esp+0x10],eax,实际上要两次总线操作的周期才能完成。类似的指令还有比如inc [esp+8]等等。 作为个人桌面应用,这点性能的差别是完全可以不计的。但对用作科学计算的计算机程序,好的编译器比差的编译器就不止是成倍地提高效率了。 我曾经读过一本书,讲图像处理的算法,作者自己编写一个滤镜算法的程序,执行时间是200ms,经过不断地优化,最后提高到46ms,最后使用intel的编译工具,使用intel的各种多媒体指令集,结果该算法最终的平均执行时间仅为6ms! 一个寄存器看似事小,实则影响非同小可。如果遇到了类似于访存的“颠簸”现象,那么这一个寄存器的代价可能是几个数量级的性能损失了!!! 包括Linus内核在内的GNU世界的程序员,全部倾向于使用AT&T汇编,而不愿意使用INTEL汇编语法。 原因就在于AT&T汇编原本不是为了程序员用来写程序而发明的,AT&T汇编格式本身就是编译器前端生成的、供后端汇编器使用的“中间代码”,像Linux内核那样,在C中嵌入汇编,甚至可以对编译器的寄存器分配策略进行控制,而如果嵌入INTEL格式,则是完全不同的概念了。 虽然我还没有能力使用AT&T汇编格式来写程序,不过目前读懂不太晦涩的代码还是没问题的。见识过了AT&T汇编,才知道GCC有多么强大。。。 |
|
[讨论]ESP 和 EBP 的关系(以及对at&t和intel 的asm讨论)
INTEL推荐使用EBP作为栈帧的访问基址寄存器。 实际中大多数编译器生成的标准代码也是这么做的。 但是对于某些情况,比如一个数学算法,如果开了编译器的高级优化,它会把EBP也分配给局部变量或临时变量,而只使用ESP访问栈上的局部变量和函数参数。 在特定情况下,仅仅多一个可分配寄存器却可能意味着性能成倍地提高。 |
|
[求助]突破代码中的CreateEvent
如果是用自己写的程序做实验,可以使用OD进行源码调试。 只要程序编译和连接时带着调试信息就可以。 另外,源代码文件路径不能有中文。 方法: 首先配置编译器生成带调试信息的程序,如果是Debug模式,默认已经带有了。如果是Release模式,则按此配置: 然后在OD中,在CPU窗口中,最右侧的一栏,默认为“注释”,点击标题栏可以在“注释”、“源码”、“统计”三者切换。只要切换到“源码”栏即可。 |
|
[求助]请问下大家,脚本一般在那个版块去找啊
可以放在工具开发与扩展区 |
|
[求助]我的要求学什么编程语言好呢?
教材有无数的都堪称经典,比如 《the C program language》 《C Primer Plus》 参考的话当然是《ISO/IEC 9899:1999 (E) - Programming languages — C》 |
|
|
|
[求助]请问谁有lida - linux interactive disassembler
你说的这个就是IDA的linux下的调试服务器。 在IDA的Windows版本中自带了。 程序名叫linux_server,linux_server64 可以使用它进行Linux本机调试(控制台界面)或远程调试(使用Windows下的IDA作为终端,图形界面)。 详情请看IDA的说明: http://www.hex-rays.com/idapro/linux/index.htm |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值