What does 'mov ah, 0x0e' mean and do?
-
- Posts: 2
- Joined: Fri Nov 25, 2016 2:42 pm
- Libera.chat IRC: 2003
What does 'mov ah, 0x0e' mean and do?
I am learning to make a very basic operating system. (I'm only 13) But I don't understand something. What does mov ah, 0x0e mean and why is it needed to print characters on the screen?
Last edited by jordanbaron12 on Fri Nov 25, 2016 3:25 pm, edited 1 time in total.
-
- Member
- Posts: 5513
- Joined: Mon Mar 25, 2013 7:01 pm
Re: What does 'int 0x10' mean and do?
The INT instruction calls an interrupt handler.jordanbaron12 wrote:What does int 0x10 mean
You don't need INT 0x10 to display characters on the screen.jordanbaron12 wrote:and why is it needed to print characters on the screen?
-
- Posts: 2
- Joined: Fri Nov 25, 2016 2:42 pm
- Libera.chat IRC: 2003
Re: What does 'mov ah, 0x0e' mean and do?
Oh shoot. Wrong line of code. I'm sorry, I edited my post so you can delete your reply.
- Schol-R-LEA
- Member
- Posts: 1925
- Joined: Fri Oct 27, 2006 9:42 am
- Location: Athens, GA, USA
Re: What does 'mov ah, 0x0e' mean and do?
It's still basically the same answer, because INT 0x10 is the interrupt vector for the majority of the standard BIOS routines; the value 0x0E (which is 14 decimal) is the number of the specific Basic Input/Output Service (BIOS) operation known as "Teletype Output", which puts a single character in into the current text video buffer and advances a hidden pair of x,y values by one.
In other words, it prints one character of text the the console in text mode, and moves the cursor to the next position.
However, as Octocontrabass said, it isn't actually necessary; it just happens to be convenient when writing a boot loader, because, well, it's already there to be used. It isn't the only way to write text to the console, nor the best way, or even a particularly good way, but it is the easiest way when you are trying to cram as much as you can into a 512 byte boot sector, so if your boot loader is sending something to the text console, that's usually the way you would do it.
Mind you, most first stage boot loaders only use any text output when you are debugging them (yo would take it out later to save space, usually), and even that's assuming you are writing your own boot loader rather than using an existing one such as GRUB or BootMagic - which is what we usually recommend, as writing the boot loader is a lot of work for very little real payoff when designing a new OS.
I am among those who say that it is a useful exercise when starting out, but only as an exercise, and only to the point where you can load another sector and jump to it. Beyond that, unless you are planning to do something really, really unusual, rolling your own boot loader is sort of a waste of time.
Getting back to the issue at hand, you would usually only use the BIOS for the very start of an operating system, especially if you are planning to run it in 32-bit or 64-bit mode - the BIOS routines only work in 16-bit mode, and while there are ways to step down to 16-bit mode from 32-bit mode, doing that is both terribly inefficient and is more work than writing a proper 32-bit driver would have been in the first place.
TL;DR: INT 0x10 has several parts, and putting 0x0E in AH tells it which one to use. But you only need to know that for the very start of things anyway, and probably not even then.
In other words, it prints one character of text the the console in text mode, and moves the cursor to the next position.
However, as Octocontrabass said, it isn't actually necessary; it just happens to be convenient when writing a boot loader, because, well, it's already there to be used. It isn't the only way to write text to the console, nor the best way, or even a particularly good way, but it is the easiest way when you are trying to cram as much as you can into a 512 byte boot sector, so if your boot loader is sending something to the text console, that's usually the way you would do it.
Mind you, most first stage boot loaders only use any text output when you are debugging them (yo would take it out later to save space, usually), and even that's assuming you are writing your own boot loader rather than using an existing one such as GRUB or BootMagic - which is what we usually recommend, as writing the boot loader is a lot of work for very little real payoff when designing a new OS.
I am among those who say that it is a useful exercise when starting out, but only as an exercise, and only to the point where you can load another sector and jump to it. Beyond that, unless you are planning to do something really, really unusual, rolling your own boot loader is sort of a waste of time.
Getting back to the issue at hand, you would usually only use the BIOS for the very start of an operating system, especially if you are planning to run it in 32-bit or 64-bit mode - the BIOS routines only work in 16-bit mode, and while there are ways to step down to 16-bit mode from 32-bit mode, doing that is both terribly inefficient and is more work than writing a proper 32-bit driver would have been in the first place.
TL;DR: INT 0x10 has several parts, and putting 0x0E in AH tells it which one to use. But you only need to know that for the very start of things anyway, and probably not even then.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Re: What does 'mov ah, 0x0e' mean and do?
Am I the only one who notices that this guy insults himself?(I'm only 13)
- MichaelFarthing
- Member
- Posts: 167
- Joined: Thu Mar 10, 2016 7:35 am
- Location: Lancaster, England, Disunited Kingdom
Re: What does 'mov ah, 0x0e' mean and do?
To describe someone as 13 cannot be seen as an insult. I mean, I was 13 once!
He is simply looking forward to the even greater distinction of being 14.
(Starts going downhill after that...)
He is simply looking forward to the even greater distinction of being 14.
(Starts going downhill after that...)
-
- Member
- Posts: 273
- Joined: Sun Oct 09, 2016 4:38 am
- Libera.chat IRC: NunoLava1998
Re: What does 'mov ah, 0x0e' mean and do?
jordanbaron12 wrote:I am learning to make a very basic operating system. (I'm only 13) But I don't understand something. What does mov ah, 0x0e mean and why is it needed to print characters on the screen?
Interrupt 10h needs a value in AH/AL/AX to know what to do. To print characters on the screen, int 10h needs AH set to 0x0e.
"mov ah, 0x0e" is simply telling NASM to "Hey, please move the byte 0x0e to the register "ah"."
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.
https://github.com/NunoLava1998/DixiumOS
https://github.com/NunoLava1998/DixiumOS