flat assembler
Message board for the users of flat assembler.

Index > DOS > x386 program,, please help

Author
Thread Post new topic Reply to topic
anurag001



Joined: 20 Sep 2010
Posts: 2
anurag001
Please help me with following program by correcting it ,,, I'm doing this for x386 and got all stuck

I replaced some syntaxes that I found but can't get all running

Code:
macro msg{
push ax
push dx
mov ah,09h
lea dx,msg
int 21h
pop dx
pop ax
}

.data
passs =qword 'password'
passd =byte 10 dup('$')
counts =byte 8
countd =byte 0
countt =byte 3
msg_ent =byte 'Enter pass:  $',10,13
msg_err =byte 'Wrong enter again:  $',10,13
msg_suc =byte 'Pass validated  $',10,13
msg_aga =byte 'Turn over:  $',10,13
.code
mov ax,@data
mov ds,ax
next_tr:
displaylay msg_ent
mov cl,0
mov countd,cl
mov di,offset
up:
mov ah,08h
int 21h
cmp al,0dh
je exit
mov [di],al
inc di
inc countd
mov ah,02h
mov dl,'*'
int 21h
jmp up
exit
mov al,countd
cmp al,counts
jne next_try
lea si,passs
lea di,passd
next_char:
mov al,[si]
cmp al,[di]
jne next try
inc si
inc di
dec countd
jnz next_char
display msg_err
dec countt
jnz next_tr
display msg_aga
exit_1:
mov ah,4ch
int 21h
ends
end                         
    



Please forgive me if I've done something wrong..

_________________
just a noob
Post 20 Sep 2010, 15:32
View user's profile Send private message Send e-mail Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
I think it will be better if you show us the original code, this one is somewhat hard to follow.
Post 20 Sep 2010, 16:18
View user's profile Send private message Reply with quote
anurag001



Joined: 20 Sep 2010
Posts: 2
anurag001
all right---

Code:
disp macro msg 
push ax 
push dx 
mov ah,09h 
lea dx,msg 
int 21h 
pop dx 
pop ax 
endm

.data 
passs db 'password' 
passd db 10 dup('$') 
counts db 8 
countd db 0 
countt db 3 
msg_ent db 10,13,'Enter pass:  $',10,13 
msg_err db 10,13,'Wrong enter again:  $',10,13 
msg_suc db 10,13,'Pass validated  $',10,13 
msg_aga db 10,13,'Turn over:  $',10,13 
.code 
mov ax,@data 
mov ds,ax 
next_tr: 
displaylay msg_ent 
mov cl,0 
mov countd,cl 
mov di,offset 
up: 
mov ah,08h 
int 21h 
cmp al,0dh 
je exit 
mov [di],al 
inc di 
inc countd 
mov ah,02h 
mov dl,'*' 
int 21h 
jmp up 
exit 
mov al,countd 
cmp al,counts 
jne next_try 
lea si,passs 
lea di,passd 
next_char: 
mov al,[si] 
cmp al,[di] 
jne next try 
inc si 
inc di 
dec countd 
jnz next_char 
display msg_err 
dec countt 
jnz next_tr 
display msg_aga 
exit_1: 
mov ah,4ch 
int 21h 
ends 
end         
Post 20 Sep 2010, 16:22
View user's profile Send private message Send e-mail Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
Hello, try this Wink
Code:

ORG 100H
use16

;=============================================================================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;=============================================================================

  mov     ax,3
        int     10h



     mov     dx,msg_ent
  call    Display_msg

next_try:

        mov     [countd],0
  mov     di,passd

up:
     mov     ah,08h
      int     21h
 cmp     al,0dh
      je      exit

    mov     [di],al
     inc     di
  inc     [countd]
    cmp     [countd],9
  jnc     exit

    mov     ah,02h
      mov     dl,'*'
    int     21h
 jmp     up

exit:
 
    mov     si,passs
    mov     di,passd

next_char:

  mov     al,[si]
     cmp     al,[di]
     jne     pass_err

        inc     si
  inc     di
  dec     [countd]
    jnz     next_char

       mov     dx,msg_suc
  call    Display_msg

     mov     dx,msg_aga
  call    Display_msg

     ret

pass_err:

        dec     [countt]
    jz      bye_bye

 mov     dx,msg_err
  call    Display_msg
 jmp     next_try

bye_bye:
        
    mov     dx,msg_seeyou
       call    Display_msg

     ret

;=============================================================================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PROC ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;=============================================================================

Display_msg:


       mov     ah,09h
      int     21h

     ret

;=============================================================================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;=============================================================================

msg_ent            db 13,10,'Enter pass:',24h
msg_err     db 13,10,'Wrong enter again:',24h
msg_seeyou   db 13,10,'Bad password!! See you next time',24h
msg_suc    db 13,10,'Pass validated',24h
msg_aga              db 13,10,'Turn over:',24h

passs            db 'password'
passd                db 8 dup('24h')
countd             db 0
countt          db 4
    

save as pass.asm
compile with fasm in this way:
fasm pass.asm
bye
Exclamation

_________________
Nil Volentibus Arduum Razz
Post 20 Sep 2010, 16:43
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Code:
macro disp msg
{
      push      ax
      push      dx
      mov       ah,09h
      lea       dx, [msg]
      int       21h
      pop       dx
      pop       ax
}

format mz
entry @code:start

segment @data
passs db 'password' 
passd db 10 dup('$') 
counts db 8 
countd db 0 
countt db 3 
msg_ent db 10,13,'Enter pass:  $',10,13 
msg_err db 10,13,'Wrong enter again:  $',10,13 
msg_suc db 10,13,'Pass validated  $',10,13 
msg_aga db 10,13,'Turn over:  $',10,13

segment @code
start:
mov ax,@data 
mov ds,ax 
next_try:
disp msg_ent
mov cl,0 
mov [countd],cl
mov di, passd ; <<<<<<< I added this, original was "mov di, offset" which means nothing (because it is incomplete). This is fasm's way of "mov di, offset passd"
up: 
mov ah,08h 
int 21h 
cmp al,0dh 
je exit 
mov [di],al 
inc di 
inc [countd]
mov ah,02h 
mov dl,'*' 
int 21h 
jmp up 
exit:disp passd
mov al,[countd]
cmp al,[counts]
jne next_try
lea si,[passs]
lea di,[passd]
next_char: 
mov al,[si] 
cmp al,[di] 
jne next_try
inc si 
inc di 
dec [countd]
jnz next_char 
disp msg_err
dec [countt]
jnz next_try
disp msg_aga
exit_1: 
mov ah,4ch 
int 21h    
Post 20 Sep 2010, 16:50
View user's profile Send private message Reply with quote
janequorzar



Joined: 11 Sep 2010
Posts: 60
janequorzar
keep in mind too, your code has lines like .data in it. Some assemblers complain about that. If your using it as a label, then add the colon at the end of it, .data: like that. Again, that is if your using it as a label.

Otherwise, just take that line out. Same thing with .code
Post 22 Sep 2010, 03:12
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.