Setting up stack wrong (solved, no need to answer)
Posted: Fri Oct 24, 2025 6:06 am
TL;DR: Someone helped me out. Be very mindful of GNU as and use `lea` instead of `mov` where appropriate.
The entire code is here: https://github.com/ciocolataculapte/risx-mirror
What am I doing wrong here? I am trying to push eax and ebx on the stack to use as arguments in my kernel main function. For testing purposes it does have a return statement. It returns 0x0BADCODE if eax didn't contain the multiboot2 magic number, and 0xDEADBEEF otherwise.
I've tries a couple variants to set up the stack in BSS, but I can't figure it out. My PC has 2 cores, so I'm trying to use the symbol "stack0" for my stack on the boot core. This was wrong, only "stack1" was valid.
Now I'm the code below, using "top0" as stack, but this doesn't work either.
What am I doing wrong? Am I missing something in my assembly file, or is my linker script perhaps messing this up?
I am not doing anything in my multiboot 2 header, it's as minimal as it can be, maybe that's the issue.
The entire code is here: https://github.com/ciocolataculapte/risx-mirror
What am I doing wrong here? I am trying to push eax and ebx on the stack to use as arguments in my kernel main function. For testing purposes it does have a return statement. It returns 0x0BADCODE if eax didn't contain the multiboot2 magic number, and 0xDEADBEEF otherwise.
I've tries a couple variants to set up the stack in BSS, but I can't figure it out. My PC has 2 cores, so I'm trying to use the symbol "stack0" for my stack on the boot core. This was wrong, only "stack1" was valid.
Code: Select all
top: .skip 0x10000 # 64K stack
stack0: .skip 0x10000 # stack for core 0
stack1: # stack for core 1Code: Select all
stack0: # stack for core 0
top0: .skip STACK_SIZE
stack1: # stack for core 1
top1: .skip STACK_SIZEI am not doing anything in my multiboot 2 header, it's as minimal as it can be, maybe that's the issue.