Assembly language program to display sum of all even numbers between 1 to 100

Code

org 100h
.stack 100h
.data
string db "sum of all even number is: $" 
sum dw 0
.code 
main proc
    mov ax,@data
    mov ds,ax
    
    mov ax,0
    mov cx,0
    
    l1:
    add ax,cx
    add cl,2
    cmp cl,100
    jle l1
    
    mov dx,0
    mov bx,10
    mov cx,0
    
    l2:
    div bx
    push dx
    mov dx,0
    
    mov ah,0
    inc cx
    cmp ax,0
    jne l2
    
    
    mov dx,offset string
    mov ah,09
    int 21h
    
    mov ah,02h
    l3:
    pop dx
    add dx,48
    int 21h
    loop l3
    
    
    mov ah,4ch
    int 21h
    
    main endp
end main

Output



Comments

Popular posts from this blog

Assembly language program to input an integer from user and display whether the number is even or odd

Assembly language program to input string from user and display it

Assembly language program to input string from user and display its length