我有兴趣制作一个操作系统。那么汇编还是C? [英] I am Interested in making an OS. So Assembly or C?

查看:74
本文介绍了我有兴趣制作一个操作系统。那么汇编还是C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说在C上首选与硬件组装交互是真的吗?

其次我正在学习大会,我的教授正在瞄准英特尔iAPX 8088,我想知道他为什么还在教学在Core i世代的存在下这样一个古老的架构,所以请给我一些指导,我会以正确的方式?真的非常感谢。

I have heard that for interacting with hardware assembly is preferred on C. is that true?
Secondly I am learning Assembly and my professor is targeting Intel iAPX 8088, i wonder why he is still teaching such an old architecture in the presence of Core i generations, So please give me some guidance that am i going the right way?? Truly Thanks in Advance.

推荐答案

尽可能使用 C 。然后,如果你不能用C做(或者有一个严重的性能优势)使用程序集。

我认为单个人使用程序集开发整个操作系统将是一项艰巨的任务(我想无论如何这都是一项艰巨的任务..)。

当然,课程(原谅双关语)有点过时了。然而,为了学习基础知识,一个简单的架构做得很好。
Use C the most you can. Then if you can't do it with C (or there's a serious performance advantage) use assembly.
I think a it would be a daunting task for a single person to develop an entire OS using assembly (I guess it is a daunting task anyway..).
Of course the course (pardon the pun) is a bit outdated. However for learning the basics a simple architecture does a good job.


取决于是最好的答案,我很害怕。



C是更好的,因为操作系统往往很复杂,而且理解和修改用高级语言编写的大软件比在汇编程序中执行相同操作要容易得多:一个粗略的指南,C的行将是汇编程序的1到20行。



但是...一个好的汇编程序员仍然可以击败任何编译器速度和/或紧凑性,有时候这是一个重要因素。



所以真的,这是你支付你的钱,你需要的您的选择 - 但请记住,如果您需要,许多C编译器将允许您为紧密位内联汇编代码。



我将走哪条路?很高,可能。维护大型汇编程序项目真的很难,当你是项目中唯一的人时,这会产生很大的不同,因为你将不得不重新访问你在六个月前写的代码并尝试理解它。



他为什么教8088?他应该教什么装配工? :笑:这是一个好的,简单的汇编程序,具有足够的功能,但没有现代CISC处理器的复杂性。是的,他可以教一些像PIC那样简单而且更常见的东西 - 但这对于初学者来说很难调试,因为一切都在芯片里面而很难搞定。使用旧的东西,你可以将示波器固定在腿上,看看发生了什么! :笑:
"Depends" is about the best answer, I'm afraid.

C is "better" in that Operating Systems tend to be complex, and it's a lot easier to understand and modify "big" software that is written in a high level language than it is to do the same in assembler: as a rough guide, a "line" of C will be 1 to 20 "lines" of assembler.

But...a good assembler programmer can still beat any compiler for speed and / or compactness, and there are occasions when that is a significant factor.

So really, it's a case of "you pays your money, and you takes your choice" - but bear in mind that many C compilers will allow you to inline assembler code for "tight bits" if you need it.

Which way would I go? High level, probably. It really is hard to maintain large assembler projects, and that makes a big difference when you are the only person on the project as you will have to revisit code you wrote six months ago and try to understand it.

Why does he teach 8088? What assembler should he teach? :laugh: It's a good, simple assembler with enough features to be useful, but without the complexity that modern CISC processors have. Yes, he could teach something like PIC which is simple and more common - but that's hard to debug for beginners because everything is inside the chip and it's hard to get at. With the older stuff, you can stick an oscilloscope on the legs and look at what is happening! :laugh:


只是几个额外的想法:



使用C ++,而不是C.您仍然可以编写< b>与C 完全一样低,有C ++的好处,你可以使用它们。



更重要的是:尽管有些装配肯定是必需的,你的一些汇编代码(实际上,大多数汇编代码)都可以用C ++ 内联汇编编写。与使用传统汇编程序相比,这是更方便。例如,您可以轻松使用用C ++编写的声明和函数,以及更多。但是,你可以找到一些非常先进的汇编程序;有些甚至是面向对象的。



根据我的经验:我是线程的早期实现者之一(当时Linux已处理但尚未线程) )和真正的现代结构化程序集处理(当它甚至没有在C ++中引入时,仅在CLU和Ada中可用,可能在其他地方)。当然,它需要使用寄存器,堆栈和其他内存进行直接操作。你是如何实现这一目标的?在它的核心,主要是在面向对象的环境中使用Borland Object Pascal内联汇编程序。



-SA
Just couple of extra ideas:

Use C++, not C. You can still write the code which is exactly as low-level as C, with benefits of C++ where you can use them.

More importantly: even though some assembly is certainly required, some of your assembly code (actually, most of your assembly code) can be written in C++ inline assembly. This is a whole lot more convenient than using traditional assembler. For example, you can easily use declarations and functions written in C++, and a lot more. However, you can find some very advanced assembler; some are even object-oriented.

Take my experience: I was one of the very early implementors of threading (at the time when even Linux had processed but not yet threads) and real modern structured assembly handling (when it wasn't even introduced in C++, was only available in CLU and Ada, maybe somewhere else). Of course, it required direct manipulations with registers, stack and other memory. How do you thing I achieved that? In the core of it, mostly using Borland Object Pascal inline assembler, in object-oriented environment.

—SA


这篇关于我有兴趣制作一个操作系统。那么汇编还是C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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