C or assembler or something else

tenchu

Member

Reaction score: 7
Messages: 35

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
 

tommiie

Member

Reaction score: 26
Messages: 93

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.
 
OP
OP
T

tenchu

Member

Reaction score: 7
Messages: 35

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
 
OP
OP
T

tenchu

Member

Reaction score: 7
Messages: 35

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
 

tommiie

Member

Reaction score: 26
Messages: 93

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.
 
OP
OP
T

tenchu

Member

Reaction score: 7
Messages: 35

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
 

pyret

Member

Reaction score: 41
Messages: 66

In another thread my recommendations included "Operating System Design: The Xinu Approach, Second Edition," by Douglas Comer, which is used at Purdue University; and "Principles of Operating Systems: Design + Applications," by Brian L Stuart, who uses Inferno to teach his operating systems courses at Drexel University.

Stuart's book delves into topics like scheduling, process management, I/O device management, memory management, etc., but is unique in that a chapter first gives an overview of say, process management, then the next chapter will cover process management in Inferno, and the next chapter will cover process management in Linux. Then onto the next topic. I cannot over emphasize the quality of this book.

In chapter 7, "Process Management in Inferno," this is exercise 6: "Modify Inferno so that process ID numbers are reused when the counter rolls over. You should make sure that no two processes simultaneously have the same PID. At the same time, make sure that a process ID is not reused until all other ones have been used."

In chapter 11, "Memory Management in Inferno," this is exercise 7: "Modify Inferno to do worst-fit memory allocation instead of best-fit allocation."

Inferno was developed for embedded devices and based on Plan 9 from Bell Labs. Of course, Plan 9 originated in the mid-80s by the creators of UNIX who wanted to correct some of the problems they saw in UNIX. Inferno can run either on bare metal or hosted.
 

BubbaMc

New Member

Reaction score: 1
Messages: 3

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 :)
 
OP
OP
T

tenchu

Member

Reaction score: 7
Messages: 35

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?
 

BubbaMc

New Member

Reaction score: 1
Messages: 3

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/
 

drhowarddrfine

Son of Beastie

Reaction score: 1,093
Messages: 3,017

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.
 
OP
OP
T

tenchu

Member

Reaction score: 7
Messages: 35

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?
 

ralphbsz

Daemon

Reaction score: 929
Messages: 1,490

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.
 

BubbaMc

New Member

Reaction score: 1
Messages: 3

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.
 

drhowarddrfine

Son of Beastie

Reaction score: 1,093
Messages: 3,017

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.
 

ralphbsz

Daemon

Reaction score: 929
Messages: 1,490

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.
 

pyret

Member

Reaction score: 41
Messages: 66

the important thing to learn is how to think and how to produce.
"How to Design Programs: An Introduction to Programming and Computing, 2e" by Matthias Fellesien, Robert Bruce Findler, Matthew Flatt, Shriram Krishnamurthi was developed by computer science educators for that purpose.

"Structure and Interpretation of Computer Programs, 2e" by Harold Abelson and Gerald Jay Sussman was used at MIT for years in their first course of programming and it uses Scheme.

I don't think anyone would claim an MIT graduate, or Northwestern, Northeastern, the University of Utah, or other schools who learned Scheme was less capable and qualified as a software engineer than one who learned using Java, C, or Assembly. There are valid reasons why they chose and choose to use Scheme to teach programming principles and design.
 

ralphbsz

Daemon

Reaction score: 929
Messages: 1,490

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, ...).
 
OP
OP
T

tenchu

Member

Reaction score: 7
Messages: 35

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.
 
OP
OP
T

tenchu

Member

Reaction score: 7
Messages: 35

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.
 

pyret

Member

Reaction score: 41
Messages: 66

"Introduction to Computing Systems: From bits & gates to C & beyond" by Yale Patt and Sanjay Patel may be what you're looking for.
Introduction to Computing Systems: From bits & gates to C & beyond, now in its second edition, is designed to give students a better understanding of computing early in their college careers in order to give them a stronger foundation for later courses. The book is in two parts: (a) the underlying structure of a computer, and (b) programming in a high level language and programming methodology.
To understand the computer, the authors introduce the LC-3 and provide the LC-3 Simulator to give students hands-on access for testing what they learn. To develop their understanding of programming and programming methodology, they use the C programming language. The book takes a "motivated" bottom-up approach, where the students first get exposed to the big picture and then start at the bottom and build their knowledge bottom-up. Within each smaller unit, the same motivated bottom-up approach is followed. Every step of the way, students learn new things, building on what they already know. The authors feel that this approach encourages deeper understanding and downplays the need for memorizing. Students develop a greater breadth of understanding, since they see how the various parts of the computer fit together.
 
OP
OP
T

tenchu

Member

Reaction score: 7
Messages: 35

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.
 

ralphbsz

Daemon

Reaction score: 929
Messages: 1,490

(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.
 
Top