[SOLVED]Bootloader working wierdly
Posted: Mon Apr 29, 2019 2:40 am
Hello everyone!
I've been running into a weird problem and I can't figure out exactly what's causing the issue. Here's the part of code that's working weirdly:
and the Makefile:
So here's the issue (I guess it has something to do with the linker), if I set -Ttext to 0x7c00, the code below _here doesn't execute BUT everything works fine if I set -Ttext to 0x0. Why is that ?
I tried looking at the values of segment registers in both cases (Ctrl+Alt+2 in qemu) and in the first case only CS seems to have the value 0x07c0 and the rest are in their default state, however in the second case, everything is as they should be.
I even tried using int $0x10 just below _here to see whether the code below the label is being executed or not and it's not executing when -Ttext 0x7c00 is used.
Why is that ?
I've been running into a weird problem and I can't figure out exactly what's causing the issue. Here's the part of code that's working weirdly:
Code: Select all
.code16
.globl _start
.section .text
_start:
ljmp $0x7c0, $_here
_here:
movw %cs, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %ss
#Rest of the code
Code: Select all
LDFLAGS := -melf_i386 --oformat=binary
all: disk.img
boot: boot.o
ld $(LDFLAGS) -Ttext 0x7c00 -e _start -o boot boot.o
boot.o: boot.s
as --32 -o boot.o boot.s
#Rest of the Makefile
I tried looking at the values of segment registers in both cases (Ctrl+Alt+2 in qemu) and in the first case only CS seems to have the value 0x07c0 and the rest are in their default state, however in the second case, everything is as they should be.
I even tried using int $0x10 just below _here to see whether the code below the label is being executed or not and it's not executing when -Ttext 0x7c00 is used.
Why is that ?