forked from daltonbr/MatrixAssembly
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgreaterInDiagonal.s
More file actions
44 lines (33 loc) · 872 Bytes
/
greaterInDiagonal.s
File metadata and controls
44 lines (33 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* Assembly AT&T */
.text
.global greaterInDiagonal_s
greaterInDiagonal_s:
push %ebp
mov %esp,%ebp
xor %edx, %edx
xor %eax, %eax
xor %ecx, %ecx
mov 8(%ebp), %ecx /* L */
mov 8(%ebp), %edx
mov $1,%eax
add %ecx, %eax /* ax = L+1 */
add %eax, %eax
add %eax, %eax /* eax = 4*(L+1) , int = 4 bytes */
dec %ecx /* L-1 */
mov %eax, %esi /* reference to 4*(L+1) */
mov 12(%ebp),%ebx /* adress of matrix's first element */
xor %edi, %edi
loop:
/* counter ecx L-1 ~ 0 */
mov %esi,%eax
mul %ecx
cmp (%ebx,%eax), %edi /* compare current max value */
ja continue /* if not, doesn't change the current max value */
mov (%ebx,%eax), %edi /* else...change it */
continue:
dec %ecx
jns loop /* loop l times */
mov %edi,%eax
mov %ebp,%esp
pop %ebp
ret