Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model tiny
- .386p
- .code
- start:
- jmp load
- IDT: dq 13 dup (0)
- dw GP_handler, 08h, 8E00h, 0
- dq 18 dup (0)
- dw int8h_handler, 08h, 8E00h, 0
- dw int9h_handler, 08h, 8E00h, 0
- IDT_size equ $-IDT
- IDTR dw IDT_size-1
- IDTR_base dd IDT
- GDT:
- dq 0
- main_rec dw 0FFFFh, 0, 9A00h, 0
- gdtr dw $ - GDT - 1
- gdtr_base dd 0
- sel_cs equ 8
- sec db 'A'
- tic db 18
- mask_old1 db 0
- mask_old2 db 0
- gdtr_old db 0, 0, 0, 0, 0, 0
- idtr_old db 0, 0, 0, 0, 0, 0
- prompt db 'Enter time to wait in seconds:$'
- GP_handler:
- pop eax ;
- iretd
- int8h_handler:
- push ax
- dec tic
- cmp tic, 0
- jne endd
- mov tic, 18
- dec sec
- mov al, sec
- add al, '0'
- mov es:220, al
- endd:
- mov al, 20h
- out 020h, al
- out 0a0h, al
- pop ax
- iretd
- int9h_handler:
- push ax
- in al,60h
- cmp al, 1; esc
- je go_out
- mov al, 20h
- out 020h, al
- pop ax
- iretd
- go_out:
- mov al, 20h
- out 20h, al
- jmp back
- load:
- mov ax, cs
- mov ds, ax
- mov ax, 3
- int 10h
- mov ah, 9
- lea dx, prompt
- int 21h
- mov ah, 1
- int 21h
- sub al, '0'
- mov sec, al4
- cli ; запрет прер
- in al, 70h
- or al, 80h
- out 70h, al
- push cs
- pop ds
- push 0B800h
- pop es
- xor si,si
- mov ax, cs
- mov cs:cs_old, ax
- sidt fword ptr idtr_old
- sgdt fword ptr gdtr_old
- mov eax, 0
- mov ax, cs
- shl eax, 4
- mov main_rec+2, ax
- shr eax, 16
- mov byte ptr main_rec+4, al
- mov eax, 0
- mov ax, cs
- shl eax, 4
- add eax, offset GDT
- mov gdtr_base, eax
- lgdt fword ptr gdtr
- mov eax, 0
- mov ax, cs
- shl eax, 4
- add eax, offset IDT
- mov IDTR_base, eax
- lidt fword ptr idtr
- mov eax, cr0
- or al, 1
- mov cr0, eax
- db 0EAh
- dw $ + 4
- dw 8 ;-------------
- in al, 021h
- mov mask_old1, al
- in al, 0A1h
- mov mask_old2, al
- mov al, 11h
- out 020h, al
- out 0A0h, al
- mov al, 20h
- out 021h, al
- mov al, 28h
- out 0A1h, al
- mov al, 4
- out 021h, al
- mov al, 2
- out 0A1h, al
- mov al, 1
- out 021h, al
- out 0A1h, al
- mov al, 0fch
- out 021h, al
- mov al, 0ffh
- out 0A1h, al
- in al, 70h
- and al, 7Fh
- out 70h, al
- sti
- poll:
- cmp sec
- jne poll
- back:
- cli
- in al, 70h
- or al, 80h
- out 70h, al
- mov al, 11h
- out 020h, al
- out 0A0h, al
- mov al, 08h
- out 021h, al
- mov al, 70h
- out 0A1h, al
- mov al, 4
- out 021h, al
- mov al, 2
- out 0A1h, al
- mov al, 1
- out 021h, al
- out 0A1h, al
- mov al, mask_old1
- out 021h, al
- mov al, mask_old2
- out 0A1h, al
- mov eax, cr0
- and al, 0FEh
- mov cr0, eax
- db 0EAh
- dw $+4
- cs_old dw 0
- lidt fword ptr idtr_old
- lgdt fword ptr gdtr_old
- mov ax, cs
- mov ds, ax
- mov ss, ax
- mov es, ax
- in al, 70h
- and al, 7Fh
- out 70h, al
- sti
- mov ax, 4C00h
- int 21h
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement