[SOLVED] Code migration issues...
Re: [SOLVED] Code migration issues...
But are you putting it in a separate section as Bare Bones does? It may work now, but when the linker decides to do something different, it could break your OS. It is just good practice to keep multiboot data away from text data
- yuukidesu9
- Posts: 12
- Joined: Wed Nov 11, 2020 4:27 pm
Re: [SOLVED] Code migration issues...
Oh, sure. I think this should work?nexos wrote:But are you putting it in a separate section as Bare Bones does? It may work now, but when the linker decides to do something different, it could break your OS. It is just good practice to keep multiboot data away from text data
Code: Select all
global loader ; the entry symbol for ELF
MAGIC_NUMBER equ 0x1BADB002 ; define the magic number constant
FLAGS equ 0x0 ; multiboot flags
CHECKSUM equ -MAGIC_NUMBER ; calculate the checksum
; (magic number + checksum + flags should equal 0)
KERNEL_STACK_SIZE equ 4096 ; size of stack in bytes
section .multiboot ; start of the multiboot header
align 4 ; align at 4 bytes
dd MAGIC_NUMBER ; write the magic number to the machine code,
dd FLAGS ; the flags,
dd CHECKSUM ; and the checksum
section .text ; start of the text (code) section
align 4 ; the code must be 4 byte aligned
.loop:
jmp .loop
kernel_stack: ; label points to beginning of memory
resb KERNEL_STACK_SIZE ; reserve stack for the kernel
mov esp, kernel_stack + KERNEL_STACK_SIZE
[extern loader_main]
loader:
call loader_main ; load our kernel
section .bss
align 4 ; align at 4 bytes
Just a fox guy doing fox things.
Y'know, doing some music, developing stuff, procrastinating a lot...
yuuOS: https://gitlab.com/yuukidesu9/yuuos/
Y'know, doing some music, developing stuff, procrastinating a lot...
yuuOS: https://gitlab.com/yuukidesu9/yuuos/
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: [SOLVED] Code migration issues...
Code: Select all
.loop:
jmp .loop
Code: Select all
kernel_stack: ; label points to beginning of memory
resb KERNEL_STACK_SIZE ; reserve stack for the kernel
Code: Select all
mov esp, kernel_stack + KERNEL_STACK_SIZE
- yuukidesu9
- Posts: 12
- Joined: Wed Nov 11, 2020 4:27 pm
Re: [SOLVED] Code migration issues...
Oh. I'm fixing them right now. Forgot about those details, it happens when we skip lunch lolOctocontrabass wrote: This code looks like it will never run. Why is it here?
...
You're reserving space for the kernel stack in the .text section. Did you want to put it in .bss instead?
...
This instruction will never run. Your stack isn't being set up at all!
Just a fox guy doing fox things.
Y'know, doing some music, developing stuff, procrastinating a lot...
yuuOS: https://gitlab.com/yuukidesu9/yuuos/
Y'know, doing some music, developing stuff, procrastinating a lot...
yuuOS: https://gitlab.com/yuukidesu9/yuuos/