Add subsection for stack creation

This commit is contained in:
Philipp Oppermann
2015-10-03 19:05:48 +02:00
parent 0324241ea1
commit 0c7100ca7d

View File

@@ -33,7 +33,10 @@ At address `0xb8000` begins the so-called [VGA text buffer]. It's an array of sc
A screen character consists of a 8 byte color code and a 8 byte ASCII character. We used the color code `4f` for all characters, which means white text on red background. `0x52` is an ASCII `R`, `0x45` is an `E`, `0x3a` is a `:`, and `0x20` is a space. The second space is overwritten by the given ASCII byte. Finally the CPU is stopped with the `hlt` instruction.
Now we can add some test _functions_. A function is just a normal label with an `ret` (return) instruction at the end. The `call` instruction can be used to call it. Unlike the `jmp` instruction that just jumps to a memory address, the `call` instruction will push a return address to the stack (and the `ret` will jump to this address). But we don't have a stack yet. The [stack pointer] in the esp register could point to some important data or even invalid memory. So we need to update it and point it to some valid stack memory. To create this memory we reserve some bytes at the end of our `boot.asm`:
Now we can add some test _functions_. A function is just a normal label with an `ret` (return) instruction at the end. The `call` instruction can be used to call it. Unlike the `jmp` instruction that just jumps to a memory address, the `call` instruction will push a return address to the stack (and the `ret` will jump to this address). But we don't have a stack yet. The [stack pointer] in the esp register could point to some important data or even invalid memory. So we need to update it and point it to some valid stack memory.
### Creating a Stack
To create this memory we reserve some bytes at the end of our `boot.asm`:
```nasm
...