;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) HexOS author 2019-2022. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format binary as "hex"
; MACROS
macro movs reg, src {
push ax
mov ax, src
mov reg, ax
pop ax
}
; HEADER
db "System/kernel.hex", 00h
times 243-$+$$ db 00h
dd 00000000h
dd 00000000h
dd 00001000h
db 10000000b
jmp p32
; IMPORTS
include "fs.inc"
include "str.inc"
include "../boot/boot.inc"
; DATA
osname db "HexOS", 00h
osver db "v0.9.4", 00h
oscopy db "Ivan Chetchasov Vladimirovich 2019-2022 (c) All rights reserved.", 00h
; SYSDATA
GDT: dw 0
.size dw @f-GDT-1
.linear dd GDT
.code = $ - GDT
dw -1,0
db 0,9ah,0cfh,0
.data = $ - GDT
dw -1,0
db 0,92h,0cfh,0
.pointer:
dw GDT.size
dd GDT
@@:
; EXECUTABLE
; switch to P-mode
p32:
cli ; NO more interrupts
lgdt fword[GDT.pointer] ; Load GDT
mov eax, cr0 ; Where my CR0?
or al, 1 ; set lowest bit
mov cr0,eax ; apply changes
jmp GDT.code:.pmode ; jump next
.pmode:
use32
; I also need to set data segment
mov ax, GDT.data
mov ds, ax
; graphic segment
movs gs, 0A000h
; stack segment
mov ss, ax
; Call 32-bit kernel
call main
; footer, just halt
; because os mustn`t
; reach this part of
; code so maybe fatal
; error happened.
cli
hlt
jmp $-2
; 32-BIT PART
include "kern32.asm"
; FILLER
times 1000h-$+$$-1 db 00h
; MAGIC
db EOF
Я пишу новую операционную систему и столкнулся с непредвиденным поведением ядра
проблема в файле kernel\kernel.asm
0x00008122: bb 00 81 movw $0x8100, %bx
0x00008125: 50 pushw %ax
0x00008126: b8 00 00 movw $0, %ax
0x00008129: 8e c0 movw %ax, %es
0x0000812b: 58 popw %ax
0x0000812c: cd 13 int $0x13
0x0000812e: 00 00 addb %al, (%bx, %si)
0x00008130: 00 00 addb %al, (%bx, %si)
0x00008132: 00 00 addb %al, (%bx, %si)
0x00008134: 00 00 addb %al, (%bx, %si)
0x00008136: 00 00 addb %al, (%bx, %si)
0x00008138: 00 00 addb %al, (%bx, %si)
0x0000813a: 00 00 addb %al, (%bx, %si)
0x0000813c: 00 00 addb %al, (%bx, %si)
0x0000813e: 00 00 addb %al, (%bx, %si)
0x00008140: 00 00 addb %al, (%bx, %si)
0x00008142: 00 00 addb %al, (%bx, %si)
0x00008144: 00 00 addb %al, (%bx, %si)
qemu-system-i386 -hda collector.bin -d in_asm,exec,cpu -D log