Here is another Assembly Language Tutorial Sample Program. This program is creating a fixed password to a certain application. This One of the basic examples unlike some of the other programs that passwords can be changed without accessing the source code. But here we created a program that has a fixed password abcdef. It is then displayed as a # when type from the keyboard. When password is correct the background color is the changed and the ASCII characters then is displayed. A86 is used as the assembler for the program. Below is a sample output of the program.

|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
call clear ;clear the screen
call center
mov ah,09h ;display string
lea dx,msg2 ;prints Enter password
int 21h
mov bl,3
again:
mov ah,07 ;direct keyboard input
int 21h
mov bh,al ;move the input al to bh
cmp bh,0dh
je again
call asterisk
cmp bh,'a' ;compare bh with J
je again1 ;if equal jump to again
jne wrong ;if not to wrong
again1:
mov ah,07
int 21h
mov bh,al
cmp bh,0dh
je invalid9
call asterisk
cmp bh,08h
je again
cmp bh,'b' ;compare bh with P
je again2
jne wrong
again2:
mov ah,07
int 21h
mov bh,al
call asterisk
cmp bh,'c' ;compare bh with h
je again3
jne wrong
invalid9:
call invalid8
again3:
mov ah,07
int 21h
mov bh,al
call asterisk
cmp bh,'d' ;compare bh with I
je again4
jne wrong
again4:
mov ah,07
int 21h
mov bh,al
call asterisk
cmp bh,'P' ;compare bh with C
je again5
jne wrong
again5:
mov ah,07
int 21h
mov bh,al
call asterisk
cmp bh,'e' ;compare bh with E
je again6
jne wrong
again6:
mov ah,07
int 21h
mov bh,al
call asterisk
cmp bh,'f' ;compare bh with s
je again7
jne wrong
invalid8:
call invalid
again7:
mov ah,07
int 21h
mov bh,al
cmp bh,0dh ;compare the input with the enter key
je exit
jne wrong
wrong:
mov ah,07
int 21h
mov bh,al
call asterisk
cmp bh,0dh ;compare the input with the enter key
je invalid
jne wrong
invalid:
call clear
call center
mov ah,09
lea dx,msg1 ;prints retry password
int 21h
dec bl ;decrements bl until 3 attempts
cmp bl,0
je invalid2
jmp again
invalid2:
call clear
call center
mov ah,09 ;print password failed!!!
lea dx,msg3
int 21h
int 20h
exit:
call clear
call center |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
;ASCII program
mov ax,0600 ;setting background
mov bh, 30h ;color of the attribute
mov cx,0000h ;where the color starts to point
mov dx,184fh ;where the color ends to point
int 10h
mov ax,0b800 ;location of the screen
mov es,ax ;location of the screen move to es register
mov bx,60+(160*4) ;where the title starts to display and move to bx register
mov si,msg4 ;the message move to si register
mov cx,16 ;the numbers of letters that will display
print:
mov al,b[si] ;the value of si is move to al register
mov es:[bx],al ;move the value of al to the location of es:[bx]
inc si ;increment the si
add bx,2 ;add bx by 1 for the attribute
loop print ;looping
int 21h ;to terminate the loop
mov bh,0 ;holds the characters
mov di,160*8 ;where the characters will display and move to di register
mov cx,255 ;the number of characetrs that will display
char:
mov al,bh ;moving bh to the al register
mov es:[di],al ;move the value of al is move to the location of es:[di]
inc bh ;increment the bh
add di,8 ;to make 20 columns
loop char ;looping
int 20h ;to terminate the loop
msg4:db 'ASCII CHARACTERS'
msg3 db 'PASSWORD INCORRECT!DENIED ACCESS!$'
msg2 db 'PASSWORD: $'
msg1 db 'RETRY: $'
asterisk: ;prints asterisk
mov ah,09h
lea dx,ask
int 21h
ret
ask db '#$'
clear: ;clear screen
mov ax,03
int 10h
center: ;set cursor at the center
mov ah,02
mov bh,00
mov dh,12
mov dl,33
int 10h
ret |

13 Comments until now.
very good programm
Thank you!
can you show me the program that can input string and output it 5 times vertically???
how to clear a value of a variable???
how can i run this program completely?>
how can i run this program?
Amazing code
well done 
thnx in advance
a small question, how can i run this code?
I used an A86 assembler
why does the program always say invalid and try again even if i put the password abcdef, can you explain the reason, please, i am a newbie in assembly language.
The program has a defined password which should have the exact characters.
good!
plz give some suggestion, how can we write assembly code by use pic 16f877a for led blinking at any port.
When I started learning embedded systems I used a PIC Simulator (http://www.oshonsoft.com/) which is closest to reality. The simulator has the assembler that is then loaded to the PIC using a pic loader. My classmate before used micro c on his projects. I suggest that you use a z80 micro-controller because its easier and you can buy the loader together with the micro-controller. There is also a manual included which has some tips and examples on how to start. Visit this website to buy your devices. http://www.e-gizmo.com
Comment!