1's complement code not working ! help please

Discussion in 'Assembly Language Programming (ALP) Forum' started by rabir, May 4, 2013.

  1. rabir

    rabir New Member

    Joined:
    May 4, 2013
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi everyone
    i'm new in assembly language.i try to code for 1's complement but not working.is there anyone who can detect my error

    code is
    Code:
    Title Length of an array
    .model small
    .stack 100h
    .data
    msg0 db 0dh,0ah, 'Enter the binary value :  $'
    msg1 db 0dh,0ah, 'the 1s complement form is: $'
    str1 db 255 dup (?)
    one db ?
    two db ?
    .code
    main proc
    mov ax,@data
    mov ds,ax
    
    lea dx,msg0
    mov ah,09h
    int 21h
    
    lea si,str1 ; read a string 
    mov ah,01h
    
    read:
            int 21h
            ;mov bl,al
            
            cmp al,0dh; carrage return
            je display; if input is a carrege return than jump display section
    
            cmp al,00h
            je _0_
    
            cmp al,01h
            je _1_
    
    _0_:
            mov al,30h
            mov [si],al
            inc si
            jmp read
    
    _1_:    
            mov al,31h
            mov [si],al
            inc si
            jmp read        
    
    
    
    display: 
                
                  mov al,'$'
                mov [si],al
                
                
                lea dx,msg1
                mov ah,09h
                int 21h
                
                lea dx, str1
                mov ah,09h
                int 21h
    
                mov ah, 4ch
                int 21h
    main endp
    end main
    
    thanks everyone
     
    Last edited by a moderator: May 5, 2013

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