开发者

How can I write a simple pseudo assembler?

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 (MIP开发者_开发百科S) 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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜