i am just starting into assembly programming, i am currently trying to trace a program step by step to determine a value of a certain register for the particular line and unfortunately, i dont understand how it goes...

i am working on this code i found from somewhere, it says that it will display a message if i'll be able to provide or enter a correct password...
my concerns arre as follows:
the code is uncommented,and it is very hard for me to trace it as i want since i honestly dont understand yet...i want to learn but how can i go on if there is no one to lead on and show me some samples?i hope you all guys understand my situation..thank so much...and please do help me by commenting each line of the code below.i'll appreciate greatly if you'll do..of course,thank you so much for the time.[IMG]http://images.devshed.com/fds/smilies/smile.gif[/IMG]more power![IMG]http://images.devshed.com/fds/smilies/smile.gif[/IMG]
------------------------------------------------------------------
.MODEL TINY
.CODE
ORG 100H
START:
JMP BEGIN
DATA1 DB 0A3H, 0A1H, 8FH, 0E9H, 8CH, 0ABH, 0DAH, 0A9H
DB 95H, 0BAH, 0DAH, 0A7H, 8EH, 0EEH, 88H, 0A7H
DATA2 DB 9DH, 0A6H, 8EH, 0EFH, 0DBH, 0EFH, 0DAH, 87H
DB 0DAH, 0A6H, 95H, 0BEH, 9FH, 0EEH, 83H, 0A1H
DATA3 DB 8FH, 0E9H, 96H, 0A2H, 0DAH, 0BEH, 9BH, 0BDH
DB 89H, 0EEH, 8EH, 0A6H, 9FH, 0EEH, 8EH, 0ABH
DATA4 DB 99H, 0A6H, 94H, 0A7H, 99H, 0AFH, 96H, 0EEH
DB 9FH, 0B6H, 9BH, 0A3H, 0D4H, 0E0H, 0D4H, 0EAH
DATA5 DB 15 DUP(24H)
DATA6 DB "Enter the password: $"
DATA7 DB "Don't push it...exciting...$"
BEGIN:
LEA DX, DATA6
MOV AH, 9
INT 21H
XOR SI, SI
INPUT:
MOV AH, 1
INT 21H
CMP AL, 0DH
JZ PROCESS
MOV BYTE PTR [DATA5 + SI], AL
INC SI
CMP SI, 0AH
JZ WHAT_THE
JMP INPUT
PROCESS:
CLD
LEA SI, DATA1
MOV DI, SI
LEA CX, DATA5
SUB CX, SI
SHR CX, 1
CONVERT:
LODSW
XOR AX, 0CEFAH
STOSW
LOOP CONVERT
MOV AL, 0
LEA BX, DATA5
SUB BX, 2
XLAT
MOV DL, AL
LEA SI, BYEBYE
SUB SI, 0BH
PUSH SI
MOV DI, SI
MOV CX, 000AH
DECODE:
LODSB
XOR AL, DL
STOSB
LOOP DECODE
MOV CX, 000AH
POP SI
LEA DI, DATA5
REPE CMPSB
JNE WHAT_THE
LEA DX, DATA1
MOV AH, 9
INT 21H
JMP BYEBYE
WHAT_THE:
LEA DX, DATA7
MOV AH,9
INT 21H
JMP BYEBYE
DB 64H, 41H, 46H, 40H, 0EH, 1DH, 14H, 1FH, 18H,0AH, 00H
BYEBYE:
MOV AX, 4C00H
INT 21H
END START
------------------------------------------------------------------


i am hoping to read more from you guys...[IMG]http://images.devshed.com/fds/smilies/smile.gif[/IMG]

For information on BIOS/DOS interrupt services you can retrieve them in a well known site - ralphs brown interrupt list: http://www.ctyme.com/intr/int.htm

I wont be doing your dirty work. If you would of put some time and research a bit you'll find its not hard to comment this yourself.

alright, i'll just explanations for the lines i've put comments...please,i really have to get the flow,i just need a sample on how to get the first letter of the password...just show me how and i'll do the rest...thank you for the time...
------------------------------------------------------------------

.MODEL TINY
       .CODE
       ORG 100H
START:
       JMP BEGIN

DATA1    DB    0A3H, 0A1H, 8FH, 0E9H, 8CH, 0ABH, 0DAH, 0A9H
           DB    95H, 0BAH, 0DAH, 0A7H, 8EH, 0EEH, 88H, 0A7H
DATA2    DB    9DH, 0A6H, 8EH, 0EFH, 0DBH, 0EFH, 0DAH, 87H
           DB    0DAH, 0A6H, 95H, 0BEH, 9FH, 0EEH, 83H, 0A1H
DATA3    DB    8FH, 0E9H, 96H, 0A2H, 0DAH, 0BEH, 9BH, 0BDH
           DB    89H, 0EEH, 8EH, 0A6H, 9FH, 0EEH, 8EH, 0ABH
DATA4    DB    99H, 0A6H, 94H, 0A7H, 99H, 0AFH, 96H, 0EEH
           DB    9FH, 0B6H, 9BH, 0A3H, 0D4H, 0E0H, 0D4H, 0EAH
DATA5    DB    15 DUP(24H)
DATA6    DB    "Enter the password: $"
DATA7    DB    "Don't push it...exciting...$"

BEGIN:
           LEA DX, DATA6
           MOV AH, 9
           NT 21H
           XOR SI, SI

INPUT:
    MOV AH, 1
    INT 21H
    CMP AL, 0DH     ;is this a carriage return or 13 imediate value?why it is needed?
    JZ PROCESS
    MOV BYTE PTR [DATA5 + SI], AL
    INC SI
    CMP SI, 0AH     ;line feed or 10?why?
    JZ WHAT_THE
    JMP INPUT

PROCESS:
           CLD
           LEA SI, DATA1
           MOV DI, SI
           LEA CX, DATA5
           SUB CX, SI    ;CX = ?
           SHR CX, 1      ; CX devide by 2?

CONVERT:
           LODSW
           XOR AX, 0CEFAH    ;why this value?
           STOSW
           LOOP CONVERT
           MOV AL, 0
           LEA BX, DATA5
           SUB BX, 2
           XLAT
           MOV DL, AL
           LEA SI, BYEBYE
           SUB SI, 0BH
           PUSH SI
           MOV DI, SI
           MOV CX, 000AH

DECODE:
           LODSB
           XOR AL, DL
           STOSB
           LOOP DECODE
           MOV CX, 000AH   ;why this value?
           POP SI
           LEA DI, DATA5
           REPE CMPSB
           JNE WHAT_THE
           LEA DX, DATA1
           MOV AH, 9
           INT 21H
           JMP BYEBYE

WHAT_THE:
          LEA DX, DATA7
          MOV AH,9
          INT 21H
          JMP BYEBYE
          DB 64H, 41H, 46H, 40H, 0EH, 1DH, 14H, 1FH, 18H,0AH, 00H       ;why it is here and what it does?
BYEBYE:
          MOV AX, 4C00H
          INT 21H
END START

------------------------------------------------------------------

thank you..:)

alright, i'll just explanations for the lines i've put comments...please,i really have to get the flow,i just need a sample on how to get the first letter of the password...just show me how and i'll do the rest...thank you for the time...
------------------------------------------------------------------
.MODEL TINY
.CODE
ORG 100H
START:
JMP BEGIN

DATA1 DB 0A3H, 0A1H, 8FH, 0E9H, 8CH, 0ABH, 0DAH, 0A9H
DB 95H, 0BAH, 0DAH, 0A7H, 8EH, 0EEH, 88H, 0A7H
DATA2 DB 9DH, 0A6H, 8EH, 0EFH, 0DBH, 0EFH, 0DAH, 87H
DB 0DAH, 0A6H, 95H, 0BEH, 9FH, 0EEH, 83H, 0A1H
DATA3 DB 8FH, 0E9H, 96H, 0A2H, 0DAH, 0BEH, 9BH, 0BDH
DB 89H, 0EEH, 8EH, 0A6H, 9FH, 0EEH, 8EH, 0ABH
DATA4 DB 99H, 0A6H, 94H, 0A7H, 99H, 0AFH, 96H, 0EEH
DB 9FH, 0B6H, 9BH, 0A3H, 0D4H, 0E0H, 0D4H, 0EAH
DATA5 DB 15 DUP(24H)
DATA6 DB "Enter the password: $"
DATA7 DB "Don't push it...exciting...$"

BEGIN:
LEA DX, DATA6
MOV AH, 9
NT 21H
XOR SI, SI

INPUT:
MOV AH, 1
INT 21H
CMP AL, 0DH ;is this a carriage return or 13 imediate value?why it is needed?
JZ PROCESS
MOV BYTE PTR [DATA5 + SI], AL
INC SI
CMP SI, 0AH ;line feed or 10?why?
JZ WHAT_THE
JMP INPUT

PROCESS:
CLD
LEA SI, DATA1
MOV DI, SI
LEA CX, DATA5
SUB CX, SI ;CX = ?
SHR CX, 1 ; CX devide by 2?

CONVERT:
LODSW
XOR AX, 0CEFAH ;why this value?
STOSW
LOOP CONVERT
MOV AL, 0
LEA BX, DATA5
SUB BX, 2
XLAT
MOV DL, AL
LEA SI, BYEBYE
SUB SI, 0BH
PUSH SI
MOV DI, SI
MOV CX, 000AH

DECODE:
LODSB
XOR AL, DL
STOSB
LOOP DECODE
MOV CX, 000AH ;why this value?
POP SI
LEA DI, DATA5
REPE CMPSB
JNE WHAT_THE
LEA DX, DATA1
MOV AH, 9
INT 21H
JMP BYEBYE

WHAT_THE:
LEA DX, DATA7
MOV AH,9
INT 21H
JMP BYEBYE
DB 64H, 41H, 46H, 40H, 0EH, 1DH, 14H, 1FH, 18H,0AH, 00H ;why it is here and what it does?
BYEBYE:
MOV AX, 4C00H
INT 21H
END START
------------------------------------------------------------------

thank you..:)

cmp al, 0DH ;it is waiting for you to press the enter key on the assumption that when you do so you will have finished typing stuff in. It then jumps out of the loop which has been fetching keyboard input.

cmp si, 0AH ;That 0AH is the ascii code for a linefeed is probably just a coincidence. It is checking to make sure you do not overflow the DATA5 buffer; even though it would actually take fourteen characters with the terminating '$' (24H)

sub cx,si ;Gives you the number of bytes after DATA1 up until DATA5

shr cx, 1 ;divide by 2 to get number of words because he subsequently uses LODSW instead of LODSB

xor ax, 0CEFAH ;presumably the arbitray value he used to "encrypt" his string

mov cx, 0AH ;the number of bytes he originally let you type into DATA5

DB 64H, 41H, 46H.... ;presumably the encrypted password. Why there, heaven alone knows.

I wouldn't be taking too many lessons off of him if I were you; he must be one of the worst assembly language programmers on the face of the earth.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.