Saturday, December 11, 2010

nostalgia

Back in college my first assembly language machine problem is reading character input. I found the following old snippets from the nostalgia of my college days.

;======================
.model small
.stack 64
.data
pass db 'wade','$'
ass db '*','$'
input db 'Enter Password: ','$'
invalid db 'Sorry, Invalid Password',13,10,'$'
valid db 'Access Granted',13,10,'$'

.code
main proc near
begin:

add bx,1
mov ah,06
mov al,00
mov bh,07
mov cx,00
mov dx,184fh
int 10h
mov ax,@data
mov ds,ax
mov cx,4
lea SI,pass
mov ah,02
mov bh,00
mov dh,09
mov dl,30
int 10h
mov ah,09
mov dx,offset input
int 21h
compare:
mov dl,[SI]
mov ah,07
int 21h
cmp al,dl
JE right
jmp wrong
right: inc SI
mov ah,09
mov dx,offset ass
int 21h

loop compare
mov ah,07
int 21h
mov ah,02
mov bh,00
mov dh,13
mov dl,34
int 10h
mov ah,09
mov dx,offset valid
int 21h
mov ah,07
int 10h
mov ah,4ch
int 21h
start: JE begin
wrong: inc SI
mov ah,09
mov dx,offset ass
int 21h
mov dl,[SI]
mov ah,07
int 21h
cmp al,dl
loop wrong
mov ah,02
mov bh,00
mov dh,13
mov dl,29
int 10h

mov ah,09
mov dx,offset invalid
int 21h
mov ah,07
int 21h
cmp bx,1
JE start
cmp bx,2
JE start
jmp exit
exit:
int 18h
main endp
End main

That is all folks.

0 comments:

Post a Comment