Is writing a bootloader a good way to be introduced to asm?
Is writing a bootloader a good way to be introduced to asm?
I was pondering on what the best way of learning assembler (as a novice programmer) would be. What do you think? I personally find interfacing with Windows or Linux to be troublesome at best, which really only leaves DOS development(who these days has DOS installed?) and bootsector creation. Is there some other method I'm missing? What are your opinions on it? How did you learn assembly?
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Re: Is writing a bootloader a good way to be introduced to asm?
I learned assembly on the TI-83+. I learned x86 assembly writing bootsectors, and found it was in some ways more restrictive but in others I had glorious freedom. I would probably say write bootsectors since the only restrictions on format are the bootable sig at the end and a filesystem structure if you want to keep it (though for early work I wouldn't bother).
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
Re: Is writing a bootloader a good way to be introduced to asm?
Depends whether you want to learn assembly, or x86 assembly in particular. I'm not sure of the best way to go about learning the latter, but the former is easy in my opinion. The best way to learn assembly is to program microcontrollers.
Re: Is writing a bootloader a good way to be introduced to asm?
i started out learning the registers, then the instructions, all in 16 bit first, then made random things out of them, how to get input, how to manipulate the input information, then learned osdevelopment in assembly, and it went from there. srry if im telling my stupid stories lol but thats how it worked for me. and plus i couldnt of done it without this forum
Re: Is writing a bootloader a good way to be introduced to asm?
It could be a good way probably only if you have some assembly experience for other platforms.
In the same way that writing a full protected mode kernel will completely limit you when you are just starting, writing a bootloader won't be the more natural way to go.
I started reading and writing some cooked code to reset the PC by jumping to something like FFFF:0 (I read it in the QUE's Upgrading and Repairing PCs, 2nd Edition, and such old books seem to be much better than the new ones, they always shared several useful things freely and one could truly learn), and some mouse code to invoke the mouse driver under DOS to use with Turbo C and BGI graphics.
-----------------------------
But it would be better if you said what you already know about assembly and what you expect being able to do or what you want to do that is practical.
In the same way that writing a full protected mode kernel will completely limit you when you are just starting, writing a bootloader won't be the more natural way to go.
I started reading and writing some cooked code to reset the PC by jumping to something like FFFF:0 (I read it in the QUE's Upgrading and Repairing PCs, 2nd Edition, and such old books seem to be much better than the new ones, they always shared several useful things freely and one could truly learn), and some mouse code to invoke the mouse driver under DOS to use with Turbo C and BGI graphics.
-----------------------------
But it would be better if you said what you already know about assembly and what you expect being able to do or what you want to do that is practical.
YouTube:
http://youtube.com/@AltComp126
My x86 emulator/kernel project and software tools/documentation:
http://master.dl.sourceforge.net/projec ... 7z?viasf=1
http://youtube.com/@AltComp126
My x86 emulator/kernel project and software tools/documentation:
http://master.dl.sourceforge.net/projec ... 7z?viasf=1
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Is writing a bootloader a good way to be introduced to asm?
Learning assembly under x86 Linux isn't very hard. You don't need to complicate things using the C standard library, and use sys_write, sys_read and sys_exit only (via INT 80h). Focus on implementing algorithms, using jump tables and so on, and create text filters like hex converters, calculators, etc.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
- 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: Is writing a bootloader a good way to be introduced to asm?
I think writing assembly for dos (via dosbox) is the easiest way to get to know x86 best - you can use system calls, you can access hardware directly, and you'll be able to practice ISRs. Writing asm under linux requires that you have a linux installation, and does not teach you what assembly is actually meant to do, but rather tends to learn you how to be your own C compiler IMO...
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Is writing a bootloader a good way to be introduced to asm?
Indeed but DOS is a 16-bit real mode OS and most assembly code out there is 32-bit (yes, people use assembly for things other than boot loaders sectors). The answer depends on the needs of the programmer. Then again, once s(he) has the proper mindset (i.e., understands addressing, registers and knows some instructions) it probably doesn't matter which one s(he) practiced, s(he) will be able figure things out easily on h(is/er) own.
I didn't use K&R to learn C, I knew Pascal and saw some C code. I didn't use and book on assembly, not even the Intel ones at first; I've read a crappy tutorial I found on the Internet (part of PC-GPE, the VLA series in particular) and played around with VBE under DOS. My point is that even though the right material may speed up the learning process, people are usually smart enough to do without them. All they need in this case is the initial boost before they can jump into the Intel manuals.
I didn't use K&R to learn C, I knew Pascal and saw some C code. I didn't use and book on assembly, not even the Intel ones at first; I've read a crappy tutorial I found on the Internet (part of PC-GPE, the VLA series in particular) and played around with VBE under DOS. My point is that even though the right material may speed up the learning process, people are usually smart enough to do without them. All they need in this case is the initial boost before they can jump into the Intel manuals.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Is writing a bootloader a good way to be introduced to asm?
I find that the most important factor in learning any language is to have a project to use the language on, instantly. So I would definitely say that programming a bootsector in asm is an excellent way to start. Don't worry about the "limitations" of a bootsector at first. Look at a few bootsectors to see what opcodes are commonly used, look up what they do, and start coding your own.
Re: Is writing a bootloader a good way to be introduced to asm?
Yea, this is what I did before writing Assembly.. I feel like it complicates matters too much though because you can't write a good virtual machine without understanding what a good virtual machine does..
Also, I'm considering writing a tutorial (or series of) to try to explain assembly as a first programming language, while keeping the person from losing hope. Real mode is way easy to me anyway... I mean, switch to using graphics with like 3 instructions, read from the disk with 3 instructions.. It's a very free standing environment, which makes it rather fun because there are so few standards to conform your code to. Of course.. first lesson "NEVER use `mov dl,0x80 \ int 0x10` as funny joke on your friends"
I like the idea of DOS also because it's basically like a superset of bootloader writing. You have all of BIOS, plus the DOS interrupts.. I think dosbox may be a good path to go with this in the beginning and then eventually step off to bootloader writing..
Re: Is writing a bootloader a good way to be introduced to asm?
I think any new language should first be practiced on some comparatively simple tasks in a developer-friendly environment (read, userspace).
Write a "Hello, World". Learn how to interface with other ASM modules, or how to call library functions. Practice with the various adressing modes. Write a counting loop (for), a conditional loop (while), a conditional execution (if). Learn how to handle integers and strings. Work with some primitive data structures (arrays, tables, lists). Learn about the features of your assembler (defines, macros, pragmas, whatever). Get to know the tools at your disposal (disassembler).
Only then set out to do something non-trivial.
Bottom line:
No, writing a bootloader is definitely NOT a good way to be introduced to ASM.
Spare the flames, OP asked my opinion and I gave it.
Write a "Hello, World". Learn how to interface with other ASM modules, or how to call library functions. Practice with the various adressing modes. Write a counting loop (for), a conditional loop (while), a conditional execution (if). Learn how to handle integers and strings. Work with some primitive data structures (arrays, tables, lists). Learn about the features of your assembler (defines, macros, pragmas, whatever). Get to know the tools at your disposal (disassembler).
Only then set out to do something non-trivial.
Bottom line:
No, writing a bootloader is definitely NOT a good way to be introduced to ASM.
Spare the flames, OP asked my opinion and I gave it.
Every good solution is obvious once you've found it.
Re: Is writing a bootloader a good way to be introduced to asm?
Solar couldn't be more correct here. Take everything he said, place it [here] and include that I suggest that you write a simple hex editor.
Yes, I see that you have proven it, but my question was, 'How did you know that would work?'.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Is writing a bootloader a good way to be introduced to asm?
And those two posts combined are pretty much what I suggested.
EDIT: Oh damn, I said hex converter.
EDIT: Oh damn, I said hex converter.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Is writing a bootloader a good way to be introduced to a
I have put a VGA sample in the "Samples" section of my "LowEST" project here (by now, the 7th element of the table of contents, it's a container):
http://126.sytes.net/projects/x86/OS/LowEST/index.html
In that example, you can see how to use that set of DOS.COM programs to fill the screen in the default 640x480 16-color VGA graphics mode from a .BAT script.
It also contains assembly source equivalent so that you can compare and better understand what each step means and does.
I will try to eventually put several useful examples to document the most basic PC features being programmed with assembly, and doing the programming independent from DOS, using it like nothing more as a shell and using it for "irrelevant" parts of programming.
It always help me catch errors like specifying wrong addresses as soon as I execute them in the step-by-step process, which reduces the effort needed to make a functional snippet.
http://126.sytes.net/projects/x86/OS/LowEST/index.html
In that example, you can see how to use that set of DOS.COM programs to fill the screen in the default 640x480 16-color VGA graphics mode from a .BAT script.
It also contains assembly source equivalent so that you can compare and better understand what each step means and does.
I will try to eventually put several useful examples to document the most basic PC features being programmed with assembly, and doing the programming independent from DOS, using it like nothing more as a shell and using it for "irrelevant" parts of programming.
It always help me catch errors like specifying wrong addresses as soon as I execute them in the step-by-step process, which reduces the effort needed to make a functional snippet.
YouTube:
http://youtube.com/@AltComp126
My x86 emulator/kernel project and software tools/documentation:
http://master.dl.sourceforge.net/projec ... 7z?viasf=1
http://youtube.com/@AltComp126
My x86 emulator/kernel project and software tools/documentation:
http://master.dl.sourceforge.net/projec ... 7z?viasf=1