I have a problem with assembly task.

Write a program that will write the numbers 7-15 in the data segment, starting from offset 200h, and then using a loop and compare them to read data from memory and the DX will insert the sum of numbers divisible by four

Here is my code, and isn't work. I'm begginer in assembly language. Could someone help me .Please

mov ax,data
mov ds,ax
mov cl,07d 
mov ch,015d
mov [bx],200h

ciklus:
mov [bx] ,cl
inc cl
inc bx
cmp cl,ch
jne ciklus

ciklus1:
mov cl,[bx]

AND ax, 3h
add dx, ax
inc cl
inc bx 
else
jmp ciklus1
end if

Recommended Answers

All 2 Replies

This should work:

mov     cl,07d
        mov     ch,015d
        mov     ebx,200h

        mov     eax,0
ciklus:
        mov     [ebx],cl
        inc     cl
        inc     ebx
        inc     eax
        cmp     cl,ch
        jle     ciklus

        mov     ebx,200h
        mov     ecx,eax
        mov     dx,0
ciklus1:
        test    byte [ebx],3h
        jnz     msk
        mov     ax,0
        mov     al,[ebx]
        add     dx,ax
msk:
        inc     ebx
        loop    ciklus1

.

commented: excelent +0

thank you a lot. This really works

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.