-
-
Save Feder1co5oave/2417258 to your computer and use it in GitHub Desktop.
Compito di calcolatori del 29/05/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 st1 { int vv1[4]; int vv2[8]; }; | |
struct st2 { double vv1[4]; double vv2[8]; }; | |
class cl | |
{ st1 s1; st2 s2; int n; | |
public: | |
cl(st1 ss); | |
cl(const cl& cla); | |
cl elab1(st1 ss); | |
void elab2(st2 ss, cl& cla); | |
void stampa() | |
{ int i; | |
cout << n << endl; | |
for (i=0;i<4;i++) cout << s1.vv1[i] << ' ' ; cout << '\t'; | |
for (i=0;i<8;i++) cout << s1.vv2[i] << ' ' ; cout << endl; | |
for (i=0;i<4;i++) cout << s2.vv1[i] << ' ' ; cout << '\t'; | |
for (i=0;i<8;i++) cout << s2.vv2[i] << ' ' ; cout << endl; | |
cout << endl; | |
} | |
}; | |
/*cl::cl(st1 ss) | |
{ int i; | |
n = 1; | |
for (i=0; i<4; i++) { s1.vv1[i] = ss.vv1[i]+1; s2.vv1[i] = 0; } | |
for (i=0; i<8; i++) { s1.vv2[i] = 2*ss.vv2[i]; s2.vv2[i] = 0; } | |
}*/ | |
/*cl::cl(const cl& cla) | |
{ *this = cla; | |
n++; | |
}*/ | |
/*cl cl::elab1(st1 ss) | |
{ int i; | |
cl cla(*this); | |
for (i=0;i<4;i++)cla.s1.vv1[i] += ss.vv1[i]; | |
for (i=0;i<8;i++)cla.s1.vv2[i] += ss.vv2[i]; | |
return cla; | |
}*/ |
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
/* | |
st1: | |
vv1[0] 0 | |
vv1[1] | |
vv1[2] | |
vv1[3] | |
vv2[0] 16 | |
... | |
vv2[7] | |
48 | |
-------------------------------- | |
st2: | |
vv1[0] 0 | |
. | |
vv1[1] | |
. | |
vv1[2] | |
. | |
vv1[3] | |
. | |
vv2[0] 32 | |
... | |
vv2[7] | |
. | |
96 | |
---------------------------------- | |
cl | |
s1.vv1[0] 0 | |
... | |
s1.vv2[0] 16 | |
... | |
s2.vv1[0] 48 | |
... | |
s2.vv2[0] 80 | |
... | |
n 144 | |
148 | |
*/ | |
.text | |
/* cl::cl(cl const&) | |
ebp 0 | |
eip 4 | |
this 8 | |
&cla 12 | |
*/ | |
.global __ZN2clC1ERKS_ | |
__ZN2clC1ERKS_: | |
push %ebp | |
mov %esp, %ebp | |
push %esi | |
push %edi | |
push %ecx | |
mov 12(%ebp), %esi | |
mov 8(%ebp), %edi | |
mov $(148/4), %ecx | |
cld | |
rep movsl | |
mov 8(%ebp), %eax | |
incl 144(%eax) | |
pop %ecx | |
pop %esi | |
pop %edi | |
pop %ebp | |
ret | |
/* cl::cl(st1) | |
ebp 0 | |
eip 4 | |
this 8 | |
ss.vv1[0] 12 | |
... | |
ss.vv2[0] 28 | |
... | |
60 | |
*/ | |
.data | |
zero: .double 0.0 | |
.text | |
.global __ZN2clC1E3st1 | |
__ZN2clC1E3st1: | |
push %ebp | |
mov %esp, %ebp | |
push %ebx | |
push %ecx | |
mov 8(%ebp), %ebx # this | |
movl $1, 144(%ebx) | |
xor %ecx, %ecx | |
for0: | |
cmp $4, %ecx | |
jae endfor0 | |
mov 12(%ebp, %ecx, 4), %eax | |
inc %eax | |
mov %eax, 0(%ebx, %ecx, 4) | |
mov zero+4, %eax # zeroL | |
mov %eax, 52(%ebx, %ecx, 8) | |
mov zero, %eax # zeroH | |
mov %eax, 48(%ebx, %ecx, 8) | |
inc %ecx | |
jmp for0 | |
endfor0: | |
xor %ecx, %ecx | |
for1: | |
cmp $8, %ecx | |
jae endfor1 | |
mov 28(%ebp, %ecx, 4), %eax | |
sal $1, %eax | |
mov %eax, 16(%ebx, %ecx, 4) | |
mov zero+4, %eax | |
mov %eax, 84(%ebx, %ecx, 8) | |
mov zero, %eax | |
mov %eax, 80(%ebx, %ecx, 8) | |
inc %ecx | |
jmp for1 | |
endfor1: | |
mov %ebx, %eax | |
pop %ecx | |
pop %ebx | |
pop %ebp | |
ret | |
/* cl cl::elab1(st1) | |
cla.s1.vv1 -148 | |
... | |
cla.s1.vv2 -132 | |
... | |
cla.s2.vv1 -100 | |
... | |
cla.s2.vv2 -68 | |
... | |
cla.n -4 | |
ebp 0 | |
eip 4 | |
ret 8 | |
this 12 | |
ss.vv1 16 | |
... | |
ss.vv2 32 | |
... | |
64 | |
*/ | |
.global __ZN2cl5elab1E3st1 | |
__ZN2cl5elab1E3st1: | |
push %ebp | |
mov %esp, %ebp | |
sub $148, %esp # cla() | |
push %ecx | |
pushl 12(%ebp) | |
lea -148(%ebp), %eax | |
push %eax | |
call __ZN2clC1ERKS_ | |
add $8, %esp | |
xor %ecx, %ecx | |
for2: | |
cmp $4, %ecx | |
jae endfor2 | |
mov 16(%ebp, %ecx, 4), %eax | |
add %eax, -148(%ebp, %ecx, 4) | |
inc %ecx | |
jmp for2 | |
endfor2: | |
xor %ecx, %ecx | |
for3: | |
cmp $8, %ecx | |
jae endfor3 | |
mov 32(%ebp, %ecx, 4), %eax | |
add %eax, -132(%ebp, %ecx, 4) | |
inc %ecx | |
jmp for3 | |
endfor3: | |
lea -148(%ebp), %eax | |
push %eax | |
pushl 8(%ebp) | |
call __ZN2clC1ERKS_ | |
add $8, %esp | |
mov 8(%ebp), %eax | |
pop %ecx | |
add $148, %esp # ~cla() | |
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() | |
{ st1 ssa1 = {1,2,3,4, 5,6,7,8,9,10,11,12}, | |
ssa2 = {21,22,23,24, 25,26,27,28,29,30,31,32}; | |
cl cla1(ssa1), cla2(cla1), cla3(ssa1); | |
cla1.stampa(); cla2.stampa(); | |
cla3 = cla1.elab1(ssa2); | |
cla3.stampa(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment