Sistemi di Calcolo

Corso di Laurea in Ingegneria Informatica e Automatica - A.A. 2017-2018

HomePage | Avvisi | Diario lezioni | Programma | Materiale didattico | Esami | Forum | Login

Revision [3143]

Last edited on 2017-10-22 16:21:59 by CamilDemetrescu
Additions:
===Venerdì 20 e martedì 24 ottobre 2017 (Lezione 6 - 90 min) - Demetrescu/Coppa===


Revision [3131]

Edited on 2017-10-22 15:42:37 by CamilDemetrescu
Additions:
# int sumsqr(int* v, int n) { // v <-> esi, n <-> edi, s <-> ebx
Deletions:
# int sumsqr(int* v, int n) { // v <-> esi, n <-> edi, s <-> ebx


Revision [3130]

Edited on 2017-10-22 15:42:30 by CamilDemetrescu
Additions:
# int sumsqr(int* v, int n) { // v <-> esi, n <-> edi, s <-> ebx
Deletions:
# int sumsqr(int* v, int n) { # v <-> esi, n <-> edi, s <-> ebx


Revision [3129]

Edited on 2017-10-22 15:41:40 by CamilDemetrescu
Additions:
%%(c;f.s)
Deletions:
%%(c, f.s.)


Revision [3128]

Edited on 2017-10-22 15:41:04 by CamilDemetrescu
Deletions:
==Esercizio: calcolo espressione con LEA==
int f(int x, int y) {
return x+2*y-7;
%%(c,f.s)
movl 4(%esp), %ecx
movl 8(%esp), %edx
leal -7(%ecx, %edx, 2), %eax


Revision [3127]

Edited on 2017-10-22 15:39:54 by CamilDemetrescu
Additions:
movl 20(%esp), %esi # esi <- v
movl 24(%esp), %edi # edi <- n
movl $0, %ebx # int s = 0;
L: cmpl $0, %edi # L: if (n<=0) goto E;
decl %edi # n--;
addl %eax, %ebx # s += sqr(v[n]);
jmp L # goto L;
E: movl %ebx, %eax # E: return s;
Deletions:
movl 20(%esp), %esi # esi <- v
movl 24(%esp), %edi # edi <- n
movl $0, %ebx # int s = 0;
L: cmpl $0, %edi # L:if (n<=0) goto E;
decl %edi # n--;
addl %eax, %ebx # s += sqr(v[n]);
jmp L # goto L;
E: movl %ebx, %eax # E:return s;


Revision [3126]

Edited on 2017-10-22 15:38:59 by CamilDemetrescu
Additions:
movl 20(%esp), %esi # esi <- v
movl 24(%esp), %edi # edi <- n
movl $0, %ebx # int s = 0;
L: cmpl $0, %edi # L:if (n<=0) goto E;
decl %edi # n--;
addl %eax, %ebx # s += sqr(v[n]);
jmp L # goto L;
E: movl %ebx, %eax # E:return s;
Deletions:
movl 20(%esp), %esi # esi <- v
movl 24(%esp), %edi # edi <- n
movl $0, %ebx # int s = 0;
L: cmpl $0, %edi # L:if (n<=0) goto E;
decl %edi # n--;
addl %eax, %ebx # s += sqr(v[n]);
jmp L # goto L;
E: movl %ebx, %eax # E:return s;


Revision [3125]

Edited on 2017-10-22 15:38:22 by CamilDemetrescu
Additions:
# int sumsqr(int* v, int n) { # v <-> esi, n <-> edi, s <-> ebx
# int s = 0;
# while (n>0) {
# n--;
# s += sqr(v[n]);
# }
# return s;
.globl sumsqr
sumsqr:
movl 20(%esp), %esi # esi <- v
movl 24(%esp), %edi # edi <- n
movl $0, %ebx # int s = 0;
L: cmpl $0, %edi # L:if (n<=0) goto E;
decl %edi # n--;
movl (%esi, %edi, 4), %eax
addl %eax, %ebx # s += sqr(v[n]);
jmp L # goto L;
E: movl %ebx, %eax # E:return s;
Deletions:
.globl sommaQuadrati
sommaQuadrati:
# prologo
#
movl 20(%esp), %esi # v <-> esi
movl 24(%esp), %edi # n <-> edi
movl $0, %ebx # s <-> ebx
L:
cmpl $0, %edi
decl %edi
movb (%esi, %edi, 1), %al
movsbl %al, %eax
addl %eax, %ebx
jmp L
E:
movl %ebx, %eax
# epilogo


Revision [3111]

Edited on 2017-10-19 22:37:25 by CamilDemetrescu
Additions:
%%(c;test-equiv.c)
Deletions:
%%(c)


Revision [3110]

Edited on 2017-10-19 22:36:04 by CamilDemetrescu
Additions:
%%(c)
a |= c;
a &= c;
Deletions:
a = a | c;
a = a & c;


Revision [3109]

Edited on 2017-10-19 22:34:35 by CamilDemetrescu
Additions:
int si, di, d;
char a, c;
si = min;
di = max;
d = *x;
a = d < si;
c = d > di;
a = a | c;
c = di > si;
a = a & c;
return (int)a;


Revision [3107]

Edited on 2017-10-19 14:48:05 by EmilioCoppa
Additions:
==Esercizio: calcolo espressione con LEA==
int f(int x, int y) {
return x+2*y-7;
%%(c,f.s)
movl 4(%esp), %ecx
movl 8(%esp), %edx
leal -7(%ecx, %edx, 2), %eax
==Esercizio: SETcc (esempio esonero 2016/2017)==
Deletions:
==Esercizio SETcc (esempio esonero 2016/2017)==


Revision [3106]

Edited on 2017-10-19 14:44:20 by EmilioCoppa
Additions:
subl $8, %esp # prologo
leal 4(%esp), %eax
call g
movl 4(%esp), %eax
addl $8, %esp # epilogo
*p = 23;
printf("%d\n", f());
Deletions:
subl $8, %esp # prologo
leal 4(%esp), %eax
movl %eax, (%esp)
call g
movl 4(%esp), %eax
addl $8, %esp # epilogo
ret
*p = 23;
printf("%d\n", f());
return 0;


Revision [3105]

Edited on 2017-10-19 14:43:34 by EmilioCoppa
Additions:
subl $8, %esp # prologo
leal 4(%esp), %eax
movl %eax, (%esp)
call g
movl 4(%esp), %eax
addl $8, %esp # epilogo
ret
%%(c;main.c)
int f();
void g(int * p) {
*p = 23;
printf("%d\n", f());
return 0;
Deletions:
subl $8, %esp # prologo
leal 4(%esp), (%esp)
call g
movl 4(%esp), %eax
addl $8, %esp # epilogo


Revision [3104]

Edited on 2017-10-19 14:39:01 by EmilioCoppa
Additions:
==Esercizio ripasso: array + passaggio parametri + registri callee-save + cast==
==Esercizio: variabili locali con LEA==
%%(c; f.c)
int f() {
int x;
g(&x);
return x;
%%(c, f.s.)
.globl f
f:
subl $8, %esp # prologo
leal 4(%esp), (%esp)
call g
movl 4(%esp), %eax
addl $8, %esp # epilogo
Deletions:
==Esercizio ripasso: array + passaggio parametri + registri callee-save ==


Revision [3103]

Edited on 2017-10-19 14:33:19 by EmilioCoppa
Additions:
movl $0, %ebx # s <-> ebx
Deletions:
movl $0, %ebx # s <-> ebx


Revision [3102]

Edited on 2017-10-19 14:32:59 by EmilioCoppa
Additions:
char v[] = {2,3,4};
Deletions:
char v = {2,3,4};


Revision [3101]

Edited on 2017-10-19 14:31:55 by EmilioCoppa

No differences.

Revision [3100]

Edited on 2017-10-19 14:31:15 by EmilioCoppa
Additions:
%%(c; main.c)
#include
int sommaQuadrati(char * v, int n);
int main() {
char v = {2,3,4};
printf("res=%d (atteso: %d)\n", sommaQuadrati(v, 3), 29);
return 0;


Revision [3099]

The oldest known version of this page was created on 2017-10-19 14:28:59 by EmilioCoppa
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in 0.0482 seconds