home *** CD-ROM | disk | FTP | other *** search
/ RBBS in a Box Volume 1 #2 / RBBS_vol1_no2.iso / 007z / ssward.asm < prev    next >
Assembly Source File  |  1985-08-20  |  3KB  |  106 lines

  1. ;
  2. ; Program for password protection of the system
  3. ;    Written by Dave Staehlin
  4. ;    5430 Candleglow NE
  5. ;    Albuquerque,NM 87111
  6. ;    (505) 822-1889
  7. ;
  8. ; Enter the password desired at the 'psw' label.  Note that this routine
  9. ; is set up for a 20 character maximum length password.
  10. ;
  11. ; Use this program by entering your password below and assembling this 
  12. ; program into a .COM type file by using EXE2BIN.  Then place the command
  13. ; PASSWORD as the first line in your AUTOEXEC.BAT file.  This program
  14. ; will not keep anyone that knows what their doing off your system but
  15. ; it will keep the kids, wifey, and nosey secretaries from gaining
  16. ; unauthorized access to your system.  It serves its purpose on a hard
  17. ; disk system.  I don't know how useful it would be on a floppy based system
  18. ; however.
  19. ;
  20. ; Since this is my first attempt at 8088 assembler, I assume no responsibility
  21. ; for my oddball way of coding this!  I've still got a lot to learn!
  22. ;
  23. ;                            Dave
  24. ;
  25. ;
  26. password    segment                ;set up code and data section
  27.         assume    cs:password,ds:password,es:password ;tell assembler about conditions at entry
  28.         org    100h            ;com programs begin here
  29. main:        jmp    begin            ;skip area for data
  30. ;
  31. ;    *** DATA AREA ***
  32. ;
  33. ;  *** Put your password between the quotes in the line below. ***
  34. ;
  35. psw        db    'place password here'  ;room for 20 byte password
  36. ;
  37. inpsw        db    '                    '    ;store user input password here
  38. prompt        db    1bh,'[2J',1bh,'[32;40mPlease enter system password: $'
  39. match        db    13,10,10,1bh,'[2JPassword Accepted - Initializing system.....',13,10,'$'
  40. ;
  41. ;    *** PROGRAM STARTS HERE ***
  42. begin:        mov    dx,offset prompt    ;output the prompt to the consol
  43.         call    stringout
  44.         mov    cl,20            ;maximum length of password
  45.         mov    bx,offset inpsw        ;put input password here
  46. inloop:        call    charin            ;consol input w/o echo
  47.         cmp    al,08h            ;backspace?
  48.         jnz    goon            ;go on if not
  49.         cmp    cl,20            ;at the beginning?
  50.         jz    inloop            ;ignore if so
  51.         inc    cl            ;else increment the counter
  52.         dec    bx            ;and decrement the memory pointer
  53.         mov    al,' '
  54.         mov    [bx],al            ;erase last char in input string
  55.         call    backspc            ;output a backspace to console
  56.         jmp     inloop
  57. ;
  58. ;
  59. goon:        cmp    al,0dh            ;carriage return?
  60.         jz    checkit            ;done with input if so
  61.         dec    cl            ;count one input done
  62.         jz    checkit            ;done if 20 chars input
  63.         mov    [bx],al            ;else save the char
  64.         inc    bx            ;increment save address by one
  65. echo:        mov    dl,'.'            ;output a period echo
  66.         call    charout
  67.         jmp    inloop            ;and get another
  68. ;
  69. checkit:    mov    cx,20            ;set up counter for string compare
  70.         mov    dx,offset match        ;assume a match
  71.         mov    si,offset psw        ;compare the strings
  72.         mov    di,offset inpsw
  73.         cld                ;clear the df flag for compare
  74.         repe    cmpsb
  75.         cmp    cx,0            ;did cl reach zero?
  76.         jz    gotmatch        ;if they match
  77.         jmp    inloop            ;oops - bomb system
  78. ;
  79. ;    we have a match - return system to the user
  80. ;
  81. gotmatch:    mov    ah,9            
  82.         int    21h    
  83.         ret                ;return to system
  84. ;
  85. ; subroutines
  86. ;
  87. stringout:    mov    ah,9            ;output a string to the console
  88.         int    21h
  89.         ret
  90. charout:    mov    ah,2            ;output a character to the console
  91.         int    21h
  92.         ret
  93. charin:        mov    ah,7            ;input console char w/o echo
  94.         int    21h
  95.         ret
  96. backspc:    mov    dl,08h            ;output a backspace
  97.         call    charout
  98.         mov    dl,' '            ;output a backspace
  99.         call    charout
  100.         mov    dl,08h            ;output a backspace
  101.         call    charout
  102.         ret
  103. ;
  104. password    ends                ;end of code and data section
  105.         end    main
  106.