Additions:
==Esercizio 3==
%%(c;es3.s)
# int makepass(int* v, int n) { // esi <-> v, edi <-> n
# int cont = 0; ebx <-> cont
# L: n--;
# if (n<=0) goto E;
# if (v[n]>=v[n-1]) goto L;
# swap(v+n, v+n-1);
# cont = 1;
# E: return cont;
.globl makepass
makepass:
pushl %esi
pushl %edi
pushl %ebx
subl $8, %esp # prologo
movl 24(%esp), %esi # v
movl 28(%esp), %edi # n
xorl %ebx, %ebx # int cont = 0; ebx <-> cont
L: decl %edi # L: n--
cmpl $0, %edi # tmp = n-0
jle E # if (tmp<=0) goto E
movl (%esi,%edi,4), %ecx # c = v[n]
cmpl -4(%esi,%edi,4), %ecx # tmp = c-v[n-1]
jge L # if (tmp>=0) goto L;
leal (%esi,%edi,4), %ecx # c = &v[n]
movl %ecx, (%esp) # 1mo param
leal -4(%esi,%edi,4), %ecx # c = &v[n-1]
movl %ecx, 4(%esp) # 2do param
call swap # swap(v+n, v+n-1);
movl $1, %ebx # cont = 1;
jmp L # goto L;
E: movl %ebx, %eax # E: return cont;
addl $8, %esp # epilogo
popl %ebx
popl %edi
popl %esi
Additions:
===Soluzioni esercitazione 3 discusse in classe (Canale AO)===
%%(c;es2.c)
void cancspazi(char* s) {
int i=0, j=0;
while (s[i]!=0) {
if (s[i]!=32) {
s[j] = s[i];
j++;
}
i++;
}
s[j] = 0;
}
%%(c;es2.s)
Deletions:
===Soluzioni esercitazione 4 discusse in classe - Canale AO===
%%(c;Es2.s)
Additions:
ret
Deletions:
# ret