TASM DOSBOX- Password system

Thread Starter

Matthew Aleguiojo

Joined Oct 7, 2018
1
Hello, I'm currently new to this forum since I've heard from a friend that it is a great place to ask about programming
My problem is as stated in the title, a password system in TASM. I'm also new to the TASM and it's ability if that explains a lot more about me.
I was asked to create a password system that will accept a set of 5 characters, I know it is easy, I can do a system of that myself, the problem lies with the condition. The professor asked me to create one using through PUSH and POP commands and that the system will terminate upon 3 tries if the wrong password was inputted. The password is "TIPML", I've done all the basic stuff with regards to using PUSH to store values, what breaks my code is the part where I try to compare it to pass db, it just fails to jump whether I've put the right or wrong value. Below is the current code I have been working on.

Code:
.model small
.stack
.data
    pass db "LMPIT$"
.code
start:
    mov cx, 5
 
    a:
 
    mov ah, 07
    int 21h
    mov bl, al
    PUSH bx
 
    mov ah, 02
    mov dl, '*'
    int 21h
 
 
    loop a
 
    mov ax,0
    mov bx,0
    mov dx,0
    mov cx, 5
    mov dx, offset pass
    b:
    POP bx
    mov al, bl
    cmp al, dl
    je lop
    jne wrong
 
    lop:
    loop b
 
    je right
    jne wrong
 
    right:
    mov ah, 2
    mov dl, 'r'
    int 21h
    jmp exit
 
    wrong:
    mov ah, 2
    mov dl, 'w'
    int 21h
    jmp exit
 
    exit:
    mov ah, 4ch
    int 21h
 
end start
Mod edit: added code tags
 

Raymond Genovese

Joined Mar 5, 2016
1,653
It has been at least 134 years since I have written any TASM code, but I *think* I see the problem.

mov dx, offset pass is doing what you think, but:
cmp al, dl is NOT doing what you think.

Since it is homework, I am not going to give you the answer straight out, but consider what this does:

Code:
.DATA
num DWORD 0

.CODE
mov ax, WORD PTR [num] ; Load a word-size value from a DWORD
IOW, use a pointer directive like, mov BYTE PTR [ESI]
 
Top