如何编写一个简单的伪汇编程序?

发布于 2024-10-06 04:58:11 字数 143 浏览 1 评论 0原文

我必须为用 VHDL 编写的简单 cpu 模型编写一系列测试平台。我需要的是一段将汇编代码(MIPS)中的指令转换为二进制字符串的代码。我不需要任何干净或优雅的东西。唯一的目的是加快测试速度。我正在考虑使用缩写或类似的东西编写 emacs 或 vim 脚本。你有什么建议?

I have to write a series of testbenches for a simple cpu model written in VHDL. What I need is a piece of code that translates an instruction in assembly code (MIPS) into a binary string. I don't need anything clean or elegant. The only purpose would be speeding up the testing. I was thinking to write an emacs or vim script using abbreviations, or something like that. What do you suggest?

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

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

发布评论

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

评论(2

Oo萌小芽oO 2024-10-13 04:58:11

如果您正在谈论 vim 和 emacs,您可能想尝试一个简单的 bash 脚本。您可以非常轻松地逐行读取文件,并且行解析和 case 语句非常强大(特别是如果您明智地使用 $IFS)。否则,这听起来像是您选择的脚本语言的工作,无论是 bash、perl、ruby、python、vim 宏还是其他语言。

If you're talking vim and emacs, you might want to try a simple bash script. You can pretty easily read in a file line by line, and the line parsing and case statements are pretty powerful (especially if you intelligently use $IFS). Otherwise, this sounds like a job for the scripting language of your choice, be it bash, perl, ruby, python, vim macros, or whatever.

雨巷深深 2024-10-13 04:58:11

你可以试试 ye olde Cu M-|将 emacs 中的 mips 字符串发送到外部程序并用结果替换该字符串。这样你就可以使用任何你想要的方法来编写实际的程序。

至于程序本身,尽管 MIPS 没有大量指令,但自己编写脚本可能需要太多工作(非常乏味,并且可能会分散您实际尝试做的事情的注意力),我建议您看看是否可以从现有的 MIPS 汇编器获取一些输出。

You might try ye olde C-u M-| to send your mips string in emacs to an external program and replace the string with the results. That way you can use whatever method you want to write the actual program.

As for the program itself even though MIPS doesn't have a ton of instructions, it's probably too much work to script it yourself (very tedious and probably a distraction from what you're actually trying to do) I would recommend seeing if you can get some output from an existing MIPS assembler.

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