Jump to content


Check out our Community Blogs

juce

Member Since 13 Dec 2011
Offline Last Active Dec 15 2011 08:01 AM
-----

Posts I've Made

In Topic: matrix task in assembly 8086

15 December 2011 - 07:57 AM

I try to solve this task in assembler 8086, there is my code. But it has some errors, could you please help me how to solve?

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

In Topic: matrix task in assembly 8086

14 December 2011 - 12:17 PM

I just read your explanation. Thanks for your advice, those were very useful for me. I look through instruction set of assembly, and I think it isn't so complicated. I will try to translate this code in assembly step by step. I hope that it will works this time:)

In Topic: matrix task in assembly 8086

13 December 2011 - 04:28 PM

include <stdio.h>
#define R 3
#define C 6
void spiralPrint(int m, int n, int a[R][C])
{
int i, k = 0, l = 0;
/* k - starting row index
m - ending row index
l - starting column index
n - ending column index
i - iterator
*/
while (k < m && l < n)
{
/* Print the first row from the remaining rows */
for (i = l; i < n; ++i)
{
printf("%d ", a[k][i]);
}
k++;
/* Print the last column from the remaining columns */
for (i = k; i < m; ++i)
{
printf("%d ", a[i][n-1]);
}
n--;
/* Print the last row from the remaining rows */
if ( k < m)
{
for (i = n-1; i >= l; --i)
{
printf("%d ", a[m-1][i]);
}
m--;
}
/* Print the first column from the remaining columns */
if (l < n)
{
for (i = m-1; i >= k; --i)
{
printf("%d ", a[i][l]);
}
l++;
}
}
}
/* Driver program to test above functions */
int main()
{
int a[R][C] = { {1, 2, 3, 4, 5, 6},
{7, 8, 9, 10, 11, 12},
{13, 14, 15, 16, 17, 18}
};
spiralPrint(R, C, a);
return 0;
}

If somebody know how can I convert into assembly ?

In Topic: matrix task in assembly 8086

13 December 2011 - 01:41 PM

Ok thanks, for the example, it is really that will work on that way. I will try to do something, but I haven't experience with assembly. I hope you will help me when something go wrong with my code.
Thanks in advance

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download