Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .386
- descr struc
- lim dw 0
- base_l dw 0
- base_m db 0
- attr_1 db 0
- attr_2 db 0
- base_h db 0
- descr ends
- ; DATA segment
- data segment use16
- gdt_null descr <0,0,0,0,0,0>
- gdt_data descr <data_size-1, 0,0,92h, 0,0>
- gdt_code descr <code_size-1, 0,0, 98h, 0,0>
- gdt_stack descr <255, 0,0,92h,0,0>
- gdt_screen descr <3999,8000h, 0Bh, 92h, 0,0,>
- gdr_size = $-gdt_null
- pdescr df 0
- sym db 1
- attr db 1Eh
- msg db 27,'Returned to real mode!',27,'$'
- data_size=$-gdt_null
- data ends
- text segment use16
- assume CS:text, CS:data
- main proc
- xor eax, eax
- mov ax, data
- mov ds, ax
- shl eax, 4
- mov ebp, eax
- mov bx, offset gdt_data
- mov [bx].base_l, ax
- shr eax, 16
- mov [bx].base_m, AL
- xor eax, eax
- mov ax, CS
- shl eax, 4
- mov BX, offset gdt_code
- mov [bx].base_l, ax
- shr eax, 16
- mov [bx].base_m, al
- xor eax, eax
- mov ax, ss
- shl eax, 4
- mov bx, offset gdt_stack
- mov [bx].base_l, ax
- shr eax, 16
- mov [bx].base_m, al
- mov dword ptr pdescr+2, ebp
- mov word ptr pdescr, gdt_size-1
- lgdt pdescr
- mov ax, 40h
- mov es, ax
- mov word ptr es:[67h], offset return
- mov es:[69h], cs
- mov al, 0Fh
- out 70h, al
- mov al, 0Ah
- out 71h, al
- cli
- mov eax, cr0
- or eax, 1
- mov cr0, eax
- ;; Now in protected mode ;;
- db 0EAh
- dw offset continue
- dw 16
- continue:
- mov ax, 8
- mov ds, ax
- mov ax, 24
- mov ss, ax
- mov ax, 32
- mov es, ax
- mov di, 1920
- mov cx, 80
- mov ax, word ptr sym
- scrn:
- swosw
- inc al
- loop scrn
- mov al, 0FEh
- out 64h, al
- hlt
- ;; Now in real mode ;;
- return:
- mov ax, data
- mov ds, ax
- mov ax, stk
- mov ss, ax
- mov sp, 256
- sti
- mov ah, 09h
- mov dx, offset msg
- int 21h
- mov ax, 4c00h
- int 21h
- main endp
- code_size=$-main
- text ends
- stk segment stack use16
- db 256 dup('^')
- stck ends
- end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement