这是我以前练习时自己编得玩的,编译成EXE文件后。。。不要轻易去试啊,到时出了意外我不负责。。。
=======================================
.model tiny
.code
diskio equ 13h
video equ 10h
org 200h
getpassword proc
passbegin:
myroutine:
push cs
pop ds
mov di,offset headmsg
call put_str
mov di,offset pswbuffer
call readstr
mov si,offset pswbuffer
mov di,offset password
xor ch,ch
mov cl,byte ptr [di]
repe cmpsb
jz right
mov di, offset errormsg
call put_str
deadloop :
jmp deadloop
right:
ret
readstr proc near
push es
push di
push cs
pop es
inc di
mov plength,0
next:
cmp plength,15
jge @l1
mov ah,1
int 16h
jz next
mov ax,0
int 16h
cmp al,0
je next
cmp al,08
je @l2
cmp al,13
je @l1
sub al,20
or al,80h
stosb
mov al,'X'
mov bx,0
mov ah,0eh
int 10h
inc plength
jmp next
@l2:
cmp plength,0
je next
dec di
mov al,00h
stosb
mov ah,03h
mov bh,00h
int 10h
dec dx
mov ah,02h
int 10h
mov al,' '
mov ah,0eh
int 10h
mov ah,02h
int 10h
dec plength
dec di
jmp next
@l1:
pop di
mov al,byte ptr plength
mov byte ptr [di],al
pop es
ret
readstr endp
;
put_str proc
mov al,cs:[di]
cmp al,'$'
je a1
mov ah,0eh
mov bx,0003h
int video
inc di
jmp put_str
a1:
ret
put_str endp
plength db 0
headmsg db"圹鄄膊北卑鞍 PASS WORD FOR HD SYSTEM 鞍氨北膊槽圹",0AH,0DH
db"****** PassWord is: MASTER ******(NOT master!!!!)",0ah,0dh
db"****** I am Sorry harddisk is write protect!!!!!",0ah,0dh
db"****** BUT You Can type the password to visit drive C:",0ah,0dh
db"圹鄄膊北卑鞍 Please input Password(MASTER) 鞍氨北膊槽圹",0ah,0dh
db 0ah,0dh
db 'Password:','$'
passtail:
passlen equ 1024-(passtail-passbegin)
db passlen dup(0)
org passbegin+1024
getpassword endp
org 600h
getpass proc
pbegin:
push ax
push cx
push ds
push es
push si
push di
xor ax,ax
mov ds,ax
mov es,ax
mov ax,ds:[3f0h]
mov ds,ax
mov es,ax
mov di,offset pswbuffer
call preadstr
mov si,offset pswbuffer
mov di,offset password
xor ch,ch
mov cl,byte ptr[di]
repe cmpsb
mov ax,1075h
mov cx,5
jz right2
$t1:
add ax,200h
call music
call delay
loop $t1
call nosound
pop di
pop si
pop es
pop ds
pop cx
pop ax
stc
ret
right2:
mov ax,2275h
$t4:
sub ax,200h
call music
call delay
loop $t4
call nosound
pop di
pop si
pop es
pop ds
pop cx
pop ax
clc
ret
preadstr proc near
push es
push di
inc di
mov plength,0
pnext :
cmp plength ,15
jge @pl1
mov ah,1
int 16h
jz pnext
mov ax,0
int 16h
cmp al,0
je pnext
cmp al,08
je @pl2
cmp al,13
je @pl1
sub al,20
or al,80h
stosb
inc plength
jmp pnext
@pl2:
cmp plength,0
je pnext
dec di
mov al,00h
stosb
dec plength
dec di
jmp pnext
@pl1:
pop di
mov al,byte ptr plength
mov byte ptr [di],al
pop es
ret
preadstr endp
timer2 equ 42h
tim_ctr equ 43h
port_b equ 61h
music proc
push ax
mov al,10110110b
out tim_ctr,al
pop ax
out timer2,al
mov al,ah
out timer2 ,al
in al,port_b
or al,00000011b
out port_b,al
ret
music endp
nosound proc
in al,port_b
and al,11111100b
out port_b,al
ret
nosound endp
delay proc
push si
mov si,0a000h
@j1:
dec si
cmp si,0
jnz @j1
pop si
ret
delay endp
errormsg db 0ah,0dh
db"鞍氨北膊槽圹 Access Denied 圹鄄膊北卑鞍",0ah,0dh
db"========= Unauthorized User =========",0ah,0dh,'$'
ptail:
restlen equ 200h-(ptail-pbegin)-32
db restlen dup (0)
org pbegin+200h-32
password db 0,15 dup(0)
pswbuffer db 0,15 dup(1)
getpass endp
end