Re: Why do people say C is better than Assembly?
Posted: Fri Jan 13, 2017 7:00 am
You don't have to imagine it; it's been done. And it doesn't reach 1KB.TheDev100 wrote:Imagine a boot sector in C. It would reach 1KB instead of 512 bytes.
The Place to Start for Operating System Developers
https://forum.osdev.org/
You don't have to imagine it; it's been done. And it doesn't reach 1KB.TheDev100 wrote:Imagine a boot sector in C. It would reach 1KB instead of 512 bytes.
Beautiful analogy!Love4Boobies wrote:All this sounds like worrying whether your car is aerodynamic so you can get to your destination faster without worrying which route you take. Which one do you think will make a difference?
When linking code written in one only high-level language and one assembly language per architecture, there are only 4 cases of linking code together:Love4Boobies wrote:You need calling conventions and to mess up your register allocation a little whenever you want to link code, even in assembly.
Definitely - it applies to every compiler that compiles a high-level language without using LTO (by default).Love4Boobies wrote:glauxosdever, that is unrelated to C.
who says assembly equivalent call gets will not get viruses and wormsC has got functions like gets(); that cause viruses and worms!
Code: Select all
(eax) = my_high_level_function(ebx, edx)Code: Select all
(eax) my_assembly_function(ebx, edx) { /* Assembly code goes here */ }GCC's inline assembly can work like this, although it's really only intended for code that can be placed inline, not function calls.glauxosdever wrote:For calling assembly code from high-level code, as I said (but not explained well) a special construct similar to function prototypes in high-level code could be used. Something like:could be inserted by the programmer in the callee assembly function, which tells the compiler to compile the caller high-level function as to put the first input value in ebx, the second input value in ebx, and to expect the first return value in eax.Code: Select all
(eax) my_assembly_function(ebx, edx) { /* Assembly code goes here */ }
Wrong. I have an arbitrary size integer package similar to bignum, entirely written in assembler, and far more efficient than any C compiler would be able to produce. That's mostly because C compilers cannot handle carry-through and similar things in a good way.DixiumOS wrote:Another way to say that C is good is that in Assembly you can't use numbers as large as... 1.7x10^308.
I guess it's a good thing that you have never heard about L4.rdos wrote:but if a micro-kernel design with lots of TLB shootdowns and context switches ever can beat a monolithic kernel written in assembly using segmentation, which I think it never can. So the C people continue with their flat monolithic kernels that are prone to memory corruption issues, as this is the only way they can reach decent performance.