I had to write a program that finds out whether a matrix is Skew-symmetric matrix or not...well my code is a disaster I seek help in this matter.
In which way can I write this code to make it eficient,short and smart?
this is my code (yet again it;s a disaster I know):
sstack segment stack
dw 100h dup(?)
sstack ends
sdata segment
a db 0,0fch,0f8h,0eeh,4,0,0f7h,0edh,8,9,0,0ech,12h,13h,14h,0
N db 4
num db 0
count db 0
sdata ends
scode segment
assume ss:sstack,ds:sdata,cs:scode
start:mov ax,sdata
mov ds,ax
mov cx,0
mov bl,N
mov ax,0
mov al,N
mul bl
mov cl,al
mov si,0
mov di,0
mov ax,0
mov dx,0
loop1:
mov bx,0
mov bl,a[si]
mov bh,a[di]
add bh,bl
cmp bh,0
jne not_Skew_symmetric matrix
inc si
mov bx,0
mov bl,N
add di,bx
inc count
mov bl,N
cmp count,bl
jne cont
inc num
mov bx,0
mov bl,num
mov di,bx
mov count,0
cont:
loop loop1
jmp cont2
not_Skew_symmetric matrix:
mov ax,0ffffh
cont2:
mov ah,4ch
int 21h
scode ends
end start
Sorry about the mess >.>;
This is the part that checks the main diagoncal for 0s:
sstack segment stack
dw 100h dup(?)
sstack ends
sdata segment
a db 0,0fch,0f8h,0eeh,4,0,0f7h,0edh,8,9,0,0ech,12h,13h,14h,0
N db 4
col db 0
row db 0
sdata ends
scode segment
assume ss:sstack,ds:sdata,cs:scode
start:mov ax,sdata
mov ds,ax
mov cx,0
mov bl,N
mov ax,0
mov al,N
mul bl
mov cl,al
mov si,0
mov di,0
mov ax,0
mov dx,0
loop1:
mov dl,row
cmp dl,col
jne cont1
cmp a[si],0
jne diff_matrix
cont2:
inc si
mov bx,0
mov bl,N
mov ax,si
div bl
mov row,al
mov col,ah
loop loop1
jmp cont2
diff_matrix:
mov ax,0ffffh
cont2:
mov ah,4ch
int 21h
scode ends
end start
I worte the part checking for 0s first then started all over with a new idea for checking the rest....I hate these codes -.-;.