home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol228 / password.asm < prev    next >
Encoding:
Assembly Source File  |  1986-02-13  |  5.1 KB  |  247 lines

  1. ;    MODULE NAME:  PASSWORD.ASM
  2. ;    LAST UPDATE:  15 DEC 84          BY: PEC
  3. ;    FUNCTION:     SECURITY PASSWORD FOR CP/M 2.2
  4. ;======================================================================
  5.  
  6. ;    ASCII CHARACTERS
  7.  
  8.     CR    EQU    0DH    ; CARRIAGE RETURN
  9.     LF    EQU    0AH    ; LINE FEED
  10.     BYPASS    EQU    1AH    ; CONTROL-Z, FOR INTERRUPT
  11.     BDOS    EQU    5    ; BDOS entry point
  12.     DRIVE    EQU    4    ; current drive number
  13.     LOCKUP    EQU    7eh+15h    ; will lock up keyboard of Hazeltine
  14.                 ; Esprit
  15.     TAB    EQU    09h    ; horizontal tab
  16.  
  17.     ORG    100H    ; TRANSIENT PROGRAMME AREA
  18. ;
  19. savecpm:
  20.     lxi    h,0    ; save the CP/M stack
  21.     dad    sp    ; and the stack pointer
  22.     shld    CPMSP
  23.     lxi    sp,stack    ; set up local stack
  24.     lda    DRIVE    ; save current disk
  25.     sta    DRSAV
  26. ;
  27. ;    CLEAR SCREEN
  28. ;
  29.     mvi    b,3    ; use Register B as a counter
  30.     call    clear
  31. signon:
  32.     lxi    d,msg1    ; point to first message
  33.     call    sprint    ; and print it
  34.     call    crlf    ; space down
  35. ;
  36. ;    INPUT SECTION
  37. ;
  38. getnom:    lxi    h,text    ; point to the text
  39. input:    mvi    e,0ffh    ; initialise function 6 for input
  40.     mvi    c,6
  41.     push    h
  42.     push    b
  43.     call    BDOS    ; and ask for character from console
  44.     pop    b
  45.     pop    h
  46.     ora    a    ; logical OR of Register A
  47.     jz    input    ; if zero then loop until key pressed
  48.     cpi    BYPASS
  49.     jz    DONE    ; quit if a CONTROL-Z
  50.     call    clcuc    ; convert to upper case
  51.     mov    m,a    ; else put character into memory
  52.     inx    h    ; get ready for next character
  53.     cpi    CR    ; was it Return
  54.     jz    check    ; if so compare with PASSWORD
  55.     jmp    input    ; else loop
  56. ;
  57. ;    CHECK THE NAME
  58. ;
  59. check:    lxi    d,name    ; point to the permitted name
  60.     lxi    h,text
  61. match:    ldax    d    ; character from NAME
  62.     cpi    '$'    ; finished yet?
  63.     jz    pass    ; ok then print welcome message
  64.     cmp    m    ; else compare with memory
  65.     jnz    fail    ; if not matched, then quit
  66.     inx    d
  67.     inx    h
  68.     jmp    match    ; else continue
  69. ;
  70. ;    OUTPUT SECTION
  71. ;
  72. pass:    mvi    b,3    ; re-set the counter
  73. read:    lxi    h,text    ; point to start of message
  74.     call    crlf    ; and space down
  75.     push    h
  76.     push    b
  77.     lxi    d,msg3    ; print welcome message
  78.     mvi    c,9
  79.     call    BDOS
  80.     pop    b
  81.     pop    h
  82. it:    mov    a,m    ; get character
  83.     call    print    ; and print to screen
  84.     inx    h    ; point to next character
  85.     cpi    CR    ; are we finished ?
  86.     jz    id    ; then get second message
  87. ;
  88.     jmp    it    ; else read another character
  89. ;
  90. ;
  91. ;    ID Number section
  92. ;
  93. id:    lxi    d,msg2    ; get second message
  94.     call    sprint
  95.     call    crlf
  96. getid:    lxi    h,text2    ; prepare buffer for ID Number
  97. input2:    mvi    e,0ffh    ; initialise function 6 for input
  98.     push    b
  99.     mvi    c,6
  100.     push    h
  101.     call    BDOS    ; and ask for character from console
  102.     pop    h
  103.     pop    b
  104.     ora    a    ; logical OR of Register A
  105.     jz    input2    ; if zero then loop until key pressed
  106.     cpi    BYPASS
  107.     cz    DONE    ; quit if CONTROL-Z
  108.     mov    m,a    ; else put character into memory
  109.     inx    h    ; get ready for next character
  110.     cpi    CR    ; was it Return
  111.     jz    check2    ; if so compare with ID Number
  112.     jmp    input2    ; else loop
  113. ;
  114. check2:    lxi    d,number    ; point to the permitted ID number
  115.     lxi    h,text2
  116. match2:    ldax    d    ; character from NAME
  117.     cpi    '$'    ; finished yet?
  118.     jz    success    ; ok then print welcome message
  119.     cmp    m    ; else compare with memory
  120.     jnz    fail2    ; if not matched, then quit
  121.     inx    d
  122.     inx    h
  123.     jmp    match2    ; else continue
  124. ;
  125. ;    SUBROUTINES
  126. ;
  127. ;    CLCUC.ASM
  128. ;
  129. ;    convert lower case to upper case
  130. ;
  131. ;    entry:    A - character to convert
  132. ;    exit:    A - converted to upper case
  133. ;
  134. clcuc:    cpi    'a'    ; compare to "a"
  135.     rc        ; return if less than "a"
  136.     cpi    'z'+1    ; see if larger than "z"
  137.     rnc        ; not lower case, so quit
  138.     sui    'a'-'A'    ; change "a...z" into "A...Z"
  139.     ret
  140. ;
  141. ;    CLEAR SCREEN - for Hazeltine Esprit
  142. ;
  143. clear:    mvi    a,7eh    ; tilde
  144.     call    print
  145.     mvi    a,1ch
  146.     call    print
  147.     ret
  148. ;
  149. sprint:    push    h
  150.     push    b
  151.     mvi    c,9    ;set up string print function
  152.     call    BDOS    ; call BDOS to do it
  153.     pop    b
  154.     pop    h
  155.     ret
  156. ;
  157. crlf:    push    psw    ; save Register A
  158.     mvi    a,CR    ; return
  159.     call    print
  160.     mvi    a,LF    ; line feed
  161.     call    print
  162.     pop    psw
  163.     ret        ; done
  164. ;
  165. lfadj:    mvi    m,LF    ; add line feed to memory
  166.     inx    h    ; increment the pointer
  167.     ret
  168. ;
  169. print:    mov    e,a    ; put character into Register E
  170.     push    b
  171.     mvi    c,6    ; initialise print routine
  172.     push    psw
  173.     push    h
  174.     call    BDOS    ; and do it
  175.     pop    h
  176.     pop    psw
  177.     pop    b
  178.     ret        ; done
  179. ;
  180. success:
  181.     lxi    d,startup
  182.     call    sprint
  183.     call    DONE
  184. ;
  185. fail:    dcr    b    ; count down 1
  186.     jnz    retry
  187.     lxi    d,signoff
  188.     call    sprint    ; quit
  189.     jmp    getnom
  190. ;
  191. fail2:    dcr    b    ; count down 1
  192.     jnz    retry2
  193.     lxi    d,signoff
  194.     call    sprint    ; quit
  195.     jmp    getnom
  196. ;
  197. retry:    call    clear
  198.     lxi    d,again
  199.     call    sprint
  200.     jmp    getnom
  201. ;
  202. retry2:    call    clear
  203.     lxi    d,again2
  204.     call    sprint
  205.     jmp    getid
  206. ;
  207. DONE:    lda    DRSAV    ; return to CP/M without re-boot
  208.     sta    DRIVE    ; restore current disk
  209.     lhld    CPMSP    ; restore CP/M stack
  210.     sphl
  211.     ret
  212. ;
  213. ;    MESSAGES
  214. ;
  215. again    db    CR,LF,'You missed that time, please try again'
  216.     db    CR,LF,CR,LF
  217. msg1    db    TAB,TAB,'PASSWORD - a programme to provide a secure'
  218.     db    CR,LF,TAB,TAB,'sign on system for CP/M 2.2',CR,LF,LF
  219.     db    'This programme does not print to screen.'
  220.     db    CR,LF,'Enter your name please - ',CR,LF
  221.     db    'Then type <RETURN> to allow check to be made.'
  222.     db    CR,LF,'$'
  223. again2    db    CR,LF,'You missed that time, please try again'
  224.     db    CR,LF
  225. msg2    db    CR,LF,CR,LF,'Now enter your ID Number - ',CR,LF,'$'
  226. msg3    db    CR,LF,'Welcome $'
  227. name    db    'NAME$'
  228. number    db    '123$'
  229. signoff    db    CR,LF,'You are not authorised to use the computer,'
  230.     db    ' goodbye now',LOCKUP,'$'
  231. startup    db    CR,LF,'You are authorised to start now, go ahead$'
  232. ;
  233. ;    LOCAL STORAGE SPACE
  234. ;
  235. DRSAV    db    0    ; current drive number
  236. CPMSP    dw    0    ; CP/M stack pointer
  237. ;
  238.     ds    20h    ; 32-byte stack
  239. stack:
  240. ;
  241. text    equ    $    ; begin message here
  242. text2    equ    $+128    ; begin second message for ID Number
  243. ;
  244.     end
  245.     
  246.         
  247.