Getting started with low level programming
Getting started with low level programming
Hi there,
I am a programmer and I have experience with high-level languages like C# and Java, but for a while I've been very interested in low-level programming. Or even better: Bare metal computing.
However, I don't have a clue on how to get started with this kind of stuff. I know real bare-metal programming is not really possible on modern computers (correct me if I'm wrong) so I was thinking about getting as low-level as it can get. I think that is the stuff you guys on this forum do all the time so that's why I've come here.
I was as less as possible layers between me and the hardware, so basically I want to write code that can be executed without an operating system.
Actually making an OS sounds very interesting to me, but it's not directly what I aim for, and I think I'm by far not ready for that.
I don't necessarily want to program a modern computer. Some other device like an old phone or something would be cool to (even cooler maybe?) but I guess it's even harder to access the lower level on those kinds of devices.
Does anyone have some tips for me? Fun things to try or advice to get me started with low-level computing?
Anything is welcome!
My thanks is advance,
Freek
I am a programmer and I have experience with high-level languages like C# and Java, but for a while I've been very interested in low-level programming. Or even better: Bare metal computing.
However, I don't have a clue on how to get started with this kind of stuff. I know real bare-metal programming is not really possible on modern computers (correct me if I'm wrong) so I was thinking about getting as low-level as it can get. I think that is the stuff you guys on this forum do all the time so that's why I've come here.
I was as less as possible layers between me and the hardware, so basically I want to write code that can be executed without an operating system.
Actually making an OS sounds very interesting to me, but it's not directly what I aim for, and I think I'm by far not ready for that.
I don't necessarily want to program a modern computer. Some other device like an old phone or something would be cool to (even cooler maybe?) but I guess it's even harder to access the lower level on those kinds of devices.
Does anyone have some tips for me? Fun things to try or advice to get me started with low-level computing?
Anything is welcome!
My thanks is advance,
Freek
Re: Getting started with low level programming
Hi,
Cheers,
Brendan
You can do "bare metal" on modern computers. People have even done raw machine code (because assembly language was too high level for them(!?) )..Freek wrote:However, I don't have a clue on how to get started with this kind of stuff. I know real bare-metal programming is not really possible on modern computers (correct me if I'm wrong) so I was thinking about getting as low-level as it can get. I think that is the stuff you guys on this forum do all the time so that's why I've come here.
Those layers are "layers of abstraction". You can write your own, or you can live without them. However, when you have to write device drivers for all the different storage devices and code to support all the different file systems in every single application, you'll quickly realise how silly life is without those abstractions, and (whether it's in the form of a binary with an API like a kernel, or in source code form like a library, or in some other form) you will end up writing your own "layers of abstraction".Freek wrote:I was as less as possible layers between me and the hardware, so basically I want to write code that can be executed without an operating system.
If you can't test your code, then you're screwed. What hardware do you have to test on? Are you willing to buy something else (e.g. maybe something like beagle board)? What would people use the application for, and what hardware are those people likely to have (or will you provide the hardware and software as a unified "thing")?Freek wrote:I don't necessarily want to program a modern computer. Some other device like an old phone or something would be cool to (even cooler maybe?) but I guess it's even harder to access the lower level on those kinds of devices.
Does anyone have some tips for me? Fun things to try or advice to get me started with low-level computing?
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: Getting started with low level programming
Thanks for your reply.
So those layers of abstraction are basically for portability? I don't think I should be worrying about that just yet.
I'll look in the the BeagleBoard thing. From what I've seen so far I assume it's something like the Raspberry PI?
Freek
Ok. Well I'm sure assembly is good enough for me. (:You can do "bare metal" on modern computers. People have even done raw machine code (because assembly language was too high level for them(!?) )..
Code: Select all
Those layers are "layers of abstraction". You can write your own, or you can live without them. However, when you have to write device drivers for all the different storage devices and code to support all the different file systems in every single application, you'll quickly realise how silly life is without those abstractions, and (whether it's in the form of a binary with an API like a kernel, or in source code form like a library, or in some other form) you will end up writing your own "layers of abstraction".
I'm not planning on writing applications that people are going to use for anything yet. It's more like experimenting for fun. I have an old laptop witch I don't need for anything else. Would that work?What hardware do you have to test on? Are you willing to buy something else (e.g. maybe something like beagle board)? What would people use the application for, and what hardware are those people likely to have (or will you provide the hardware and software as a unified "thing")?
I'll look in the the BeagleBoard thing. From what I've seen so far I assume it's something like the Raspberry PI?
Freek
Re: Getting started with low level programming
Hi,
Cheers,
Brendan
They're more for extensibility and project maintenance. For example, rather than having an application that talks directly to the hard disk controller (and breaks as soon as the storage device is something different and has to be rewritten), you could have an application that uses a "storage device driver API" (and a device driver that implements that API) and then write more "storage device drivers" whenever you like without breaking anything.Freek wrote:So those layers of abstraction are basically for portability? I don't think I should be worrying about that just yet.Those layers are "layers of abstraction". You can write your own, or you can live without them. However, when you have to write device drivers for all the different storage devices and code to support all the different file systems in every single application, you'll quickly realise how silly life is without those abstractions, and (whether it's in the form of a binary with an API like a kernel, or in source code form like a library, or in some other form) you will end up writing your own "layers of abstraction".
That could work fine.Freek wrote:I'm not planning on writing applications that people are going to use for anything yet. It's more like experimenting for fun. I have an old laptop witch I don't need for anything else. Would that work?What hardware do you have to test on? Are you willing to buy something else (e.g. maybe something like beagle board)? What would people use the application for, and what hardware are those people likely to have (or will you provide the hardware and software as a unified "thing")?
Yes, it's very similar (in concept) to Raspberry PI - basically, a cheap ARM thing slapped on a low cost development board for people to experiment with.Freek wrote:I'll look in the the BeagleBoard thing. From what I've seen so far I assume it's something like the Raspberry PI?
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: Getting started with low level programming
The most "bare-metal" you can possibly get is writing bytes to a floppy disk, and inserting it into a machine and turning it on. (You just need to know what all those bytes "mean" to the computer running it.)Freek wrote:I am a programmer and I have experience with high-level languages like C# and Java, but for a while I've been very interested in low-level programming. Or even better: Bare metal computing.
However, I don't have a clue on how to get started with this kind of stuff.
You would be insane to go this route.
With that being said, here is a link to how I did it.
https://ozone.codeplex.com
Here as a lengthy discussion thread on my project:
http://forum.osdev.org/viewtopic.php?f=15&t=27971
In short, I am using XML, XSD, and XSLT files to convert XML elements into bytes that are written out to disk. I've enumerated all (or most) of the CPU instructions for several platforms, including x86, Commodore 64, Nintendo Entertainment System, Super NES, GameBoy, GameBoy Advance, Atari 2600, Raspberry Pi, Java JVM, and .NET CLR. I have sample projects for most of these showing how to get started, but I've focused most of my time toward x86 32-bit development.
I created all of this as an alternative to using ASM, when I discovered that there are no good development IDEs out there for ASM development. Using XML has the advantage of having a large list of editors that provide a lot of the functionality that you would get in a modern development environment / language -- Tooltips, documentation, autocomplete, intellisense, namespaces, jump-to declaration, etc.
So, if you are looking for something higher-level than writing byte codes in a hex editor, but lower level than ASM instructions, you may want to take a look. Especially if you are not already an expert in Assembly language. You may find it easier to learn than the console based ASM compilers from 30 years ago.
I should also mention that there are a few OS projects on this site that are written in pure Java and/or pure C#. You may want to consider going this route, instead.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Re: Getting started with low level programming
Install FreeDOS, it's a simple OS that doesn't provide protection like the modern OS's.Freek wrote: I have an old laptop witch I don't need for anything else. Would that work?
Programming in DOS is the closest you'll get to direct hardware control while still having a memory and filesystem library. Using DPMI you can easily switch to protected mode and have a large address space and using VBE you can use frame buffers for writing straight to video. If you wanted to have lower level disk access you could use the BIOS for sector reads and writes or you could write directly using the FDC and DMA.
There is plenty of old documentation and here's something to give you an idea of the devices you can control in DOS.
"God! Not Unix" - Richard Stallman
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Getting started with low level programming
Or simpler, DOSBox, because you don't need to reboot that (although a VM might be a more accurate choice).b.zaar wrote:Install FreeDOS, it's a simple OS that doesn't provide protection like the modern OS's.Freek wrote: I have an old laptop witch I don't need for anything else. Would that work?
Re: Getting started with low level programming
Why not install real DOS (with rufus) on USB stick and boot from it? Also, DOS is closest to Hardware and Boots faster.Combuster wrote:Or simpler, DOSBox, because you don't need to reboot that (although a VM might be a more accurate choice).
Re: Getting started with low level programming
Combuster wrote: because you don't need to reboot that.muazzam wrote:Why not install real DOS (with rufus) on USB stick and boot from it? Also, DOS is closest to Hardware and Boots faster.Combuster wrote:Or simpler, DOSBox, because you don't need to reboot that (although a VM might be a more accurate choice).
Also, DOS does not necessary boot faster (than other OS) if you count the stuff done with config.sys and autoexec.bat, especially the long pause with cdrom driver.
And I doubt loading DOS from USB stick (i.e. BIOS disk service) would be faster than loading dosbox on top of DMA and cache-enabled OS.
Re: Getting started with low level programming
Who would use DOSBox for anything useful? =)Combuster wrote:Or simpler, DOSBox, because you don't need to reboot that :wink: (although a VM might be a more accurate choice).b.zaar wrote:Install FreeDOS, it's a simple OS that doesn't provide protection like the modern OS's.Freek wrote: I have an old laptop witch I don't need for anything else. Would that work?
"God! Not Unix" - Richard Stallman
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
Re: Getting started with low level programming
Just because you don't have anything useful to run or debug in DOS/DOSBox, it doesn't mean nobody else does. I, for one, have been running the DOS version of my compiler under it. I need to test the DOS version of my standard C library and DOSBox helps me do that. I'm sure there are useful programs that were never ported to Windows and Linux that people still want to run, be it old games or something else.b.zaar wrote:Who would use DOSBox for anything useful? =)
Re: Getting started with low level programming
Yeah sorry it was sarcasm. I'm working on BoxOn, an emulator forked from DOSBox.
"God! Not Unix" - Richard Stallman
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
Re: Getting started with low level programming
I use DOSBox to play Sim Towerb.zaar wrote:Who would use DOSBox for anything useful? =)Combuster wrote:Or simpler, DOSBox, because you don't need to reboot that (although a VM might be a more accurate choice).b.zaar wrote:
Install FreeDOS, it's a simple OS that doesn't provide protection like the modern OS's.