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

跳转指令中,PC和offset的疑问 #8

Open
huangwei2013 opened this issue Jun 17, 2019 · 2 comments
Open

跳转指令中,PC和offset的疑问 #8

huangwei2013 opened this issue Jun 17, 2019 · 2 comments

Comments

@huangwei2013
Copy link

在尝试实现&调试“条件跳转指令”过程中,遇到PC、offset计算问题。
按JVM文档、资料、class二进制内容,得到的结果都是新地址为

	offset+PC
		其中 offste = (operand1<<8)|operand2

但本项目中,PC地址似乎保存的是第N条指令,于是直接加offset,会超出operands数组长度范围

参考项目,如 https://github.com/zachaxy/JVM/ 的 blob/master/Java/src/instructions/base/BytecodeReader.java

程序自己维护PC,并且每读出一个 UINT8 内容,会递增 PC
这个才比较符合JVM规范的说明
@caoym
Copy link
Collaborator

caoym commented Jun 17, 2019

确实之前pc的实现,没有仔细去查阅文档,想当然就实现了,非常感谢你能指出。如果你有精力,欢迎提交patch :P

@huangwei2013
Copy link
Author

感谢确认,花了几天时间才确认这个问题 333

我会尝试一下增加该部分处理:)

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

1 participant