Additions:
===Venerdì 13 ottobre 2017 (Lezione 4 - 90 min) - Demetrescu===
Deletions:
===Venerdì 13 ottobre 2017 (Lezione 5 - 90 min) - Demetrescu===
Additions:
==Esempio 2: scambio oggetti in memoria==
Additions:
# a = *d; // a = *x
# c = *d; // c = *y
# *d = a; // *y = a
# *d = c; // *x = c
movb %al, (%edx) # *d = a; -> *y = a
movb %cl, (%edx )# *d = c; -> *x = c
Deletions:
# a = *d; // a = *x
# c = *d; // c = *y
# *d = a; // *y = a
# *d = c; // *x = c
movb %al, (%edx) # *d = a; -> *y = a
movb %cl, (%edx )# *d = c; -> *x = c
No differences.
Additions:
movb (%edx), %al # a = *d; -> a = *x
movb (%edx), %cl # c = *d; -> c = *y
Deletions:
movb (%edx), %al # a = *d; -> a = *x
movb (%edx), %cl # c = *d; -> c = *y
Additions:
movl 4(%esp), %edx # d = x;
movb (%edx), %al # a = *d; -> a = *x
movl 8(%esp), %edx # d = y;
movb (%edx), %cl # c = *d; -> c = *y
movl 4(%esp), %edx # d = x;
Deletions:
movl 4(%esp), %edx # d = x;
movb (%edx), %al # a = *d; -> a = *x
movl 8(%esp), %edx # d = y;
movb (%edx), %cl # c = *d; -> c = *y
movl 4(%esp), %edx # d = x;
Additions:
movb %al, (%edx) # *d = a; -> *y = a
movb %cl, (%edx )# *d = c; -> *x = c
Deletions:
movb %al, (%edx) # *d = a; // *y = a
movb %cl, (%edx )# *d = c; // *x = c
Additions:
void swap(char* x, char* y);
char u=10, v=20;
swap(&u, &v);
printf("u=%d, v=%d\n", u, v); // 20, 10
%%(c;swap.c)
void swap(char* x, char* y) {
char a, c;
a = *x;
c = *y;
*y = a;
*x = c;
%%(c;swap.s)
# void swap(char* x, char* y) {
# char a, c;
# a = *x;
# c = *y;
# *y = a;
# *x = c;
# void swap(char* x, char* y) {
# char a, c, *d;
# d = x;
# a = *d; // a = *x
# d = y;
# c = *d; // c = *y
# *d = a; // *y = a
# d = x;
# *d = c; // *x = c
.globl swap
swap:
movl 4(%esp), %edx # d = x;
movb (%edx), %al # a = *d; -> a = *x
movl 8(%esp), %edx # d = y;
movb (%edx), %cl # c = *d; -> c = *y
movb %al, (%edx) # *d = a; // *y = a
movl 4(%esp), %edx # d = x;
movb %cl, (%edx )# *d = c; // *x = c
Additions:
movl 4(%esp), %ecx # short* c = v; -> indirizzo base vettore
movl 8(%esp), %edx # int d = i; -> indice
movw (%ecx, %edx, 2), %eax # short a = c[d];
incw %ax # a++;
movw %ax, (%ecx, %edx, 2) # c[d] = a;
Deletions:
movl 4(%esp), %ecx # short* c = v; // indirizzo base vettore
movl 8(%esp), %edx # int d = i; // indice
movw (%ecx, %edx, 2), %eax # short a = c[d];
incw %ax # a++;
movw %ax, (%ecx, %edx, 2) # c[d] = a;
Additions:
movl 4(%esp), %ecx # short* c = v; // indirizzo base vettore
movl 8(%esp), %edx # int d = i; // indice
incw %ax # a++;
movw %ax, (%ecx, %edx, 2) # c[d] = a;
Deletions:
movl 4(%esp), %ecx # short* c = v; // indirizzo base vettore
movl 8(%esp), %edx # int d = i; // indice
incw %ax # a++;
movw %ax, (%ecx, %edx, 2) # c[d] = a;
Additions:
%%(c;incr.c)
void incr(short* v, int i) {
v[i]++;
%%(asm;incr.s)
# void incr(short* v, int i) {
# v[i]++;
# }
# void incr(short* v, int i) {
# short* c = v; // indirizzo base vettore
# int d = i; // indice
# short a = c[d];
# a++;
# c[d] = a;
# }
.globl incr
incr:
movl 4(%esp), %ecx # short* c = v; // indirizzo base vettore
movl 8(%esp), %edx # int d = i; // indice
movw (%ecx, %edx, 2), %eax # short a = c[d];
incw %ax # a++;
movw %ax, (%ecx, %edx, 2) # c[d] = a;
ret
Additions:
==Esempio 1: modifica i-esimo elemento di un array==
Deletions:
==Esempio 1: accesso ad array==
Additions:
===Venerdì 13 ottobre 2017 (Lezione 5 - 90 min) - Demetrescu===
Sessione pratica con spiegazioni:
==Esempio 1: accesso ad array==