-
-
Save Feder1co5oave/2217555 to your computer and use it in GitHub Desktop.
Compito di calcolatori del 13/02/2002
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
#include <iostream> | |
using namespace std; | |
struct st { | |
double vv[8]; | |
int a; | |
double b; | |
}; | |
class cl { | |
int n; | |
st s; | |
public: | |
cl(st ss); | |
cl(const cl& cla); | |
cl elab1(cl& cla); | |
cl elab2(st ss, cl& cc); | |
void stampa() | |
{ int i; | |
for (i=0;i<8;i++) cout << s.vv[i] << ' ' ; | |
cout << ' ' << s.a << ' ' << s.b << endl; | |
cout << n << endl; | |
cout << endl; | |
} | |
}; |
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
#include "cc.h" | |
cl::cl(st ss) | |
{ s = ss; | |
n = s.a; | |
} | |
/*cl::cl(const cl& cla) | |
{ s = cla.s; | |
n = cla.n+10; | |
} | |
cl cl::elab1(cl& cla) | |
{ int i; cl cca(cla); | |
for (i=0;i<8;i++) cca.s.vv[i] = s.vv[i]; | |
return cca; | |
} | |
*/ |
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
/* Oggetto cl | |
-------- | |
n 0 | |
s.vv[0] 4 | |
s.vv[1] | |
. | |
. | |
. | |
. | |
. | |
s.vv[7] 60 | |
s.a 68 | |
s.b 72 | |
--------80 */ | |
/* cl::cl(const cl& cla) | |
Stack frame | |
-------- | |
ebp <- 0 | |
ip 4 | |
this 8 | |
&cla 12 | |
-------- | |
*/ | |
.global __ZN2clC1ERKS_ | |
__ZN2clC1ERKS_: | |
push %ebp | |
mov %esp, %ebp | |
push %ebx | |
push %esi | |
push %edi | |
push %ecx | |
mov 12(%ebp), %ebx | |
lea 4(%ebx), %esi | |
mov 8(%ebp), %ebx | |
lea 4(%ebx), %edi | |
cld | |
mov $19, %ecx | |
rep movsl | |
mov 12(%ebp) ,%ebx | |
mov (%ebx), %eax | |
add $10, %eax | |
mov 8(%ebp), %ebx | |
mov %eax, (%ebx) | |
mov %ebx, %eax | |
pop %ecx | |
pop %edi | |
pop %esi | |
pop %ebx | |
pop %ebp | |
ret | |
/* cl cl::elab1(cl& cla) | |
Stack frame | |
-------- | |
cca.n -84 | |
cca.s.vv[0] -80 | |
cca.s.vv[1] -72 | |
. | |
. | |
. | |
. | |
. | |
cca.s.vv[7] -24 | |
cca.s.a -16 | |
cca.s.b -12 | |
i -4 | |
ebp <- 0 | |
ip 4 | |
&ret 8 | |
this 12 | |
&cla 16 | |
*/ | |
.global __ZN2cl5elab1ERS_ | |
__ZN2cl5elab1ERKS_: | |
push %ebp | |
mov %esp, %ebp | |
push %ebx | |
push %ecx | |
sub $80, %esp | |
pushl 16(%ebp) | |
lea -80(%ebp), %ebx | |
push %ebx | |
call __ZN2clC1ERKS_ | |
add $8, %esp | |
mov 12(%ebp), %ebx | |
xor %ecx, %ecx | |
for: | |
cmp $8, %ecx | |
jge finefor | |
mov 4(%ebx, %ecx, 8), %eax | |
mov %eax, -76(%ebp, %ecx, 8) | |
mov 8(%ebx, %ecx, 8), %eax | |
mov %eax, -72(%ebp, %ecx, 8) | |
inc %ecx | |
jmp for | |
finefor: | |
lea -80(%ebp), %ebx | |
push %ebx | |
pushl 8(%ebp) | |
call __ZN2clC1ERKS_ | |
add $88, %esp | |
pop %ecx | |
pop %ebx | |
pop %ebp | |
ret $4 |
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
#include "cc.h" | |
int main() | |
{ st ssa = {1,2,3,4,5,6,7,8, 10, 20}, | |
ssb = {11,12,13,14,15,16,17,18, 30, 40}; | |
cl cla1(ssa), cla2(ssb); | |
cla1.stampa(); cla2.stampa(); | |
cout << endl; | |
cla1 = cla1.elab1(cla2); | |
cla1.stampa(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment