Matrix given in memory to print the spiral in opposite direction from clockwise (left column down the right lower range, right up column, a series of upper left, etc. until you get to the middle)

I'm new here, I have to write code for the task above in assembly,could someone help me and explain me how to solve this task? Please

mov     ecx,0
        mov     cl,[QDM]
        mov     ebx,ecx
        mov     edi,Matrix
mSpiral:
        push    edi

        mov     al,[edi];Output [edi]
        push    ecx

        mov     edx,ecx
        mov     ecx,edx
        dec     ecx
        cmp     ecx,0
        jle     mSkD1
mD1:
        add     edi,ebx
        mov     al,[edi];Output [edi]
        loop    mD1
mSkD1:

        mov     ecx,edx
        dec     ecx
        cmp     ecx,0
        jle     mSkD2
mD2:
        inc     edi
        mov     al,[edi];Output [edi]
        loop    mD2
mSkD2:

        mov     ecx,edx
        dec     ecx
        cmp     ecx,0
        jle     mSkD3
mD3:
        sub     edi,ebx
        mov     al,[edi];Output [edi]
        loop    mD3
mSkD3:

        mov     ecx,edx
        sub     ecx,2
        cmp     ecx,0
        jle     mSkD4
mD4:
        dec     edi
        mov     al,[edi];Output [edi]
        loop    mD4
mSkD4:

        pop     ecx

        pop     edi
        add     edi,ecx
        inc     edi

        sub     ecx,2
        cmp     ecx,0
        jle     mEx
        jmp     mSpiral
mEx:

Matrix  db 0,1,2,3,4,5,6,7,8,9,0Ah,0Bh,0Ch,0Dh,0Eh,0Fh
QDM     db 4;Matrix dimension

, each line mov al,[edi];Output [edi] means print. I did not implement it because I do not know what compiler and OS do you use.

I use assembler 8086. by which interrupt I should print the result ??
mov ah, 02h
int 21h ?? or something else?????
Thanks for your help

Yes, you can use it.

I tried one more time, but doesn't work.Your post is all right and helpful for me
If you can help me one more time it would be grateful. I couldn't print the result. tnx

I work on Windows 7. It does not allow to use interrupts, so I can print using Windows API only. Is it fine for you?

The AL(Assemly Linker) task wraps AL.exe, a tool that is distributed with the Windows Software Development Kit (SDK). This Assembly Linker tool is used to create an assembly with a manifest from one or more files that are either modules or resource files.

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.