C#语言解释器 [英] Language interpretor in C#

查看:115
本文介绍了C#语言解释器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!我想开始一个新项目.我的目标是模拟CISC结构(我具有结构的结构).好的,我的第一步是制作一个语言解释器(我不知道这是否是核心词,但我希望您理解我的意思).对于行mov r1,[r2]的exp,结果将为0000 000001010010.
所以
mov = 0000
r1 = 0001,前2位表示寻址模式" 00-直接
r2 = 0010 01-间接

我的问题是我不知道在这两者之间建立联系对我有什么好处.
我想将数据存储在哈希表中,例如:value ="mov"作为字符串,key = 0000作为字节.我知道我可以用这种方法来做到这一点,但我希望对此有其他意见.

您建议使用哪种更好.我只需要一些想法,而不是代码或类似的东西.


提前非常感谢您.

CISC结构

Hello ! I want to start a new project . My goal is to simulate a CISC arhitecture(I have the structure of my arhitecture). Ok my first step is to make a language interpretor (I don`t know if this is the corect word but I hope you understand what I mean). For exp for the line mov r1,[r2] the result will be 0000 000001 010010.
So
mov = 0000
r1 = 0001 and the first 2 bits represent the "Addressing modes" 00 - direct
r2 = 0010 01 - indirect

My problem is that I don`t know what is better for me to make the connection between these two.
I thought to store my data in a hashtable like : value = "mov" as a string and key = 0000 as a byte . I know that I can do it with this method but I want some other opinions about this .

What do you suggest that is better to use . I want just some ideas , not code or something like that .


Thank you very much in advance.

CISC arhitecture

推荐答案

被称为交叉汇编器,尽管我似乎从来没有用C#编写过代码,但是有很多是用C或C ++编写的.
Google会帮助您找到它们-这并不像您想的那么简单!看一下现有的一些写法,并尝试看看是否有可以使用的思想.

老实说,如果您要模拟整个CISC体系结构,那么我将从另一端开始:从CPU内核开始并编写指令处理器.这样,您就可以在编写交叉汇编程序时对其进行测试...:laugh:
That is called a cross assembler, and while I have never seem one written in C#, there are quite a lot written in C or C++.
Google will help you find them - it''s not as simple as you think! Have a look at how some existing ones are written, and try to see if there are ideas you can use.

To be honest, I would start this from the other end, if you are simulating the whole CISC architecture: start with the CPU core and write the instruction processor. That way, you have something to test the cross assembler against when you have written it... :laugh:


这篇关于C#语言解释器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆