Password program for work any takers

I need a program written in assembler for a password program the program should prompt the user to enter a password and the password should be stored in memory

a valid password is made up at least 6 and a maximum of 12 characters
the first character must be an alphabetic character
and the remaining charcters must be alpanumeric

and if an invalid character is discoverd an appropriete error messege be displayed

once the password is enterd a length check should be performed if it is to short an error messege is displayed

Could any one write this proggram as a challenge to yourself it for my spare computer to personalise it cheers


  • I used TASM in making this program..i admit it's quite messy and not well-commented, but i'm willing to give you help on anything you don't understand..i haven't tested it for all cases so plz tell me if there's any unhandled case...there's the code:
    data segment
    prompt db 'please enter a password:',13,10,'$'
    invchar db 'error: invalid char',13,10,'$'
    pshort db 'error: password is shorter than 6 chars',13,10,'$'
    plong db 'error: password is longer than 12 chars',13,10,'$'
    password db 12 dup (?)
    crlf db 13,10,'$'
    data ends

    code segment
    assume cs:code,ds:data
    mov ax,data
    mov ds,ax

    mov ah,09
    lea dx,prompt
    int 21h ; display message

    mov si,0
    mov ah,0h
    int 16h
    call check_char
    cmp si,12
    jge skip
    mov password+si,al
    cmp al,13 ; ENTER key
    je exit
    cmp al,8 ; BACKSPACE key
    jne skip_dec
    dec si
    cmp si,0ffffh
    je skip_dec
    sub si,2 ; since -2 + inc = 1 dec
    inc si
    jmp scanf
    exit: ; '0'=48, 'A'=65->'Z'=90=101 1010=5a, 'a'=97=110 0001=61->'z'=122
    lea dx,crlf
    mov ah,09h
    int 21h ; printf("
    cmp byte ptr password,'A'
    jl invalid_char
    cmp byte ptr password,'z'
    jg invalid_char
    mov dl,password
    sub dl,91
    cmp dl,6
    jl invalid_char
    ; now check for length
    cmp si,6
    jl short_pass
    cmp si,12
    jg long_pass
    ; here passwd is correct
    jmp terminate
    ; error msgs:
    invalid_char: lea dx,invchar
    jmp disp_msg
    short_pass: lea dx,pshort
    jmp disp_msg
    long_pass: lea dx,plong
    mov ah,09h
    int 21h
    mov ax,4c00h
    int 21h

    check_char proc near ; al=ASCII char code
    push ax
    push bx
    push cx
    push dx
    cmp al,8 ; BACKSPACE key
    jnz else1
    mov ah,3
    mov bh,0
    int 10h ; get cursor pos.
    cmp dx,0100h ; start of next line (after msg)
    jz endz
    mov ah,2
    sub dx,1
    int 10h ; repos. cursor
    mov ah,0ah
    mov al,' '
    mov bh,0
    int 10h ; blanking char. without repos.
    jmp endz
    call put_hash_char
    pop dx
    pop cx
    pop bx
    pop ax
    check_char endp

    put_hash_char proc near
    push ax
    push bx
    mov bh,0
    mov ah,0eh
    mov al,'*'
    int 10h
    pop bx
    pop ax
    put_hash_char endp

    code ends
    end start

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion