noroozifar
شنبه 23 اردیبهشت 1391, 14:17 عصر
سلام دوستان من برنامه اسمبلی نمی نویسم و این برنامه را یکی از دوستان داده اما خطا میگیره و من هم نمی توانم حلش کنم چون اصلا اسمبلی کار کرده ام کارش هم اینه پسورد و یوزر را را چک میکند
لطفا اگر کسی میتونه خطاش را بگیره بهم بر گردونه ممنون میشم فقط خیلی فوریه ممنونم
در صورت لزوم میتونید با ای دی من تماس بگیرید در یاهو :
alaydyn
TITLE (testAB5.asm)
.model large
.stack 4096
.386
.data
msg byte 0dh, 0ah, 0dh, 0ah, "Demonisch (Andy Bate) username and password check$"
msgIns byte 0dh, 0ah, "Username and password must be 4 chars long", 0dh, 0ah, "Do not press enter, this is done for you", 0dh, 0ah, "$"
msgUs byte 0dh, 0ah, "Username (X999): $"
msgUE byte " [Invalid Input]", 0dh, 0ah, "First char must be an upper case letter", 0dh, 0ah, "$"
msgUE2 byte " [Invalid Input]", 0dh, 0ah, "Last 3 chars must be digits", 0dh, 0ah, "$"
msgMat byte 0dh, 0ah, "The passwords match!$"
msgNM byte 0dh, 0ah, "The passwords do not match$"
newLine byte 0dh, 0ah, "$"
msgEnd byte 0dh, 0ah, 0dh, 0ah, "Press any key to continue", 0dh, 0ah, 0dh, 0ah, "$"
strU byte 4 DUP ('$')
strP byte 4 DUP ('$')
strP2 byte 4 DUP ('$')
num word 0000h ;Used so data ends on a word boundary
.code
main PROC
mov ax, SEG msg ;Start of segment
mov ds, ax
mov ah, 9
mov dx, OFFSET msg ;Header
int 21h
mov dx, OFFSET msgIns ;Instructions
int 21h
getUsS: ;Get username start (loop back if error in username)
mov dx, OFFSET msgUs ;Ask for username
int 21h
mov cx, 0000h ;CX keeps count of how many chars entered
lea di, strU ;di points to the start of the username and acts as an offset
getUs: ;Get username chars (loop until got them all)
mov ah, 1 ;char read
int 21h
mov bl, al ;Sometimes al causes problems, so put in bl
cmp cx, 0000h ;First char must be uppper case letter
je testLet
jmp testDig
testLet: ;Make sure first char is an upper case letter
cmp bl, 41h ;A
jl usE
cmp bl, 5Ah ; Z
jg usE ;Error if less then A, or greater then Z
jmp getUsV
testDig: ;Last three chars must be digits
cmp bl, 30h ;0
jl usE2
cmp bl, 39h ;9
jg usE2 ;Error if less then 0, greater then 9
jmp getUsV
usE: ;First char error
mov ah, 9
mov dx, OFFSET msgUE ;Display error msg
int 21h
jmp getUsS ;Let them try again
usE2: ;Not a number error
mov ah, 9
mov dx, OFFSET msgUE2
int 21h
jmp getUsS
getUsV: ;Valid username char
mov [di], bl ;Store it
inc di ;Inc the offset
inc cx
cmp cx, 0004h ;Keep looping until 4 chars entered
jl getUs
mov bl, 00h ;First password mode
call getPass
mov bl, 01h ;Confirm password mode
call getPass
mov ah, 9
mov dx, OFFSET newLine
int 21h
lea di, strP ;di look at first pass
lea si, strP2 ;si look at second pass
mov cx, 0000h
comPC: ;Compare password chars
mov bh, [di]
mov bl, [si]
cmp bh, bl ;If the matching chars of each password don't match
jne passNM
inc di
inc si
inc cx
cmp cx, 0004h
jl comPC
jmp match ;All chars matched
match: ;They match!
mov ah, 9
mov dx, OFFSET msgMat
int 21h
jmp proEnd
passNM: ;They don't match
mov ah, 9
mov dx, OFFSET msgNM
int 21h
jmp proEnd
proEnd:
mov ah,9
mov dx,OFFSET msgEnd
int 21h
mov ah, 1 ;Wait for any key, allows the user to read any output
int 21h ;before the programme ends and the window closes
mov ah, 4ch
int 21h
main ENDP
getPass PROC
.data
msgPE byte " [Invalid Input]", 0dh, 0ah, 0dh, 0ah, "Passwords must only contain letters and digits", 0dh, 0ah, "$"
msgPE2 byte " [Invalid Format]", 0dh, 0ah, 0dh, 0ah, "Passwords must contain at least one letter", 0dh, 0ah, "And at least one digit", 0dh, 0ah, "$"
msgP byte 0dh, 0ah, "Password: $"
msgP2 byte 0dh, 0ah, "Confirm Password: $"
usedD byte 00h ;Counts how many digits are in the password
usedL byte 00h ;Counts how many letters are in the password
whichP byte 00h ;00 = pass, 01 = confirm pass
pass word 0000h
.code
mov whichP, bl
getPS:
mov cx, 0000h
mov usedD, 00h ;Reset digit and letter count (password must have at least one digit and one letter)
mov usedL, 00h
cmp whichP, 00h
jne getP2
mov ah, 9
mov dx, OFFSET msgP
int 21h
lea di, strP
jmp getPC
getP2: ;Getting a confirm pass
mov ah, 9
mov dx, OFFSET msgP2
int 21h
lea di, strP2
getPC: ;Get password char
mov ah, 8 ;Invisible input
int 21h
cmp bl, 39h
jle passPD ;30h - 39h are digits, so get possible digit
cmp bl, 41h ;A
jl pE
cmp bl, 5Ah ;Z
jl passVL ;Valid upper case char
cmp bl, 61h ;a
jl pE
cmp bl, 7Ah ;z
jg pE
jmp passVL
passVL: ;is a valid letter
inc usedL
jmp getPCC
passPD: ;Might be a valid digit
cmp bl, 30h ;Already know is 9 or less, make sure not less then 0
jl pE
inc usedD ;digit ++
getPCC: ;Get Password Char Continue
mov [di], bl
inc di
inc cx
mov ah, 6
mov dl, 2Ah ;Astrik *
int 21h
cmp cx, 0004h ;If 4 chars have not been entered yet
jl getPC
jmp testP ;Test the password
pE: ;Password error
mov ah, 9
mov dx, OFFSET msgPE
int 21h
jmp getPS ;Go back to the start
pE2: ;Not used a letter or digit
mov ah, 9
mov dx, OFFSET msgPE2
int 21h
jmp getPS ;Go back to the start
testP: ;Test the entered password si valid
cmp usedL, 00h ;Hasn't used a letter
je pE2
cmp usedD, 00h ;Hasn't used a digit
je pE2
ret
getPass ENDP
END main
لطفا اگر کسی میتونه خطاش را بگیره بهم بر گردونه ممنون میشم فقط خیلی فوریه ممنونم
در صورت لزوم میتونید با ای دی من تماس بگیرید در یاهو :
alaydyn
TITLE (testAB5.asm)
.model large
.stack 4096
.386
.data
msg byte 0dh, 0ah, 0dh, 0ah, "Demonisch (Andy Bate) username and password check$"
msgIns byte 0dh, 0ah, "Username and password must be 4 chars long", 0dh, 0ah, "Do not press enter, this is done for you", 0dh, 0ah, "$"
msgUs byte 0dh, 0ah, "Username (X999): $"
msgUE byte " [Invalid Input]", 0dh, 0ah, "First char must be an upper case letter", 0dh, 0ah, "$"
msgUE2 byte " [Invalid Input]", 0dh, 0ah, "Last 3 chars must be digits", 0dh, 0ah, "$"
msgMat byte 0dh, 0ah, "The passwords match!$"
msgNM byte 0dh, 0ah, "The passwords do not match$"
newLine byte 0dh, 0ah, "$"
msgEnd byte 0dh, 0ah, 0dh, 0ah, "Press any key to continue", 0dh, 0ah, 0dh, 0ah, "$"
strU byte 4 DUP ('$')
strP byte 4 DUP ('$')
strP2 byte 4 DUP ('$')
num word 0000h ;Used so data ends on a word boundary
.code
main PROC
mov ax, SEG msg ;Start of segment
mov ds, ax
mov ah, 9
mov dx, OFFSET msg ;Header
int 21h
mov dx, OFFSET msgIns ;Instructions
int 21h
getUsS: ;Get username start (loop back if error in username)
mov dx, OFFSET msgUs ;Ask for username
int 21h
mov cx, 0000h ;CX keeps count of how many chars entered
lea di, strU ;di points to the start of the username and acts as an offset
getUs: ;Get username chars (loop until got them all)
mov ah, 1 ;char read
int 21h
mov bl, al ;Sometimes al causes problems, so put in bl
cmp cx, 0000h ;First char must be uppper case letter
je testLet
jmp testDig
testLet: ;Make sure first char is an upper case letter
cmp bl, 41h ;A
jl usE
cmp bl, 5Ah ; Z
jg usE ;Error if less then A, or greater then Z
jmp getUsV
testDig: ;Last three chars must be digits
cmp bl, 30h ;0
jl usE2
cmp bl, 39h ;9
jg usE2 ;Error if less then 0, greater then 9
jmp getUsV
usE: ;First char error
mov ah, 9
mov dx, OFFSET msgUE ;Display error msg
int 21h
jmp getUsS ;Let them try again
usE2: ;Not a number error
mov ah, 9
mov dx, OFFSET msgUE2
int 21h
jmp getUsS
getUsV: ;Valid username char
mov [di], bl ;Store it
inc di ;Inc the offset
inc cx
cmp cx, 0004h ;Keep looping until 4 chars entered
jl getUs
mov bl, 00h ;First password mode
call getPass
mov bl, 01h ;Confirm password mode
call getPass
mov ah, 9
mov dx, OFFSET newLine
int 21h
lea di, strP ;di look at first pass
lea si, strP2 ;si look at second pass
mov cx, 0000h
comPC: ;Compare password chars
mov bh, [di]
mov bl, [si]
cmp bh, bl ;If the matching chars of each password don't match
jne passNM
inc di
inc si
inc cx
cmp cx, 0004h
jl comPC
jmp match ;All chars matched
match: ;They match!
mov ah, 9
mov dx, OFFSET msgMat
int 21h
jmp proEnd
passNM: ;They don't match
mov ah, 9
mov dx, OFFSET msgNM
int 21h
jmp proEnd
proEnd:
mov ah,9
mov dx,OFFSET msgEnd
int 21h
mov ah, 1 ;Wait for any key, allows the user to read any output
int 21h ;before the programme ends and the window closes
mov ah, 4ch
int 21h
main ENDP
getPass PROC
.data
msgPE byte " [Invalid Input]", 0dh, 0ah, 0dh, 0ah, "Passwords must only contain letters and digits", 0dh, 0ah, "$"
msgPE2 byte " [Invalid Format]", 0dh, 0ah, 0dh, 0ah, "Passwords must contain at least one letter", 0dh, 0ah, "And at least one digit", 0dh, 0ah, "$"
msgP byte 0dh, 0ah, "Password: $"
msgP2 byte 0dh, 0ah, "Confirm Password: $"
usedD byte 00h ;Counts how many digits are in the password
usedL byte 00h ;Counts how many letters are in the password
whichP byte 00h ;00 = pass, 01 = confirm pass
pass word 0000h
.code
mov whichP, bl
getPS:
mov cx, 0000h
mov usedD, 00h ;Reset digit and letter count (password must have at least one digit and one letter)
mov usedL, 00h
cmp whichP, 00h
jne getP2
mov ah, 9
mov dx, OFFSET msgP
int 21h
lea di, strP
jmp getPC
getP2: ;Getting a confirm pass
mov ah, 9
mov dx, OFFSET msgP2
int 21h
lea di, strP2
getPC: ;Get password char
mov ah, 8 ;Invisible input
int 21h
cmp bl, 39h
jle passPD ;30h - 39h are digits, so get possible digit
cmp bl, 41h ;A
jl pE
cmp bl, 5Ah ;Z
jl passVL ;Valid upper case char
cmp bl, 61h ;a
jl pE
cmp bl, 7Ah ;z
jg pE
jmp passVL
passVL: ;is a valid letter
inc usedL
jmp getPCC
passPD: ;Might be a valid digit
cmp bl, 30h ;Already know is 9 or less, make sure not less then 0
jl pE
inc usedD ;digit ++
getPCC: ;Get Password Char Continue
mov [di], bl
inc di
inc cx
mov ah, 6
mov dl, 2Ah ;Astrik *
int 21h
cmp cx, 0004h ;If 4 chars have not been entered yet
jl getPC
jmp testP ;Test the password
pE: ;Password error
mov ah, 9
mov dx, OFFSET msgPE
int 21h
jmp getPS ;Go back to the start
pE2: ;Not used a letter or digit
mov ah, 9
mov dx, OFFSET msgPE2
int 21h
jmp getPS ;Go back to the start
testP: ;Test the entered password si valid
cmp usedL, 00h ;Hasn't used a letter
je pE2
cmp usedD, 00h ;Hasn't used a digit
je pE2
ret
getPass ENDP
END main