Print out and Exlpain

Discussion in 'Assembly Language Programming (ALP) Forum' started by ahmed-mii, May 9, 2010.

  1. ahmed-mii

    ahmed-mii New Member

    Joined:
    May 9, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Hi,the program is Binary Search ,but how do I print out two digits this is the code.
    Code:
    org 0x0100   
                ;mov  [swap],0
                mov cx,1
                jmp start
                
        
        data:   dw 60,80,0,50,70,90,20,30,10,40
        
        swap:   db 0
                   
        
        
        start:  mov bx,0
                mov byte [swap],0    
                
        loopl:  mov ax, [data+bx]
                cmp ax, [data+bx+2]
                jbe noswap
                
                
                
                 mov dx,[data+bx+2]
                 mov [data+bx+2],ax
                 mov [data+bx],dx
                 mov byte[swap],1
                
                
             
        noswap: add bx,2
                cmp bx,18
                jne loopl
                
                ;xopr [swap],[swap]
               
                add cx,1
                cmp cx,10         
                jbe  start 
                
                
                mov cx,10 
                mov bx,data  
                
        printsorted:
                
                
                mov al, [bx]
                add bx,2  
                or  al, 30h
                mov ah,0eh  
                int 10h
                sub cx,1
                jnz printsorted
    
                mov ax,0x4c00             
                int 0x21       
    
    I'm waiting.. :D:D
     
    Last edited by a moderator: May 10, 2010
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    How you print one digit is going to be very hardware and software dependent. You need to tell us what processor you're using and what hardware that processor is mounted in.

    Are you on a course? If so, there will probably be something in the course notes about how to output data for the user's benefit. Seems odd that you're working on sorting algorithms without having already encountered that.
     
  3. ahmed-mii

    ahmed-mii New Member

    Joined:
    May 9, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    thanks for your reply this program you saw it print out one digit Ok ,but I want to print out two digits the assembler I'm using is NASM and my processor is 32 bit.
    So this code you saw for one digit .Is there a way print out to digits if we change the data to 60,80,50. who can I print out them ?Do I need a stack or what??

    Code:
    org 0x0100
    ;mov [swap],0
    mov cx,1
    jmp start
    
    
    data: dw  6,8,0,5,7,9,2,3,1,4
    
    swap: db 0
    
    
    
    start:  mov bx,0
    mov byte [swap],0
    
    loopl: mov ax, [data+bx]
    cmp ax,  [data+bx+2]
    jbe noswap
    
    
    
    mov dx,[data+bx+2]
    mov  [data+bx+2],ax
    mov [data+bx],dx
    mov byte[swap],1
    
    
    
    noswap:  add bx,2
    cmp bx,18
    jne loopl
    
    ;xopr [swap],[swap]
    
    add  cx,1
    cmp cx,10
    jbe start
    
    
    mov cx,10
    mov bx,data
    
    printsorted:
    
    
    mov  al, [bx]
    add bx,2
    or al, 30h
    mov ah,0eh
    int 10h
    sub cx,1
    jnz  printsorted
    
    mov ax,0x4c00
    int 0x21
     
    Last edited by a moderator: May 10, 2010
  4. ahmed-mii

    ahmed-mii New Member

    Joined:
    May 9, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    come on guys plz help me
     
  5. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    I just tried to help you but you ignored my questions. Is it the int 10h that displays the number? Where is the number displayed - on a PC screen? What do you want to change to 60,80,50 (i.e. what is it now, cos I can't see anything in the program that looks like it might change easily to that)? Why do you think you might need a stack?

    Don't assume that the development system you're working on is the only one in the world, or that we all know exactly what you're talking about.
     
  6. ahmed-mii

    ahmed-mii New Member

    Joined:
    May 9, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Ok,thanks I tried to be clear as much as I can you see the program print out one digit .So how can I print out two digits.
    Look man I don't know much about the assembly language if you can help out I'll be thankful for you
     
  7. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    No idea then. If the program prints one digit and you can identify the line that prints that digit, then I would have thought the obvious solution was to duplicate that line.

    But I suggest your best bet would be to get hold of a programmer, or ask your tutor. I simply don't have the context available to be able to help you.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice