« first day (189 days earlier)      last day (530 days later) » 

12:15 AM
Right now im learning C , and i know C++ Preety well
Is Assembly Gonna Go Well you think? Assembly is really diffrent from other langauges.. As i see code examples, it has complete diffrent structure. Does it even have if/else statements lol?
@PeterCordes
And if you guys dont mind. I have one big question, and that is Can you put assembly code in C++ / C ?
 
@Dsafds: No, it doesn't have if statements. You have to implement them yourself using conditional-branch instructions. (like an if(x) goto label). See the x86 tag wiki and/or the assembly tag wiki.
If you understand C pointers, memory, and globals vs. locals, you're all set to understand asm. C compiles pretty directly to asm, since the language doesn't include anything the hardware doesn't support directly.
You can use inline-assembly in C/C++, but that's the most difficult way to learn assembly. I'd recommend starting by just reading compiler output for extremely simple functions to sort of get an idea of things at first. It's fine to treat assembly as a read-only language if you don't want to spend a lot of extra time up front learning it. Compile stuff with gcc -fverbose-asm -O1 or something.
The x86 tag wiki has some links to suggestions for learning.
 
inline-assembly?
wow.. new terms here :D
And i have heard there are many Assembler Compilers? Which one is the best for making kernels?
 
12:31 AM
@Dsafds: yasm is popular and good, so is nasm. Why do you want write a kernel, though? You're only just learning C/C++, and you don't know asm yet. Just learning user-space asm will take you a while. Once you understand just the user-space unprivileged instructions and how to use them, then understanding all the system-management stuff an OS has to do will make so much more sense.
 
Why i am writing a kernel? Haha, that is my major goal in my life. To make the greatest kernel of mankind. yasm, i never heard about it lol, but i defintely heard a lot about the nasm compiler. I am not just learning C++, i know it preety well by know, but as for C Im just learning it but it should be easy.
 
For me, the benefit in understanding asm is to tell when the compiler did a good job, and when it could have done better. Also, to understand what the hardware can do, and what the compiler will probably do, so I can write C that compiles to efficient asm. You almost never want to actually write asm by hand; just look at the compiler output while tuning C.
 
and your required assembly for making an OS
i love how you directly communicate with hardware :)
 
NASM isn't a compiler, it's an assembler.
 
assembler? ugh i got to go for an hour.. but whats an assembler??!
 
12:35 AM
An assembler is to assembly language what a compiler is to a higher-level language.
Compilers output asm
Also, assembly doesn't imply communicating directly with the hardware (other than the CPU). Most asm code is not part of a device driver.
e.g. all the asm code in a video codec like x264 just exists to do calculations faster, because the compiler doesn't do quite as good a job as hand-tuned asm.
It is a lot of fun to tune your code based on the capabilities of a specific microarchitecture, though. Accurately predicting cycles per iteration for a loop is really cool. (See Agner Fog's microarch pdf). So I guess that's the kind of direct hardware interaction I think is cool in asm.
If you want to write a kernel, though, in what way will yours be better than Linux or FreeBSD? I've never felt the need to write my own kernel, since I can (and have) just modified Linux when I wanted it to work better.
 
12:55 AM
Wow, the Assembly room is one of the most active rooms in SO chat?
(Hi all. First time here.)
@PeterCordes Is it still true that hand-tuned assembler is faster than compiled code, even for a modern CPU like an i7 with predictive execution, massive pipelining, etc?
I've written a LOT of assembler in my day, but I tend to stick to higher level languages these days.
I wrote a word processor for the original IBM PC in 8086 assembler, for example. In those days that was the only way to get really fast performance.
 
@DuncanC: on a small scale, yes. gcc doesn't have a sophisticated cost model for specific microarchitectures, so it doesn't tune very small loops perfectly. And it's usually possible to save a couple uops with careful choice of addressing modes and referencing one array input as (orig_src-orig_dst) + dst.
Depending on the code, it can take hours or days to find a tiny improvement that may only bring a gain in code-size, not actual execution speed. Compilers do a good-enough job almost all the time, and when they don't it's usually best to hand-hold them towards the right asm by writing C that works the way you want the asm to work.
 
Agreed. I write a lot of hand-tuned C, but haven't written much assembler in > 20 years.
 
Because on a large scale, compilers are unrivalled by humans for constant-propagation and inlining on a whole-program scope.
Using inline asm defeats constant-propagation
Even from a pure performance standpoint, gcc.gnu.org/wiki/DontUseInlineAsm has some good arguments. Even though I'm good at it, I don't actually use it in practice, and definitely discourage others from using it any time it comes up.
 
Understanding how best to take advantage of on-chip pipelining and concurrency is also not easy.
 
Right, small-scale local optimizations for the Sandybridge-family pipeline is where it gets fun. Sandybridge-family finally gets rid of many of the hard-to-predict bottlenecks like register-read port stalls. (And of course out-of-order execution mostly gets rid of instruction-scheduling issues)
Tuning for an in-order pipelined CPU is where it gets hard. Out-of-order CPUs are much less sensitive to instruction ordering in most cases, since they find the separate dep chains for you.
You can usually get fairly good results for static analysis from just counting fused-domain uops, latency, and unfused-domain port bottlenecks.
 
1:10 AM
Designing for cache coherence is another big.
biggie.
 
See for example the static perf analysis in some of my answers.
How is designing for cache coherence different in asm than C11 stdatomic? You have to know what's fast on the hardware. I know I'd think about it in terms of the asm it would compile to, but that's only because I already know asm.
Or do you mean in terms of modern hardware being complex, and using the fewest locks and cheapest barriers is an important optimization? Yeah, that's true, release is much cheaper on x86 than seq_cst.
 
2:01 AM
Basically a assembler is like the compiler to javascript where javascrupt is assembly?
Kernel, is the foundation of our race
the kernel...... is love.... the kernel is life
5
Why dont you want to make an awesome kernel? Thats the real question
 
Javascript is interpreted. It doesn't have a compiler.
 
no lol
I meant like C++
sorry i got confused there xD
@DuncanC is there any other langauges i need to make kernel? and OS, other than C,C++, and Assembly?
 
@Dsafds: I don't need to make an awesome kernel because I'm already using Linux, which is already awesome.
 
@PeterCordes why not make a better one?
I agree the linux kernel, is by far the best kernel
but whos stopping you?
 
How exactly can you improve on Linux?
Linux is written in C, with a bit of inline assembly. That appears to be the optimal combination these days.
But anyway, if I had any ideas for making a better kernel, I'd suggest them as changes to Linux instead of starting from scratch just to change something.
Linux already works great; it's user-space code like web browsers that are steaming piles of bloated crap.
Or more interestingly, instead of just designing a new kernel, why not design a replacement for the x86 ISA combining the advantages of CISC instruction encoding while dropping the x86 legacy baggage. A branch-new architecture could take some interesting approaches to SIMD instructions when they're part of the ISA from the start.
 
2:24 AM
Hahahha
First off
How exactly can you improve on C?
I mean Linux sorry
not C
Are you crazy?
There is nothing.. NOTHING out there that is perfect
Linux can be improved many ways
i have also, so to speak came up with my own ideas for the security base... something completly diffrent from usual
but anything in this world, can be improved on so many ways... we are farrr farrrrrrrr from perfect
 
@DuncanC It has a JIT compiler, but.. it doesn't really matter.
 
Ok can you guys give me a snippet of code of what inline assembly looks like?
haha why would you want to help linux?
why not start from scratch?
Rememebr... dont be a follower
be a leader
 
It won't work.
 
What wont work?
please @Darkrifts dont interrupt
 
Writing your own unix-like.
 
2:28 AM
mkay
 
yes im going to write a unix like kernel @littlepootis
but i dont understand.. what wont work?
So yea.. that is my anwser to your multiple questions @PeterCordes .... off to work
 
good luck :)
 
@Dsafds Yes, of course it's not perfect, but how specifically? What actual idea do you have that can't work as a change to Linux, and would require starting over from scratch?
 
First of all
@PeterCordes it can be a stupid idea
The idea can be the most terrible idea ever or
The greatest idea ever
so i wont spoil it for you guys :) . but ima give you a peek, it has something to do with security
why do i need to go of what somone did?
why not create your own..
 
@Dsafds I want to help Linux because it's what everyone already uses. An improvement to Linux will be much more useful to the world in general than yet another toy OS.
 
2:34 AM
its not a toy OS lol..
Yea but people change
 
Many different security frameworks have been implemented on top of Linux
 
back in the days
No one used linux kernel
It was all mac
yay apple.. yay apple!
 
I mean
whatever kernel mac uses..
now it changed to linux..
What about the future?
People Change. SOciety Changes
 
What does your kernel offer that linux doesn't? Why would people contribute to your project?
 
2:37 AM
Your OS doesn't even exist yet. It's going to be a toy OS at first. It's a huge amount of work to get it working reliably on a wide variety of server and desktop hardware (drivers), and get into the status of an OS that someone might use for something other than an experiment.
 
@littlepootis ... the real question is.. why would i spoil my idea?
@PeterCordes what a downer..... what a downer we got here..
 
How old are you..?
 
Maybe so people could help you refine your idea? I think it's hilarious that you have this idea that you think might lead to a revolution in operating systems, but you won't even tell anyone what it is so they can help you with it.
 
15? Why ask?
 
Linux was created because there weren't any good Free (as in open-source) OSes at the time. That's not the case now; Linux exists.
 
2:40 AM
Lol ok? And after 15 years when another bright kernel comes... We will be like "KernelCompanyName was created because there werent good kernels back then"
 
Linux is GPLv2, you can fork it if you want and use it as a good starting point for a new OS
THAT is the key point.
 
?
Like i said.... Im not a follower
 
Wait, Linux hasn't switched to GPLv3?
 
but what i was asking you guys at beggining was can you show me a code snippet of inline-assembly
 
It has not. Linus doesn't like GPLv3.
 
2:43 AM
And what is GPL?
 
@Dsafds: I think I linked the inline assembly tag wiki a while ago. Read it for links to tutorials and stuff.
Or just ask google about that and the GPL.
 
lol ok
 
Lack of good kernels is near the bottom of the list of problems with software today. Linux is one of the best pieces of software in existence. It's interesting, but I feel like most other things need improvement more than Linux. e.g. smarter compilers to make better asm is an interesting problem. They work well most of the time, but they're still really dumb.
 
Ok?
Why not make a better kernel?
Like i said....... Why stop here?
 
@Dsafds Yeah, let's make linux better.
 
2:51 AM
no. Lets not be followers and create our own kernel. @littlepootis
 
Why should I follow you when I can make my own kernel?
 
dont
Dont ever follow me
make your own kernel
 
Why not make a better kernel? Because I don't have unlimited time, and spending time improving Linux would be more efficient.
 
unlimited time/
Hmm.... Ofcourse Linux was created by unlimited time
 
Not to mention that if I ever wanted it to be used in production for anything real, it would take a significant fraction of the millions of man-hours that have gone into bugfixing and improving Linux, especially drivers.
 
2:55 AM
it would ttake years
but the end result is worth it
 
You have given ZERO convincing arguments that there's anything to gain from starting from scratch, instead of just forking Linux.
 
The end result? Homelessness?
 
Actually, zero arguments at all, let alone convincing.
 
you guys are just downers..
anways.. nice talking to you guys
Hope we meet soon..
 
If you want to justify starting from scratch, you need to do it with technical reasons, not just because you're young and optimistic and think that everyone should write all their own software There is a LOT of value in well-tested code, and nothing fundamentally wrong with the design of Linux.
 
2:59 AM
Accordint to Peter "Linux is Perfect". Makes 100% Sense
and im not young
and im not optimisitc
 
On the bright side, this is the longest conversation this room has witnessed.
 
really lol?
well.. i was suprised to hear a Assembly Room
well i got to sleep
 
You said you're 15. I'm 37; I'm allowed to call you young. As for optimistic, well whatever you want to call it that makes you think starting from scratch will give better results in the long run than building on top of the millions of man-hours that have gone into improving Linux.
 
Making a kernel, has been my dream'
from day one
ill turn it to reality
 
At no point have I said that Linux is perfect. Just that I don't want to spend my time on it.
 
3:06 AM
no one will stop meh
trust me
one day you will see
and youu will remember your words
"no point on making another kernel"
 
Go for it; a lot of people have fun making their own toy OS.
 
Hahaha ok guys
 
as a learning project
 
not learning
this is production
now peter if you are gonna down me .. dont reply t ome
anways guys
i gtg.. glad to hear assembly waking up
 
 
8 hours later…
11:19 AM
@Dsafds um. I'd say it's still debatable. There are plenty corner cases like... Proper RTOS on ARM or some... not that popular architecture.
 
12:06 PM
Hmm
@Kamiccolo well..... remember this "the key to immortality is living a life worth rememebering"
 
 
4 hours later…
Sam
3:45 PM
Hello, Excuse Me
 
I, Pootis, excuse you.
 
Sam
Where is a good place for me to learn Assembly?
 
Depends, do you have any previous programming experience.
 
Sam
Yes
but not with the assembly language
 
What languages?
 
Sam
3:49 PM
I know no languages fully but I have experiences with Lua, Python and Java
 
@Sam oh
I've heard good stuff about this book: savannah.nongnu.org/projects/pgubook
 
Sam
Well at the moment I am 15 but looking to work with operating systems in the future I thought it would be good to learn languages early
and for operating systems I hear assembly is most important
 
@Sam maybe... more like core features of how the computers work, not specifically assembly. Nowadays, not that much of code for OS is written in assembly. Bootloader.
 
Sam
Creating an operating System is like a dream
I have a spare pc I would be happy to remove the os of to create my own
 
I second the recommendation for Programming from the Ground Up. I think it kind of "puts the pieces together" to help you understand what's going on when you program in asm. If you don't already know low-level C / pointers / memory, you need a lot of background knowledge before asm can make any sense. I added a link to it in the x86 tag wiki.
@Kamiccolo: you need to basically understand how registers / memory / context switching actually works to write an OS, though, even though you should only use small amounts of asm. Linux is a good example.
 
Sam
4:06 PM
so where exactly do I find things for info on pointers, memory, etc?
 
@PeterCordes yup. And debugging GCC issues on this kind of low level code seems to be pain in the ass.
 
I have to say, I've never been tempted to reinvent the wheel and write my own OS. There's so much interesting stuff to do with asm in user-space. I did write a program that used iopl to get access to the parallel port, and used it turn on/off 8 LEDs wired up to the 8 data pins of the parallel port. That was enough "proof of concept" for me to believe that I'd grokked how CPUs talk to hardware.
 
@PeterCordes I'd agree on this as well.
 
@Sam: read Programming from the Ground Up, the free book that pootis linked. I think it covers all that stuff on the way to introducing a very very simple bit asm code, so you hopefully understand what's going on before they show more complicated asm examples.
 
Sam
So that book will help me learn about operating systems?
 
4:10 PM
Or learn to program in C. e.g. once you grok pointers in C, you're set. They work the same way in asm (but it's easier to confuse a pointer with a value, because there's no compiler).
@Sam: yes, I think so. Or at least the basics you need to understand to learn much from writing an OS as a hobby project. You might be able to get something to boot and print messages by copy/pasting examples, but you won't learn as much if you don't understand how computers really work.
 
Sam
I don't know how deep I need to go for writing an OS, is it linked to the different hardware like motherboard, hard drive?
Which exactly should I be reading?
 
4:26 PM
OS Theory.
 
Sam
which is that out of the 4 links...
 
They're just different formats. Download the latest version (the last link)
 
@Sam: you don't need a spare computer to develop an OS. It's much easier to run it in a virtual machine / emulator, like bochs. That lets you set breakpoints and single-step / examine registers even in bootloader code. On real hardware all you get is "works" / "fails", and maybe something on the screen or not.
I'd start with writing asm as normal program that runs under an existing OS, though. Managing stuff like the IDT / GDT and BIOS calls requires being able to write working code, and learning in user-space where debugging is easy will teach you that.
 
 
3 hours later…
7:06 PM
I'm writing an OS right now, however I'm still stuck at loading the kernel ;-;
 

« first day (189 days earlier)      last day (530 days later) »