Created
September 6, 2013 15:30
-
-
Save dlion/6465525 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Data una matrice quadrata di interi a 16bit, stampi a video "Vero" se la somma degli elementi della diagonale principale di M coincide con | |
; la somma degli elementi della diagonale secondaria e stampi "Falso" altrimenti. | |
section .data | |
M dw 7,15,3,10,4,2,1,11,7,2,0,56,1,21,4,5 | |
dim equ $-M | |
N equ 4 | |
V db "Vero", 10 | |
dim_V equ $-V | |
F db "Falso", 10 | |
dim_F equ $-F | |
D equ 3 | |
section .text | |
global _start | |
_start: | |
mov eax, 0 | |
mov ebx, 0 | |
mov ecx, D | |
mov esi, N | |
shl esi, 1 | |
scan_rows: | |
mov di, [eax+ebx*2+M] | |
add dx, di | |
mov di, [eax+ecx*2+M] | |
add bp, di | |
change_rows: | |
add eax, esi | |
inc ebx | |
dec ecx | |
cmp eax, dim | |
je risultato | |
jmp scan_rows | |
risultato: | |
cmp dx, bp | |
je vero | |
falso: | |
mov edx,dim_F | |
mov ecx, F | |
mov ebx, 1 | |
mov eax, 4 | |
int 0x80 | |
jmp fine | |
vero: | |
mov edx, dim_V | |
mov ecx, V | |
mov ebx, 1 | |
mov eax, 4 | |
int 0x80 | |
fine: | |
mov ebx, 0 | |
mov eax, 1 | |
int 0x80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment