Created
September 1, 2021 20:00
-
-
Save alimkoca/a0184c2adc01dc40589bcf6c6e7be800 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bits 16 | |
org 0x7c00 | |
boot: | |
mov ax, 0x2401 | |
int 0x15 ; A20 bitini aktive et | |
mov ax, 0x3 | |
int 0x10 ; vga yazı modunu 3 yap | |
lgdt [gdt_pointer] ; global tanımlayıcı tablosunu yükle | |
mov eax, cr0 | |
or eax,0x1 ; korumalı modu özel merkezi işlem ünitesinin cr0 özel yazmacına ayarla | |
mov cr0, eax | |
jmp CODE_SEG:boot2 ; kod segmentinin boot2 sembolik adresine atla | |
gdt_start: | |
dq 0x0 ; 32 bitlik qword | |
gdt_code: | |
dw 0xFFFF ; 16-16-16-16 16'lık tabanda | |
dw 0x0 ; 0 | |
db 0x0 ; 0 | |
db 10011010b ; 128+0+0+16+8+0+2+0 = 154 | |
db 11001111b ; 128+64+0+0+8+4+2+1 = 207 | |
db 0x0 ; 0 | |
gdt_data: | |
dw 0xFFFF ; 16-16-16-16 16'lık tabanda | |
dw 0x0 ; 0 | |
db 0x0 ; 0 | |
db 10010010b | |
db 11001111b | |
db 0x0 | |
gdt_end: | |
gdt_pointer: | |
dw gdt_end - gdt_start ; 16 bit boyutunda pointer | |
dd gdt_start ; 32 bit boyutunda pointer | |
CODE_SEG equ gdt_code - gdt_start ; Kod segmenti | |
DATA_SEG equ gdt_data - gdt_start ; Veri segmenti | |
bits 32 ; 32 bit modu | |
boot2: | |
mov ax, DATA_SEG ; veri segmentinin adresini veri yazmacına kaydet | |
mov ds, ax | |
mov es, ax | |
mov fs, ax | |
mov gs, ax | |
mov ss, ax | |
mov esi,hello | |
mov ebx,0xb8000 ; vga video modu | |
.loop: | |
lodsb | |
or al,al | |
jz halt | |
or eax,0x0100 | |
mov word [ebx], ax | |
add ebx,2 | |
jmp .loop | |
halt: | |
cli | |
hlt | |
hello: db "Hello world!",0 | |
times 510 - ($ - $$) db 0 | |
dw 0xaa55 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment