指令集在汇编中起什么作用? [英] What does the instruction sete do in assembly?
问题描述
我的大学课程要求一些基本的组装知识...即使我没有任何知识.但是他们给了我们这个示例汇编代码:
My uni course requires some basic assembly knowledge... even though I have NONE. However they gave us this sample assembly code:
080485fa <check_pin>:
80485fa: 55 push ebp
80485fb: 89 e5 mov ebp,esp
80485fd: 81 7d 08 bf 07 00 00 cmp DWORD PTR [ebp+0x8],0x7bf
8048604: 0f 94 c0 sete al
8048607: 0f b6 c0 movzx eax,al
804860a: 5d pop ebp
804860b: c3 ret
应该大致等同于以下C代码:
It is supposed to be more or less equivalent to the following C code:
int check_pin(int pin) {
return pin == 0x7bf;
}
我试图弄清楚该汇编代码到底是做什么的,对此sete
指令我感到du目结舌.这条指令是做什么的?
I'm trying to figure out what exactly this assembly code do and I'm dumbfounded by this sete
instruction. What does this instruction do?
Wikibooks具有有关x86汇编的课程,但是我找不到关于sete
在有关汇编说明的章节中.
Wikibooks has a course on x86 assembly, but I was not able to find anything about sete
in the chapter devoted to assembly instructions.
推荐答案
如果设置了零标志,则sete
指令(及其等效的setz
)将其参数设置为1
,否则设置为0
.如果最后一个比较或算术指令产生相等或结果为零,则设置零标志.因此,根据您的情况,sete
根据前面的cmp
指令的结果将al
设置为0
或1
.
The sete
instruction (and its equivalent, setz
) sets its argument to 1
if the zero flag is set or to 0
otherwise. The zero flag is set if the last comparison or arithmetic instruction yielded equality or a result of zero. Thus in your case, sete
sets al
to 0
or 1
according to the result of the preceeding cmp
instruction.
这篇关于指令集在汇编中起什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!