C or assembler or something else

Good morning all,

I was wondering what the textfiles that we modify when making changes are written in.

Are the text files "the operating system" and if so what are they written in? C, assembler or something else?

Also, I have an interest in device drivers even though I'm still a beginner. What language is used to write them and which would I be better learning first?

Regards,
Nick
 
I don't understand your first two sentences. "What are the text files written in, C, assembler, or something else?" They are just plain text files...

Device drivers are mostly written in C, with sometimes a couple of routines in assembly language. But it will depend on the device you're writing a driver for. If you wan to learn more about device drivers, there is a book on it (though it is for Linux): Linux Device Drivers, Third Edition.
 
I don't understand your first two sentences. "What are the text files written in, C, assembler, or something else?" They are just plain text files...

Device drivers are mostly written in C, with sometimes a couple of routines in assembly language. But it will depend on the device you're writing a driver for. If you wan to learn more about device drivers, there is a book on it (though it is for Linux): Linux Device Drivers, Third Edition.
Sorry about the wording I wasn't sure how to phrase what I meant.

I mean to ask, if I wanted to learn about the operating system and how to modify it, what language would I need and where should I start? I was assming the text files were the operating system.
Second question then, what are the text files and how do they work?
Thanks Nick
 
If you want to learn about operating system programming, you should know the C programming language. See also this thread: https://forums.freebsd.org/threads/tutorials-for-freebsd-system-programming.69964/#post-420616

But if I were you, I would start with more easy projects because OS programming is extremely hard.
I've got a raspberry pi and a few arduinos to practice on (I don't want to do anything risky on my laptops). I've been going through Sams C in 1 hour a day but it's not very intuative. I've also been trying my hand at assembly on the raspberry pi using the Robert Dunne book but I'm having to stop periodically to watch youtube videos to explain the concepts. I'm fine with binary and Hex but am currently trying to get my head round bit shifts and which registers do what. If you can explain bit shifts i.e. logical, arithmetical etc... I'd be very grateful.
Regards
Nick
 
If you can explain bit shifts i.e. logical, arithmetical etc... I'd be very grateful.
I can search for a good tutorial. I learnt this stuff in Peter Norton's book. When I'm at home, I'll look up the title. The book is ancient but it's still one of my favorite books to learn assembly language. It explains assembly language programming and guides you into writing a complete program. So you will learn concepts of how to program & test your program along the way.
 
I can search for a good tutorial. I learnt this stuff in Peter Norton's book. When I'm at home, I'll look up the title. The book is ancient but it's still one of my favorite books to learn assembly language. It explains assembly language programming and guides you into writing a complete program. So you will learn concepts of how to program & test your program along the way.
That would be a massive help if you could. I'll plod along with the Robert Dunne book until then. Many thanks Nick
 
I was wondering what the textfiles that we modify when making changes are written in.

In ASCII (that is letters, numbers and symbols), formatted a particular way so that whatever is referring to it may understand it.

Are the text files "the operating system"

No.

Also, I have an interest in device drivers even though I'm still a beginner. What language is used to write them and which would I be better learning first?

I'd start with learning about combinatorial logic, sequential logic, and binary arithmetic. Then move onto C and maybe assembly. Get hold of some recommended first year college textbooks on computer engineering.

Going by your questions above, you need to start from the basics - you don't know what you don't know (which is not a bad thing, many programmers have never studied logic and have no idea how the hardware actually works). Good luck with it, let us know how you get on :)
 
I can search for a good tutorial. I learnt this stuff in Peter Norton's book. When I'm at home, I'll look up the title. The book is ancient but it's still one of my favorite books to learn assembly language. It explains assembly language programming and guides you into writing a complete program. So you will learn concepts of how to program & test your program along the way.
I think I may have found that book on amazon. Is it called Peter Nortons assembly language for the IBM PC? If it is and it has a puple/blue cover then it's the one I'm looking at. It's going cheap but I suspect by this point the disk won't be included. Would the exercises in the book still work on a modern laptop?
 
Would the exercises in the book still work on a modern laptop?

Sort of. To get it to work on a modern laptop you'd need DOS and a DOS assembler.

I would also look at Assembly Language Step by Step by Jeff Duntemann

It's great for beginners. It uses the Insight debugger which can be installed by following the steps on this page (confirmed working on Ubuntu 19.04 beta, would probably work on BSD although I haven't tested it yet):
http://www.dalfonso.co/2016/04/23/setting-insight-debugger-on-ubuntu-16-04-lts/
 
tenchu That's pretty old but not worthless. Modern CPUs are very complicated but you said you'd be using a Raspberry Pi. No one needs to use every instruction available on a microprocessor, especially when starting to learn, but things like out of order execution, caching and so on can make assembly programming really intense. fwiw, I started life building computers from the TTL chip level using bit-slice processors, toggle switches, assembly language and all that.

I'm going to see if I have links to some resources including online books that are still relevant. I probably do but I'd have to wade through a lot of things to find them. I'll edit this post as I find them and in no particular order.





I couldn't immediately find any book links as I thought. Those links might keep you busy enough for now but I have tons more that are not necessarily tutorials.
 
Sort of. To get it to work on a modern laptop you'd need DOS and a DOS assembler.

I would also look at Assembly Language Step by Step by Jeff Duntemann

It's great for beginners. It uses the Insight debugger which can be installed by following the steps on this page (confirmed working on Ubuntu 19.04 beta, would probably work on BSD although I haven't tested it yet):
http://www.dalfonso.co/2016/04/23/setting-insight-debugger-on-ubuntu-16-04-lts/
How would I get my hands on DOS or DOS assembler? I have three laptops, one with windows 10 one with ubuntu and one with BSD. Which would be best to install it on?
 
If you want to write software ... do not begin with an OS. It is extremely hard.
And do not begin with C. It is a hard language to learn, and an extremely hard language to learn to program well in.
And don't waste your time on assembly. It is very rarely used today, and a very frustrating way to learn to program.

In addition to the other thread that tommiie linked to above, read this thread: https://forums.freebsd.org/threads/startpoint-to-programming-with-assembly.70006/

In the last few weeks, there have been LOTS of queries from new forum members about how to program in C, in assembler, at the device driver level, in the kernel, using the Unix philosophy, with the least bloat, and similar queries. Most of the time, it is clear from the questions that the posters have no or vanishingly little programming, computer science, or software engineering experience (those are all separate fields). Trying to jump into the topics they want to work on with that level of experience is silly. It's like someone showing up and saying "I don't know how to swim, I have a fear of heights, I've never been more than 5cm off the ground, but I want to learn diving. How do I start the double sommersault with triple rittberger from the 10m tower? No, just no. If you climb up to 10m height and leap down with zero experience, you will at best be scared and wet (after the life guard fishes you out); at worst you will be seriously injured. If you try to write a device driver in assembly for a Unix environment, without extensive experience (probably a few years of study), you will just waste your and everyone else's time. Please don't. If you want to learn more about computers, get a few textbooks, read and understand them, and start with simple problems, using tools that are intended for learning.
 
How would I get my hands on DOS or DOS assembler? I have three laptops, one with windows 10 one with ubuntu and one with BSD. Which would be best to install it on?

Since you already have Ubuntu installed I'd recommend using Duntermann's book I listed above. It assumes no prior knowledge, and serves as a good introduction to computer engineering in general (the first half of the book), so would be suited to someone new to the field.

That said, answers to your question are just a google search away - get used to doing this, you'll be doing it all the time.
 
And do not begin with C. It is a hard language to learn, and an extremely hard language to learn to program well in.
And don't waste your time on assembly. It is very rarely used today, and a very frustrating way to learn to program.
The first language I learned was assembly and it made sense to me completely as a hardware guy who designed and built computers. I was dragged, kicking and screaming, into learning C cause the boss told us we had to. I thought C was unnecessary to replace assembly for us but times have changed. I still find C simpler to learn and use than any other language on the planet and, when I do break down and try to use or learn another, I get a voice in my head saying, "I feel like I'm writing C code but with a few different syntax changes. So why am I not just doing this in C?".

If one wants to learn how operating systems and processors work, then assembly and C are the best. To this day, I still visually think of how the address lines from the processor reach out to memory and return bits on the data lines. I am dumbfounded that people struggle so much with learning pointers as if it's the mystery of the universe and asked on hobbyist forums like reddit every day.
 
If you want to have a career in computer engineering (which is a field of study separate from software engineering and from computer science), then you really do need to understand how processors work. Today, that means not just understanding registers, PC, instructions, but more important memory models, parallelism, caching, and how IO works (which has gotten much harder since people like SirDice and me programmed on microprocessors in the late 70s). Yes, I cut my teeth in that era too, including building my own computer (from individual chips, like Z80s, memories, TTLs, and in one memorable case a Z280, all wire-wrapped), and writing the whole BIOS in assembly from scratch (including a caching floppy controller, I unfortunately never finished the SCSI driver).

Similarly, your statement is correct: If you want to program an OS, you really do need to understand the hardware at the level of a C programmer. That includes knowing what a pointer is, and why a pointer is not just an int.

But: If today you want to become a software engineer, even one who works on the kernel (I know lots of them, there is a group of a dozen kernel coders right next to me at work), you need to know a lot more. The really important skill is not the small bit of C syntax, or knowing words like address/register/pointer/load/compare-and-swap. The really important skill is thinking, working with other people, analyzing requirements, designing software, following a reliable and efficient software process, and most importantly how to see the little bit of C coding in the context of the overall engineering effort. For the software engineers I know, the actual "coding" part is a small part of their job. So focussing too much on learning C (or assembly or Ruby or whatever scripting or web language is popular this season) is silly; the important thing to learn is how to think and how to produce. And all software engineers I know program fluently in multiple languages, and learn new ones regularly.

And this is why it worries me that there are so many new programmers who think that C or assembly is the end-all, because it is "kernel" or "Unix philosophy" or some such nonsense.
 
Don't know the Fellesien... book. The Abelson book is EXCELLENT.

Completely agree on your comment of which language to learn with: It doesn't matter, use something that's good for learning. Once you know Scheme or Smalltalk or Python or Lego or ... and you are smart, you can learn C or assembly, but you will also have good taste.

But most importantly one needs to know software engineering. And I don't know any good current textbooks about that; I used to use the SEI CMM book (blue and red cover by Watts Humphrey) when I was teaching to young colleagues at work, but his other books are WOEFULLY out of date.

I still think the two best books about software engineering are: (a) the tar pit book (The Mythical Man-Month, by Fred Brooks) and (b) Peopleware, by DeMarco and Lister. That's because they describe the sociological process of multiple people working together. This is the hard part, which is still often not well solved. Too many software development departments are staffed with autistic mavericks, all of whom are really smart and good at coding and good at solving computer puzzles, but incapable of following direction, and incapable of dealing with other stakeholders (like colleagues, users, vendors, finance, ...).
 
Good evening everyone,

I seem to have a lot of responses here so I shall try to address them all by explaining my position. I'm a maths student (mature student) and am looking for a career that I can apply myself to, as no one will pay me to sit and do maths (when I graduate). I do have coding and IT experience although it is well out of date. I did an AVCE back in 2000-2002 which is a 2 year college level course (I don't mean uni if anyone here is from USA I'm not sure what your equivalent of college is). It was all applied and covered things like programming in VB6, creating web pages, so html javascript and such, creating databases and applications. Most of what I learned and used is now obsolete. I enjoyed the VB stuff but hated all the creative 'oh what about this colour scheme' stuff to do with design, which was why I dropped it as a subject decades ago. I have only recently gotten back into it after using maths programs and realising there were things to do in languages such as python and C which interested me (lots of maths and algorithms). I purchased a raspberry pi and one or two arduinos but find the books on the market which 'help' beginners woefully inadequate. I'll be selling them once I have the motivation to open an ebay page. I purchased second hand copies of my old AVCE text books to get my head back in the game i.e. systems analysis and good coding practice. I find the abstraction element of computer science a bit off putting because I like to see exactly how something works and every book I've purchased so far either skirts round topics or just doesn't cover them properly. I would like to get more involved with low level coding but the hardware side of things is hard to get my head around. I suspect this is down to poor quality learning materials. I know this can be the case as I have taught various subjects usually languages such as german and have found grammar explanations to be quite poorly explained for beginners, and suspect computing texts are not immune to having poor authors. That said, Imay have to reconsider my career options if I cannot get my head around the hardware and assembly because I highly suspect that being a programmar without hardware knowledge is like being a doctor with no knowledge of anatomy.
 
Add to the above, I have tried going through some of the comptia A+ and Network+ books get a basic idea of the underlying hardware and they almost made me want to give up. None of them explain the hardware properly or even the abstract concepts for that matter such as the OSI model or TCP/IP. I have asked about on the forums here for advice on tcp/ip but don't really 'get' the answers. I wouldn't say I was particularly dim or thick as I can handle calculus and algebra pretty well and am on track for a first. Maybe an IT career is just not for me. I'll see how this year goes and if I'm any further forward.
 
would starting with something like python be a better idea than going straight for C? I was assuming going for C first would give me a better overview and understanding of 'whats going on'. If starting with python wouldn't necessarily put me at a disadvantage I would quite happily take up the idea.
 
(I don't mean uni if anyone here is from USA I'm not sure what your equivalent of college is).
I think the AVCE was roughly equivalent to the 6th form, and as such 11th and 12th year of school. In the US, that is still high school. Although in US high schools there is rarely subject specialization into the "industrial arts". From the viewpoint of the AVCE being a pre-university education in real-world job skills that doesn't lead to an academic degree such as a bachelor, it is roughly comparable to a junior college or community college in the US. Those are institutions that come after high school, and prepare students either for a career (such as nursing, law enforcement, IT, forestry), or teach general education with the intent of later transferring that to a "college" (a.k.a. 4-year school).

... things like programming in VB6, creating web pages, so html javascript and such, ...
Good. General computer skills, not necessarily hard-core programming or software engineering.

I purchased a raspberry pi ...
Great machine to experiment on. Install Raspbian, comes with compiler and linker for C, and with Python, and start programming. If you like to tinker with hardware, you can attach a few LEDs, displays, sensors, and actually build things that are somewhat useful. The nice thing about the Pi is that it is as cheap as a small embedded system, and can do real-world IO (switches and LEDs), but on the other hand has a complete full OS and development environment on it.

Arduino, on the other hand, is a different beast. That's an embedded system, and the skills of coding it are not similar to those used on "computers".

I find the abstraction element of computer science a bit off putting because I like to see exactly how something works and every book I've purchased so far either skirts round topics or just doesn't cover them properly.
Stop right there. Computer science and engineering are all about abstraction, virtualization, and not worrying about the details. Even in a low-level language like C, you don't need to know what the address and data pins on the CPU are doing, how exactly that byte went from the RAM chip to the register, and which instructions were executed to write "while (*p++ = *q++);". If you try to think about even simple 100-line programs at the level of pins, signals, gates, and voltages, you will never get done. Yes, there is work at those levels, but that work is done by chip designers. You need to get comfortable with abstractions. For example, when you type in a Python program at the command line (using the little code editor that opens when you just say "python"), for each statement you type in, the actual CPU executes millions of instructions. And that's a good thing. You want to be able to say "in this language, I can sort most types of containers like arrays by just saying sorted(container)", without worrying about how this works.

At some point, if you want to get a real CS degree, you will have to learn some of these details. For example learn about sorting algorithms, which ones are efficient, and formally prove that you can't get better than O(n*log n). But before that, you need to learn to program.

... that being a programmar without hardware knowledge is like being a doctor with no knowledge of anatomy.
Now, it is like being a doctor with only partial and superficial knowledge of quantum mechanics. In the end, all chemistry is quantum mechanics. And doctors do study a little bit of organic chemistry. But they don't need a PhD in physics.

One of the nice things about my generation is that we grew up when CPUs were still chips, with identifiable pins. I could still put an oscilloscope on the address and data bus, and with a good storage scope or logic analyzer, see my program execute at the level of instructions and data. What we had already lost was the ability to see inside the CPU. People who grew up in the 60s were able to see every bit of state in the CPU (using the light bulbs on the console), and watch the hardware execute every addition. But in reality, even 50 years ago there were lots of programmers, and most of them hardly ever see the actual hardware. Today, on a Raspberry Pi, you can't even see the data any longer; there is a memory interface, and then serial buses for IO. The gap of abstraction between hardware and software has become a little larger.

I would start with a random computer (you already have the pi), and start coding in an easy-to-learn language. My favorite happens to be python, which is easy to learn yet powerful enough to be used in production. But there are many other choices. Find simple problems, and solve them.
 
Dear tenchu , these are my humble suggestions after reading the many things you wrote.

1] I reccomend you try to find a problem and just solve it. That is be best way to learn everything, just solve a damn problem. Often, the choice of language is a consequence of your problem, not an a priori.

2] I completely understand your desider to understand the "real" things underneath. But consider, some times the real thing is a just a formal set of rules. Take Web programming, it has nothing to do with electronics, flip-flops, assembly and so on. There is Javascript, HTML, CSS. That is your universe, you can't go beyond that. Other stuff is build OVER those 3 building blocks, in some sense these are your electronics, assembly and C.

3] A consequence of point [2] is that i reccomend you start your journey from web-programming (not server side, on browser code execution). What you will need to learn is limited/controllable, what you will learn is usefull and in high demand. Also, it could serve you as a bridge to attack the server side, still, using the same language, Javascript, in its Node incarnation. ... But with time, don't attack the server side now.

3.1] The server side will bring you new problems to solve, the management of an operating system, automation of recurrent tasks, the necessity to learn some networking and the principles of security. It will all come out almost naturally. This will push you to learn a scripting language, most probably: sh, Ruby, Python, Perl, Awk, etc.

4] In case you are not fascinated by web programming at all and you are really intrigued by eletronics. Then i reccomend you start with Arduino and C. But, you will need to start learning basic electronics as well, or what you can achieve is just turn on/off the onboard arduino led. AFAIK There is not much demand for this kind of knowledge on the market. Also, an Elec. Eng. will pretty much burn you on this hand down, always.

5] In case you are fascinated by the assembly ... well, If you buy a BeagleBone Black you can enjoy programming the two PRU units in assembly. It is quite fun. The processors PRU are simple enough to be enjoyable. Book reccomended, if you want to pursue this way, is "Molloy - Exploring Beagle Bone". I warn you, the book is good, you must be highly motivated.

6] I reccomend you do not start your learning with "Structure and Interpretation of computer programs". It is a wonderfull book, but not for beginners. This is just my opinion. A small motivation. The authors push a style of programming called functional, where basically you try to avoid changing the state of variables. Algorithms are written deploying recursion as much as possible. If you like proofs by mathematical induction you may like it. Read it after you already know programming, you may find it a damn fascinating read.

7] Don't you think it could be cool if your phone could do X for you ? .... A good way to enter phone dev. this is more difficult than Web programming, but still, very interesting and with a market. Here Java is dominant. Apple has his own tools.

In conclusion, choose a problem you consider interesting, or an area you find interesting, the programming
language comes after it, as a consequence.

hope it helps, I am also a mathemtician, I learnt alone, but started 20 years after ralphbsz , in the 90, when computer came already without a manual. Blah.
 
I still think that a 1970s introduction to computing book is a great place to learn what is going on deep inside a computer. All computers did then was addition, comparison and moving numbers around. Computers today do the same but a billion times faster. A book of that era will tell you that computers don't subtract, they subtract by adding negative numbers. They multiply by repeatedly adding and shifting. Modern computers do the same. Calculating a pixel intensity in a raytracing program is just combining as few as few hundred thousand additions. A Text file is just a sequence of number. "Abc" on modern hardware is 65,98,99. Move a 65 to the right memory location and an "A" will show up on the screen.
 
Back
Top