68HC11计算sin(x)的汇编代码

发布于 2024-08-15 13:03:37 字数 167 浏览 2 评论 0原文

68HC11 使用泰勒级数或查找表计算正弦值的汇编代码是什么?

显示值只能是整数。查找表如何工作 在这种情况下?如何使用泰勒级数来实现?

What would be the assembly code for 68HC11 to calculate value of sine using either Taylor series or a lookup table?

Display value will be only in integer. How would a lookup table work
in this case? How can it be implemented using Taylor series?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

哆兒滾 2024-08-22 13:03:37

如果您正在寻找浮点解决方案,则需要首先实现浮点运算。这部分在 68HC11 上并不重要,因为它甚至不支持 32 位操作。之后,计算 sin 很容易,但速度很慢。 ;-)

使用查找表。

If you are looking for a floating point solution, you'll need to implement floating point operations first. That part will be non-trivial on a 68HC11 which has no support for even 32 bit operations. After that, calculating sin is easy but very slow. ;-)

Use a lookup table.

终遇你 2024-08-22 13:03:37

不要使用泰勒级数。

Google 发现了

Don't use Taylor series.

Google found this.

月寒剑心 2024-08-22 13:03:37

我已经很长时间没有做过任何 68HC11 编程了,所以我无法为您提供准确的说明,但您或多或少希望执行以下操作:

  1. 在内存中定义一个表,该表在一个象限上具有 256 个(或任意多个)Sin(x) 值,范围为 [0-Pi /2]。
  2. 将您的输入转换为 [0-Pi/2] 范围,并跟踪它最初所在的象限。例如,对于 Q2,您需要值 (Pi/2-x)。
  3. 在表中查找调整后的值,如果原始角度位于第三或第四象限,则结果无效。

具体细节当然取决于输入和输出范围,但一般来说,您将使用索引寻址模式,索引寄存器指向表,或者使用扩展寻址,通过修改操作码设置偏移量。

I haven't done any 68HC11 programming in a long time, so I won't be able to give you exact instructions, but you want to do more-or-less the following:

  1. Define a table in memory that has 256 (or however many) values for Sin(x), over one quadrant, in the range [0-Pi/2].
  2. Convert your input to the range [0-Pi/2], keeping track of which quadrant it was originally in. For Q2, you want the value (Pi/2-x), for example.
  3. Look up the adjusted value in the table, negating the result if the original angle was in the 3rd or 4th quadrants.

Specifics would of course depend on input and output ranges, but generally speaking, you'll use indexed addressing mode, with the index register pointing into the table, or alternatively, extended addressing, with the offset set by modifying the opcode.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文