3 blue merks
Solid State Member
- Messages
- 16
Not sure if there are any assembly programmers here but I will give it a shot anyway. I am trying to write a simple password program that will take in 4 digits, store them in a buffer, then compare them to the string. If the 2 match, it will display UNLOCK message, if they don't match it will display LOCK message. I am using TASM to do the assembling but that doesn't really matter. My code is not working correctly however and I am not sure why. Here is the code if anyone wants to have a look and tell me if they see a problem.
Code:
DTSEG SEGMENT
SECRET_CODE DB "1234"
STRING DB "Enter 4-digit code ",07H,24H
UNLOCK DB " Unlocked",07H,24H
LOCKED DB " Incorrect code: LOCKED",07H,24H
INBUF DB 20 DUP(?)
DTSEG ENDS
MOV AH,9H
MOV DX,OFFSET STRING
INT 21H
MOV DI,OFFSET INBUF
NXTCH: MOV AH,7H
INT 21H
CMP AL,0DH
JE CHECK
MOV [DI],AL
INC DI
MOV AH,2H
MOV DL,'*'
INT 21H
JMP NXTCH
CHECK: MOV AL,0H
MOV [DI],AL
MOV DI,OFFSET INBUF
MOV BX,OFFSET SECRET_CODE
CMP BX,DI
JE UNLOCKED
MOV AH,9H
MOV DX,OFFSET LOCKED
INT 21H
MOV AH,4CH
INT 21H
UNLOCKED: MOV AH,9H
MOV DX,OFFSET UNLOCK
INT 21H
MOV AH,4CH
INT 21H