Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- format binary
- use16
- org 0x7c00
- jmp near EntryBoot
- GDT:
- db 0x0000000000000000 ; null descriptor
- CODE_D db 0xff,0xff,0x00,0x00,0x00,10011010b,00001111b,0x00 ; code descriptor
- Data_D db 0xff,0xff,0x00,0x00,0x00,10010010b,00001111b,0x00 ; data descriptor
- VIDEO_D db 0xff,0xff,0x00,0x80,0x0b,10010010b,01000000b,0x00 ; video 0xb8000 descriptor
- len_GDT equ $ - GDT
- GDTR:
- dw len_GDT - 1
- dd 0x00000000
- EntryBoot:
- .clear_screen:
- mov ah,0x02
- xor bh,bh
- xor dx,dx
- int 0x10
- mov ah,0x0a
- mov al,' '
- xor bh,bh
- mov cx,0xffff
- int 0x10
- cli
- in al,0x92
- bts ax,1
- jc .continue_boot
- out 0x92,al
- .continue_boot:
- mov dx,cs
- shl edx,4
- add edx,GDT
- mov [GDTR+2],edx
- .set_PM:
- lgdt fword [GDTR]
- mov edx,cr0
- or dl,0x01
- mov cr0,edx
- jmp far 0x0008:EntryProtected
- use32
- EntryProtected:
- hlt
- mov dx,0x0010
- mov ds,dx
- mov ss,dx
- mov es,dx
- mov dx,0x0018
- mov fs,dx
- mov esp,0xffff0000
- mov ebp,esp
- .print_status:
- lea esi,[string] ; arg1
- mov ecx,42 ; arg2
- call PrintStatus
- hlt
- PrintStatus:
- cld
- xor edi,edi
- .lp:
- lodsb
- shl ax,8
- mov al,0x0f
- stosw
- loop .lp
- ret
- string db '[+] MBR IN PROTECTED MODE',0x0a,0x0d,'[*] SYSTEM HALT'
- times 510 - ($ - $$) db 0x00
- dw 0xaa55
Advertisement
Add Comment
Please, Sign In to add comment