📄 pm3.asm
字号:
include debug.mac
.386P
descr struc
limit dw 0
base_l dw 0
base_m db 0
attr_l db 0
attr_2 db 0
base_h db 0
descr ends
trap struc
offs_l dw 0
sel dw 16
rsrv db 0
attr db 8Fh
offs_h dw 0
trap ends
intr struc
ioffs_l dw 0
isel dw 16
irsrv db 0
iattr db 8Eh
ioffs_h dw 0
intr ends
data segment use16
gdt_null descr <0,0,0,0,0,0>
gdt_data descr <data_size-1,0,0,92h>
gdt_code descr <code_size-1,,,98h>
gdt_stack descr <255,0,0,92h>
gdt_screen descr <4095,8000h,0Bh,92,0,0>
gdt_size=$-gdt_null
idt label word
trap 10 dup (<dummy_exc>)
trap <exc_0Ah>
trap <exc_0Bh>
trap <exc_0Ch>
trap <exc_0Dh>
trap <exc_0Eh>
trap 17 dup (<dummy_exc>)
idt_08 intr <new_08>
idt_size=$-idt
pdescr dq 0
mes db 27,'[31;42m Back To Real Mode! ',27,'[0m$';(21)
tblhex db '0123456789ABCDEF'
string db '**** ****_**** ****_**** ****'
len=$-string
home_sel dw home
dw 10h
mark_08h dw 480
color_08h db 71h
time_08h db 0
data_size=$-gdt_null
data ends
text segment 'code' use16
assume cs:text,ds:data
begin label word
exc_0Ah proc
pop eax
pop eax
mov si,offset string+5
debug
mov ax,0Ah
jmp dword ptr home_sel
exc_0Ah endp
exc_0Bh proc
pop eax
pop eax
mov si,offset string+5
debug
mov ax,0Bh
jmp dword ptr home_sel
exc_0Bh endp
exc_0Ch proc
pop eax
pop eax
mov si,offset string+5
debug
mov ax,0Ch
jmp dword ptr home_sel
exc_0Ch endp
exc_0Dh proc
pop eax
pop eax
mov si,offset string+5
debug
mov ax,0Dh
jmp dword ptr home_sel
exc_0Dh endp
exc_0Eh proc
pop eax
pop eax
mov si,offset string+5
debug
mov ax,0Eh
jmp dword ptr home_sel
exc_0Eh endp
dummy_exc proc
pop eax
pop eax
mov si,offset string+5
debug
mov ax,1111h
jmp dword ptr home_sel
dummy_exc endp
new_08 proc
push ax
push bx
test time_08h,03
jnz skip
mov al,21h
mov ah,color_08h
mov bx,mark_08h
mov es:[bx],ax
add mark_08h,2
skip: inc time_08h
mov al,20h
out 20h,al
pop bx
pop ax
db 66h
iret
new_08 endp
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
rol 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
rol 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
rol eax,16
mov [bx].base_m,al
mov dword ptr pdescr+2,ebp
mov word ptr pdescr,gdt_size-1
lgdt pdescr
cli
mov al,8Fh
out 70h,al
jmp $+2
mov al,05h
out 71h,al
mov dx,20h
mov al,11h
out dx,al
jmp $+2
inc dx
mov al,20h
out dx,al
jmp $+2
mov al,4
out dx,al
jmp $+2
mov al,1
out dx,al
mov al,0FEh
out dx,al
mov dx,0A1h
mov al,0FFh
out dx,al
mov word ptr pdescr,idt_size-1
xor eax,eax
mov ax,offset idt
add eax,ebp
mov dword ptr pdescr+2,eax
lidt pdescr
mov eax,cr0
or eax,1
mov cr0,eax
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 al,0h
out 70h,al
sti
mov cx,300
mov bx,2720
mov dx,3001h
xxxx: push cx
mov cx,0
zzzz: loop zzzz
mov es:[bx],dx
inc dl
add bx,2
pop cx
loop xxxx
mov ax,0FFFFh
home: mov si,offset string
debug
mov si,offset string
mov cx,len
mov ah,74h
mov di,1600
scr: lodsb
stosw
loop scr
mov al,0FEh
out 64h,al
hlt
return: mov ax,data
mov ds,ax
mov ax,stk
mov ss,ax
mov sp,256
mov al,0B8h
out 21h,al
mov al,9Dh
out 0A1h,al
sti
mov al,0
out 70h,al
mov ah,09h
mov dx,offset mes
int 21h
mov ax,4C00h
int 21h
main endp
code_size=$-main
text ends
stk segment stack 'stack'
db 256 dup ('^')
stk ends
end main
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -