home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
assemblr
/
library
/
password
/
password.asm
next >
Wrap
Assembly Source File
|
1992-11-15
|
9KB
|
204 lines
;; PASSWORD - password security program with alarm sound.
;;
;; To change password after assembling use Dos debug program
;;
;; Type: DEBUG PASSWORD.COM
;;
;; At the debug prompt type: F 103 116 0
;; press enter
;; this replaces old password with "0"s
;;
;; Next type: E 103 'ANYWORD' press enter
;; Be sure to include the quotes at beginning and end of password.
;; ( up to 20 characters in length )
;; PASSWORD MUST BE IN UPPERCASE
;;
;; Type W
;; press enter to write program to disk
;;
;;
;; This program can be assembled using the A86 or TASM assemblers
;;
;; Not tested with Masm, should work?
;;
;; This code is "PUBLIC DOMAIN"
;;
;; by William Cravener 11/14/92
;;
;-----------------------------------------------------------------------------
;;
code SEGMENT ; set up code and data section
ASSUME cs:code, ds:code, es:code, ss:code
ORG 100h ; COM programs begin here
main: jmp password_code ; skip over "DATA"
;;
;-----------------------------------------------------------------------------
;; DATA
;;
psword DB 20 DUP (0) ; room for 20 byte password
inpsword DB 20 DUP (0) ; keys pressed stored here
prompt DB 13, 10, 'Please enter system password: ', 0
match DB 13, 10, 10, 'Password Accepted!', 13, 10, 10, 0
start DB 0
rightlimit DB 0
;;
;-----------------------------------------------------------------------------
password_code:
mov ah, 8 ; get current screen color
mov bh, 0
int 10h
mov bh, ah ; place color in bh
mov ah, 6 ; service "6" scroll screen
mov al, 0 ; scroll 25 rows
mov cx, 0 ; upper left
mov dx, 184fh ; lower right
int 10h
mov ah, 2 ; set cursor
mov bh, 0
mov dx, 0a00h ; at about the center row
int 10h
mov si, OFFSET prompt ; output the prompt
call print_string
mov ah, 3 ; get cursor location
mov bh, 0
int 10h
mov start, dl ; save cursor start position
push dx ; push cursor location on stack
add dl, 20 ; add 20 places -
mov rightlimit, dl ; to the right - maximum
pop dx ; restore cursor location
mov di, OFFSET inpsword ; point di to "inpsword"
push di ; push it on the stack
mov al, 0 ; be sure any previous
mov cx, 20 ; attempt is flushed out
repe stosb
pop di ; pop "inpsword" off stack
key_input:
xor ax, ax ; get key pressed
int 16h ; BIOs key input
cmp ah, 1ch
je completed ; "ENTER" key pressed
cmp ah, 0eh
je moveleft ; "BACKSPACE" key pressed
cmp al, 20h
jl key_input ; return if not valid key
cmp dl, rightlimit ; 20 character limit
jge password_code
call uppercase ; make upper case if need be
push ax ; push character on stack
mov ah, 0ah ; print a smilly face
mov al, 1 ; smilly value
mov bh, 0 ; must be page "0"
mov cx, 1 ; print 1 smilly face
int 10h
mov ah, 3 ; get cursor location
int 10h
inc dl ; move it to the right
mov ah, 2 ; set cursor
mov bh, 0
int 10h
pop ax ; pop character off stack
stosb ; store it to "inpsword"
jmp key_input ; go get next key press
completed:
cmp BYTE PTR [inpsword], 0 ; if equal "0" nothing entered
jne ok_checkit ; is something there
jmp password_code ; "no" go try again
ok_checkit:
jmp checkit ; "yes" go compare strings
moveleft:
call to_the_left ; user pressed backspace key
jmp key_input ; go get a key press
checkit:
mov cx, 20 ; set up counter for compare
mov si, OFFSET psword ; the assigned password
mov di, OFFSET inpsword ; user entered password
cld ; clear DF flag for compare
repe cmpsb
cmp cx, 0 ; did CX reach zero?
jz gotmatch ; jump if they match
call alarm ; illegal attempt - sound alarm
jmp password_code ; go try again
gotmatch:
mov si, OFFSET match ; assume a match
call print_string ; print out message
alldone:
mov ax, 4c00h ; return to system
int 21h
;--------------------------------------
alarm:
mov bp, 10 ; number of passes
next:
mov dx, 200 ; repeat count of inner loop
mov bx, 700 ; start frequency low
mov al, 0b6h ; magic number
out 43h, al ; send it
back:
mov ax, bx ; place frequency in (ax)
out 42h, al ; send LSB
mov al, ah ; put MSB in (al)
out 42h, al ; send it
in al, 61h ; get value from port
or al, 03h ; ORing will turn speaker on
out 61h, al ; send it
dec bx ; decrementing rises frequency
mov cx, 1000 ; delay count in (cx)
looper:
loop looper ; do nothing loop so we can hear sound
dec dx ; decrement our repeat count
jnz back ; if not = 0 go do again
in al, 61h ; get port value
and al, 0fch ; ANDing turns speaker off
out 61h, al
dec bp
jz done
jmp next
done:
ret
;---------------------------------------
to_the_left: ; backspace subroutine
cmp dl, start
jle nomo
dec dl ; move back 1 space
mov ah, 2 ; and set cursor
mov bh, 0
int 10h
dec di ; decrement memory pointer
mov BYTE PTR [di], 0 ; place 0 at that location
mov ah, 0ah
mov al, ' ' ; print a blank space
mov cx, 1 ; at cursor position
int 10h
nomo:
ret
;----------------------------------
print_string: ; prints string to consol
lodsb
cmp al, 0 ; 0 indicates end of string
jz endofit
mov ah, 0eh
mov bh, 0
int 10h
jmp print_string
endofit:
ret
;----------------------------------
uppercase: ; make character uppercase
cmp al,'a' ; if neccessary
jb isup
cmp al,'z'
ja isup
sub al,20h
isup:
ret
;-----------------------------------------------------------------------------
code ENDS ; end of code
END main