flat assembler
Message board for the users of flat assembler.
Index
> DOS > How to read and verify a password? |
Author |
|
OzzY 25 Sep 2003, 22:05
Please help me!!! I need an example....
|
|||
25 Sep 2003, 22:05 |
|
Yawgmoth 25 Sep 2003, 22:06
Try putting your data at the end of the program.
|
|||
25 Sep 2003, 22:06 |
|
Tomasz Grysztar 25 Sep 2003, 22:14
No, he is correctly jumping over the data.
The problem is that you are comparing one byte in AL to a multi-byte value. The text "pass" consists of four bytes (characters), so you have to read four character from keyboard consecutively and compare that sequence to sequence of bytes that makes the password. |
|||
25 Sep 2003, 22:14 |
|
OzzY 25 Sep 2003, 22:34
Could you give me an example please??
Thanks Privalov!!! |
|||
25 Sep 2003, 22:34 |
|
Tomasz Grysztar 25 Sep 2003, 22:43
Just make it with one character first (for example modify your above program with "p" instead of "pass") and then try to repeat the same scheme for more characters (in a loop preferably).
|
|||
25 Sep 2003, 22:43 |
|
OzzY 25 Sep 2003, 22:49
But, if I don't know how many letters will go, example:
What's your name? user enters--> John Hi John!! How could I do this? |
|||
25 Sep 2003, 22:49 |
|
Tomasz Grysztar 25 Sep 2003, 22:51
Oh, one more thing - you have not reserved the space for your buffer correctly, it should be:
Code: _p db 4,0 rb 4 And to get the first character of read string into AL (as you are then trying to check the contents of AL), you should do: Code: mov al,[_p+2] as the first byte is the maximum size of buffer and the second byte is the count of read characters, and then the characters follow, so they begin from _p+2 address. |
|||
25 Sep 2003, 22:51 |
|
Tomasz Grysztar 25 Sep 2003, 22:56
OK, here you are with example:
Code: org 100h mov dx,_msg mov ah,9 int 21h mov dx,_buffer mov ah,0Ah int 21h mov dx,_greet1 mov ah,9 int 21h mov cl,[_buffer+1] xor ch,ch mov bx,_buffer+2 _loop: mov ah,2 mov dl,[bx] int 21h inc bx loop _loop mov dx,_greet2 mov ah,9 int 21h xor ah,ah int 16h int 20h _msg db 'Enter your name: ',24h _greet1 db 13,10,'Hello, ',24h _greet2 db '!!!',13,10,24h _buffer db 80h,0 rb 80h |
|||
25 Sep 2003, 22:56 |
|
OzzY 25 Sep 2003, 22:58
That was what I was looking for, thanks!!!
|
|||
25 Sep 2003, 22:58 |
|
WhiteDwarf 15 Jan 2004, 06:15
Quote: _loop: Would the code be optimized if you put that line of code before the loop. So then the loop won't needlessly be loading ah with 2 every time.? |
|||
15 Jan 2004, 06:15 |
|
Octavio 15 Jan 2004, 09:06
cmp al,'pass'
is an invalid instruction ,fasm must output a error size comment |
|||
15 Jan 2004, 09:06 |
|
Matrix 27 Oct 2004, 10:35
Privalov wrote: OK, here you are with example: nice, the dos function to read a string, i have discovered the new line bug in this code 5 years ago, so i have recognized it. but this can be a size optimization method under dos. |
|||
27 Oct 2004, 10:35 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.