Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2014-09-17
- #include <iostream>
- using namespace std;
- struct st1 { char vc[4]; }; struct st2 { int vd[4]; };
- class cl
- { st1 s; int v[4];
- public:
- cl(char c, st2& s2);
- void elab1(st1 s1, st2 s2);
- void stampa()
- { int i;
- for (i=0;i<4;i++) cout << s.vc[i] << ' '; cout << endl;
- for (i=0;i<4;i++) cout << v[i] << ' '; cout << endl << endl;
- }
- };
- #include "cc.h"
- cl::cl(char c, st2& s2) {
- for (int i = 0; i < 4; i++) {
- s.vc[i] = c + i;
- v[i] = s2.vd[i] + s.vc[i];
- }
- }
- void cl::elab1(st1 s1, st2 s2) {
- cl cla('a', s2);
- for (int i = 0; i < 4; i++) {
- if (s.vc[i] <= s1.vc[i]) {
- s.vc[i] = cla.s.vc[i];
- v[i] = cla.v[i];
- }
- }
- }
- SOLUZIONE
- .global _ZN2clC1EcR3st2
- _ZN2clC1EcR3st2:
- # RECORD DI ATTIVAZIONE
- # &s2 -24
- # i | c -16
- # this -8
- .set s2, -24
- .set i, -12
- .set c, -16
- .set this, -8
- # PROLOGO
- pushq %rsp
- movq %rsp, %rbp
- subq $24, %rsp
- # COPIO PARAMETRI
- movq %rdi, this(%rbp)
- movb %sil, c(%rbp)
- movq %rdx, s2(%rbp)
- movl $0, i(%rbp)
- for:
- cmpl $4, i(%rbp)
- jge finefor
- movq this(%rbp), %rdi
- movslq i(%rbp), %rcx
- movb c(%rbp), %al
- addb %cl, %al
- movb %al, (%rdi, %rcx) # (%rdi, %rcx) = s.vc[i]
- movq s2(%rbp, %rcx, 4), %r9 # s2.vd[i]
- addq (%rdi, %rcx), %r9
- movq %r9, 4(%rdi, %rcx, 4)
- incl i(%rbp)
- jmp for
- finefor:
- leave
- ret
- # ELAB1
- .global _ZN2cl5elab13st13st2
- _ZN2cl5elab1E3st13st2:
- # RECORD DI ATTIVAZIONE
- # cla.s | _ _ _ _ -64
- # cla.v[1] | cla.v[0] -56
- # cla.v[3] | cla.v[2] -48
- # cla -40
- # s2[1] | s2[0] -32
- # s2[3] | s2[2] -24
- # i | s1 -16
- # this -8
- .set this, -8
- .set i, -12
- .set s1, -16
- .set s2, -32
- .set cla, -64
- # PROLOGO
- pushq %rsp
- movq %rsp, %rbp
- subq $64, %rsp
- # COPIO PARAMETRI
- movl %esi, s1(%rbp)
- movq %rdi, this(%rbp)
- movq %rdx, s2(%rbp) # parte piΓΉ significativa di s2
- movq %rcx, s2+8(%rbp) # parte meno significativa di s2
- # CREO CLA
- leaq cla(%rbp), %rdi
- movb $'a', %sil
- leaq s2(%rbp), %rdx
- call _ZN2clC1EcR3st2
- movl $0, i(%rbp)
- for1:
- cmpl $4, i(%rbp)
- jge finefor
- movslq i(%rbp), %rcx
- movq this(%rbp), %r8
- leaq cla(%rbp), %r9
- if:
- movb (%r8, %rcx), %al # al prende s.vc[i]
- cmpb s1(%rbp, %rcx), %al # confronto s1.vc[i] con s.vc[i]
- jg fineif
- movb (%r9, %rcx), %al # in al ho salvato l'indrizzo di s.vc[i], quindi
- # sposto cla.s.vc[i] in s.vc[i]
- movq 4(%r9, %rcx, 4), %rax
- movq %rax, 4(%r8, %rcx, 4)
- fineif:
- incl i(%rbp)
- jmp for1
- finefor1:
- leave
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement