+ Reply to Thread
Results 1 to 2 of 2

Thread: add even numbers

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    36

    add even numbers

    Hi , i want to Write an assembly program to add even numbers from (2 to 10) using loop.

  2. #2
    Glad to answer you , here is the corresponding code :

    Code:
    .model small
    .data
    a dw 02d
    b dw 10d
    result dw ?
    .code
    start:
    	mov ax,@data
    	mov ds,ax
    	mov cx,b
    	mov ax,0h
    aaaaa:  add ax,cx
    dec cx ; cx--
    dec cx ; cx-- for second time
    cmp cx,00h
    loop aaaaa ; go to loop
    mov result,ax ; move result to the data register ax
    mov ah,4ch
    int 21h
    end start

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts