1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

I need help !!!!!!!!!!!!!!!!!!!!!!!!!!

Discussion in 'Assembly Language Programming (ALP) Forum' started by duynguyenvan, Aug 28, 2007.

  1. duynguyenvan

    duynguyenvan New Member

    Joined:
    Aug 28, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Hello,
    Could you pls help me answer this question:
    - Please take a look at my small Assembly program that reads a tring from keyboard, then displays all the characters that are not uper-case letters in reverse order:
    Code:
    .model small
    .stack 100
    .data
            tb1 db 'Pls enter a string, enter to finish $'
            tb2 db 10,13,'The characters that are not uper-case : $'
            xau db 80 dup(?)
    .code
    Main proc
            mov ax,@data
            mov ds, ax
            mov es, ax
            mov ah,9
            lea dx,tb1
            int 21h
            xor cx,cx
            lea di,xau
    nhap:        mov ah,1
            int 21h
            cmp al,13
            je thoi
            cmp al,'A'
            jb dung
            cmp al,'Z'
            ja dung
            jmp nhap
    dung:        stosb
            inc cx
            jmp nhap
    thoi:        mov ah,9
            lea dx,tb2
            int 21h
            dec di
            mov si,di
            std
            mov ah,2
    quay:        lodsb        
            mov dl,al
            int 21h
            loop quay
            mov ah,4ch
            int 21h
    Main endp
            End main
    The code above runs very well, even though i did not use the Clear Direction Flag (cld) instruction after the instruction in red (lea di,xau)
    The string processing is still in forward direction.
    The question is that: Why?

    I appreciate your help. my email: duyngv@us.ibm.com

    Regards,
    Duy.
     
    Last edited by a moderator: Aug 28, 2007
  2. duynguyenvan

    duynguyenvan New Member

    Joined:
    Aug 28, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Is there any instructions in the ones below that impact on the Direction Flag so that the DF always set to 0 :
    Code:
    ea dx,tb1
    int 21h
    xor cx,cx
    lea di,xau
    nhap: mov ah,1
    int 21h
    cmp al,13
    je thoi
    cmp al,'A'
    jb dung
    cmp al,'Z'
    ja dung
    jmp nhap
    dung: stosb
    inc cx
    jmp nhap
     
    Last edited by a moderator: Aug 28, 2007
  3. jwshepherd

    jwshepherd New Member

    Joined:
    Aug 13, 2007
    Messages:
    135
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    VP Technology Corporation
    Location:
    Texas
    Home Page:
    nhap: mov ah,-1
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    duynguyenvan, there are lots of things I would like to tell you.

    1. have code blocks when you have code snippets in the posts.
    2. Have a title that describes your content.
    3. Don't just jump into every thread and have the same post.
    4. Be patient for a reply.

    I would suggest you read Hints before you make a query.
     
  5. duynguyenvan

    duynguyenvan New Member

    Joined:
    Aug 28, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Hi jwshepherd,
    what do you mean?
    do you mean the line:
    nhap: mov ah,1
    in my code set the DF to 0 so that the di will always point to a continuous character? like we use the cld instruction?
     
  6. duynguyenvan

    duynguyenvan New Member

    Joined:
    Aug 28, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Dear Shabbir, i'm so sorry for that !
     
  7. duynguyenvan

    duynguyenvan New Member

    Joined:
    Aug 28, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    seems there is no one knows about this stuff ... :(
     

Share This Page