Code: Select all
[org 0]
jmp 07C0h:start
start:
mov ax, cs
mov ds, ax
mov es, ax
mov ax, 0xB800
mov es, ax
mov di, 0
mov ax, word [msgBack]
mov cx, 0x7FF
paint:
mov word [es:di], ax ; fill the screen with "orange background and dots"
add di, 2
dec cx
jnz paint
read:
mov ax, 0x1000
mov es, ax
mov bx, 0
mov ah, 2
mov al, 1
mov ch, 0
mov cl, 2
mov dh, 0
mov dl, 0
int 0x13
jc read
jmp 0x1000:0000
msgBack db '*' , 0x67
times 510-($-$$) db 0
dw 0AA55h
Code: Select all
[org 0]
[bits 16]
start:
mov ax, cs
mov ds, ax
xor ax, ax
mov ss, ax
cli
lgdt[gdtr] ; load GDT
mov eax, cr0
or eax, 0x00000001
mov cr0, eax
jmp $+2 ; jumps to the 32 bit mode
nop
nop
db 0x66
db 0x67
db 0xEA
dd PM_Start
dw SysCodeSelector
[bits 32]
PM_Start:
mov bx, SysDataSelector
mov ds, bx
mov es, bx
mov fs, bx
mov gs, bx
mov ss, bx
xor eax, eax
mov ax, VideoSelector
mov es, ax
mov edi, 80*2*10+2*10
lea esi, [ds:msgPMode]
call printf ; print the message (We are in protected MODE)
jmp $
printf:
push eax
printf_loop:
or al, al
jz printf_end
mov al, byte [esi]
mov byte [es:edi], al
inc edi
mov byte [es:edi], 0x06
inc esi
inc edi
jmp printf_loop
printf_end:
pop eax
ret
msgPMode db "We are in Protected MODE", 0
;---------------------------------------
; Global Descriptor Table
;----------------------------------------
gdtr:
dw gdt_end - gdt - 1
dd gdt+0x10000
gdt:
;Dummy Segment desc
dw 0
dw 0
db 0
db 0
db 0
db 0
; Code seg
SysCodeSelector equ 0x08
dw 0xffff
dw 0x0000
db 0x01
db 0x9a
db 0xcf
db 0x00
; Data seg
SysDataSelector equ 0x10
dw 0xffff
dw 0x0000
db 0x01
db 0x92
db 0xcf
db 0x00
; Video Seg
VideoSelector equ 0x18
dw 0xffff
dw 0x8000
db 0x0B
db 0x92
db 0x40
db 0x00
gdt_end:
nasm -f bin -o boot.bin boot.asm
nasm -f bin -o kernel.bin kernel.asm
copy boot.bin+kernel.bin kernel.img
The thing that I'm very annoyed is kernel.img is not working on VMware. It just shows up "orange background filled with dots". It looks like boot.asm is working well but not kernel.asm. I cannot check whether this is problem of vmware or the problem of source code itself because i don't have floppy drive in my computer.
Anybody can find the problem from the source code above?
Plz Help MEEEE