Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于test命令 #1

Closed
zhj12138 opened this issue Mar 17, 2021 · 4 comments
Closed

关于test命令 #1

zhj12138 opened this issue Mar 17, 2021 · 4 comments

Comments

@zhj12138
Copy link

你好,我想问问在习题中出现的这段代码:

sub  $1, %bx
test $0, %bx
jgt .top

其中的test指令的作用是什么,我感觉作者想表达的应该是cmp指令,即和0进行比较,比0大就继续循环。
但是根据我对test指令的了解,它是对两个参数进行与运算,可是任何数和0相与不都是0吗,这样对条件码的影响会和cmp相同吗?
我看到你的答案里好像也是按照cmp理解的,所以我有些困惑,是我对test指令理解错了吗?

@jzplp
Copy link
Owner

jzplp commented Mar 22, 2021

这是哪道习题?

@zhj12138
Copy link
Author

@jzplp 这是线程那几个章节的模拟题里,一些.s文件中出现的代码(出现了很多次)

@jzplp
Copy link
Owner

jzplp commented Mar 22, 2021

哦哦,不同系统的的汇编代码是不一样的。这里仅仅是一种汇编的伪代码,不用纠结这个。

@zhj12138
Copy link
Author

好的,谢啦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants