Home > Enterprise >  no error message, nothing, but it does not work (512byte boot file)
no error message, nothing, but it does not work (512byte boot file)

Time:09-28

Yeah, basically I want to change from a 16-bit system to a 32, (later 64 when it will work) but it does not work. Nasm didn't give me an error, but it doesin't run in virtualbox. Here is a link if someone understands assembly:

https://github.com/Xulum12/assembly/blob/main/boot2.asm

[org 0x7c00] 

GDT_Start:
null_descriptor:
dd 0
dd 0
code_descriptor:
dw 0xffff
dw 0
dw 0
db 10011010

db 11001111

db 0

data_descriptor:
dw 0xffff
dw 0
dw 0
db 10010010

db 11001111

db 0
GDT_end:

GDT_Descriptor:
dw GDT_end - GDT_Start - 1
dd GDT_Start

CODE_SEG equ code_descriptor - GDT_Start
DATA_SEG equ data_descriptor - GDT_Start

cli
lgdt [GDT_Descriptor]
mov eax, cr0
or eax, 1
mov cr0, eax

jmp CODE_SEG:stpm
[bits 32]
stpm:

mov al, 'q'
mov ah, 0x0f
mov [0xb8000], ax

times 510-($-$$) db 0              
db 0x55, 0xaa

CodePudding user response:

Your code starts with data. CPU treats data as instructions which can do unexpected things. You need to either move data to end of the code, or add a JMP instruction at the beginning of the code that skips the data bytes.

CodePudding user response:

Some reasons why it fails include:

  • The data gets executed as if it was code
  • The descriptors have 9 bytes instead of 8
  • The segment registers have not been setup
  • There's no decent end for the code
  • ...
  • Related