这段代码主程序部分够简练吧,还可以优化? (1千字)
;发声部分不在优化之列.586
.model flat, stdcall
option casemap :none ; case sensitive
include c:\hd\hd.h
include c:\hd\mac.h
int_num equ 5
;;--------------
.DATA
sztit db "By hume,2002",0
errmsg db "Error Ocurred!",0
msg db "Ring0 Succ!",0
;;-----------------------------------------
.CODE
__Start:
assume fs:nothing
call set_seh
lea eax,errmsg
jmp ExitP
set_seh:
push dword ptr fs:[0]
mov fs:[0],esp
push 0
sidt [esp-2]
pop ebx
add ebx,int_num*8+4
mov ecx,[ebx]
mov cx,[ebx-4] ;ecx=int Des offset
lea esi,my_int
mov [ebx-4],si
shr esi,16
mov [ebx+2],si
int int_num
mov [ebx-4],cx
shr ecx,16
mov [ebx+2],cx
pop dword ptr fs:[0]
mov dword ptr [esp],offset msg
pop eax
ExitP:
invoke MessageBox,0,eax,addr sztit,40h+MB_SYSTEMMODAL
invoke ExitProcess,0
my_int: ; now in Ring-0
mov ecx,50
@lop1:
push ecx
call beeps
pop ecx
loop @lop1
iretd ; return to caller
beeps:
pushad
mov ax, 1000
mov bx, 800
mov cx, ax
mov al, 0b6h
out 43h, al
mov dx, 0012h
mov ax, 34dch
div cx
out 42h, al
mov al, ah
out 42h, al
in al, 61h
mov ah, al
or al, 03h
out 61h, al
l1:
mov ecx, 4680
l2:
loop l2
dec bx
jnz l1
mov al, ah
out 61h, al
popad
ret
END __Start
